public class HotSwappableTargetSource extends Object implements TargetSource, Serializable
TargetSource implementation that
caches a local target object, but allows the target to be swapped
while the application is running.
If configuring an object of this class in a Spring IoC container, use constructor injection.
This TargetSource is serializable if the target is at the time of serialization.
| 构造器和说明 |
|---|
HotSwappableTargetSource(Object initialTarget)
Create a new HotSwappableTargetSource with the given initial target object.
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
equals(Object other)
Two HotSwappableTargetSources are equal if the current target
objects are equal.
|
Object |
getTarget()
Return a target instance.
|
Class<?> |
getTargetClass()
Return the type of the current target object.
|
int |
hashCode() |
boolean |
isStatic()
Will all calls to
TargetSource.getTarget() return the same object? |
void |
releaseTarget(Object target)
Release the given target object obtained from the
TargetSource.getTarget() method, if any. |
Object |
swap(Object newTarget)
Swap the target, returning the old target object.
|
String |
toString() |
public HotSwappableTargetSource(Object initialTarget)
initialTarget - the initial target objectpublic Class<?> getTargetClass()
The returned type should usually be constant across all target objects.
getTargetClass 在接口中 TargetClassAwaregetTargetClass 在接口中 TargetSourceTargetSourcepublic final boolean isStatic()
TargetSourceTargetSource.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 在接口中 TargetSourcetrue if the target is immutableTargetSource.getTarget()public Object getTarget()
TargetSourcegetTarget 在接口中 TargetSourcenull if there is no actual target instancepublic void releaseTarget(Object target)
TargetSourceTargetSource.getTarget() method, if any.releaseTarget 在接口中 TargetSourcetarget - object obtained from a call to TargetSource.getTarget()public Object swap(Object newTarget) throws IllegalArgumentException
newTarget - the new target objectIllegalArgumentException - if the new target is invalidpublic boolean equals(Object other)