Package org.springframework.aop.target
Class SingletonTargetSource
- java.lang.Object
- org.springframework.aop.target.SingletonTargetSource
- All Implemented Interfaces:
Serializable,TargetClassAware,TargetSource
public class SingletonTargetSource extends Object implements TargetSource, Serializable
Implementation of theTargetSourceinterface that holds a given object. This is the default implementation of the TargetSource interface, as used by the Spring AOP framework. There is usually 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, Juergen Hoeller
- See Also:
AdvisedSupport.setTarget(Object), Serialized Form
Constructor Summary
Constructors Constructor Description SingletonTargetSource(Object target)Create a new SingletonTargetSource for the given target.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)Two invoker interceptors are equal if they have the same target or if the targets or the targets are equal.ObjectgetTarget()Return a target instance.Class<?>getTargetClass()Return the type of targets returned by thisTargetSource.inthashCode()SingletonTargetSource uses the hash code of the target object.booleanisStatic()Will all calls toTargetSource.getTarget()return the same object?voidreleaseTarget(Object target)Release the given target object obtained from theTargetSource.getTarget()method, if any.StringtoString()
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:TargetSourceReturn the type of targets returned by thisTargetSource.Can return
null, although certain usages of aTargetSourcemight just work with a predetermined target class.- Specified by:
getTargetClassin interfaceTargetClassAware- Specified by:
getTargetClassin interfaceTargetSource- Returns:
- the type of targets returned by this
TargetSource
getTarget
public Object getTarget()
Description copied from interface:TargetSourceReturn a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.- Specified by:
getTargetin interfaceTargetSource- Returns:
- the target object which contains the joinpoint, or
nullif there is no actual target instance
releaseTarget
public void releaseTarget(Object target)
Description copied from interface:TargetSourceRelease the given target object obtained from theTargetSource.getTarget()method, if any.- Specified by:
releaseTargetin interfaceTargetSource- Parameters:
target- object obtained from a call toTargetSource.getTarget()
isStatic
public boolean isStatic()
Description copied from interface:TargetSourceWill all calls toTargetSource.getTarget()return the same object?In that case, there will be no need to invoke
TargetSource.releaseTarget(Object), and the AOP framework can cache the return value ofTargetSource.getTarget().- Specified by:
isStaticin interfaceTargetSource- Returns:
trueif the target is immutable- See Also:
TargetSource.getTarget()
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.
hashCode
public int hashCode()
SingletonTargetSource uses the hash code of the target object.