public class SingletonTargetSource extends java.lang.Object implements TargetSource, java.io.Serializable
TargetSource
interface
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.
AdvisedSupport.setTarget(Object)
,
Serialized FormConstructor and Description |
---|
SingletonTargetSource(java.lang.Object target)
Create a new SingletonTargetSource for the given target.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other)
Two invoker interceptors are equal if they have the same target or if the
targets or the targets are equal.
|
java.lang.Object |
getTarget()
Return a target instance.
|
java.lang.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
TargetSource.getTarget() return the same object? |
void |
releaseTarget(java.lang.Object target)
Release the given target object obtained from the
TargetSource.getTarget() method, if any. |
java.lang.String |
toString() |
public SingletonTargetSource(java.lang.Object target)
target
- the target objectpublic java.lang.Class<?> getTargetClass()
TargetSource
TargetSource
.
Can return null
, although certain usages of a TargetSource
might just work with a predetermined target class.
getTargetClass
in interface TargetClassAware
getTargetClass
in interface TargetSource
TargetSource
public java.lang.Object getTarget()
TargetSource
getTarget
in interface TargetSource
null
if there is no actual target instancepublic void releaseTarget(java.lang.Object target)
TargetSource
TargetSource.getTarget()
method, if any.releaseTarget
in interface TargetSource
target
- object obtained from a call to TargetSource.getTarget()
public boolean isStatic()
TargetSource
TargetSource.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 of TargetSource.getTarget()
.
isStatic
in interface TargetSource
true
if the target is immutableTargetSource.getTarget()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object