org.springframework.aop.target
Class SingletonTargetSource

java.lang.Object
  extended byorg.springframework.aop.target.SingletonTargetSource
All Implemented Interfaces:
Serializable, TargetSource

public final class SingletonTargetSource
extends Object
implements TargetSource, Serializable

Implementation of the TargetSource interface that holds a local object. This is the default implementation of TargetSource used by the AOP framework. There is no need to create objects of this class in application code.

This class is serializable. However, the actual serializability of a SingletonTargetSource will depend on whether the target is serializable.

Author:
Rod Johnson
See Also:
AdvisedSupport.setTarget(java.lang.Object), Serialized Form

Constructor Summary
SingletonTargetSource(Object target)
          Create a new SingletonTargetSource for the given target.
 
Method Summary
 boolean equals(Object other)
          Two invoker interceptors are equal if they have the same target or if the targets or the targets are equal.
 Object getTarget()
          Return a target instance.
 Class getTargetClass()
          Return the type of targets returned by this TargetSource.
 int hashCode()
          SingletonTargetSource uses the hash code of the target object.
 boolean isStatic()
          Will all calls to getTarget() return the same object?
 void releaseTarget(Object target)
          Release the given target object obtained from the getTarget() method.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SingletonTargetSource

public SingletonTargetSource(Object target)
Create a new SingletonTargetSource for the given target.

Parameters:
target - the target object
Method Detail

getTargetClass

public Class getTargetClass()
Description copied from interface: TargetSource
Return the type of targets returned by this TargetSource. Can return null, although certain usages of a TargetSource might just work with a predetermined target class.

Specified by:
getTargetClass in interface TargetSource

getTarget

public Object getTarget()
Description copied from interface: TargetSource
Return a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.

Specified by:
getTarget in interface TargetSource
Returns:
the target object, whicch contains the joinpoint

releaseTarget

public void releaseTarget(Object target)
Description copied from interface: TargetSource
Release the given target object obtained from the getTarget() method.

Specified by:
releaseTarget in interface TargetSource
Parameters:
target - object obtained from a call to getTarget()
See Also:
TargetSource.getTarget()

isStatic

public boolean isStatic()
Description copied from interface: TargetSource
Will all calls to getTarget() return the same object? In that case, there will be no need to invoke releaseTarget, and the AOP framework can cache the return value of getTarget().

Specified by:
isStatic in interface TargetSource
Returns:
whether the target is immutable
See Also:
TargetSource.getTarget()

hashCode

public int hashCode()
SingletonTargetSource uses the hash code of the target object.


equals

public boolean equals(Object other)
Two invoker interceptors are equal if they have the same target or if the targets or the targets are equal.


toString

public String toString()


Copyright (C) 2003-2004 The Spring Framework Project.