Top Description Fields Constructors Methods
org.springframework.aop.target

public Class HotSwappableTargetSource

extends Object
implements TargetSource, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.springframework.aop.TargetSource, org.springframework.aop.TargetClassAware
Imports
java.io.Serializable, org.springframework.aop.TargetSource, org.springframework.lang.Nullable, org.springframework.util.Assert

org.springframework.aop.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.

Authors
Rod Johnson, Juergen Hoeller

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

use serialVersionUID from Spring 1.2 for interoperability.

private Object
target

The current target object.

Constructor Summary

AccessConstructor and Description
public
HotSwappableTargetSource(Object
the initial target object
initialTarget
)

Create a new HotSwappableTargetSource with the given initial target object.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Two HotSwappableTargetSources are equal if the current target objects are equal.

public synchronized Object
getTarget()

Implements org.springframework.aop.TargetSource.getTarget.

Return a target instance.

public synchronized Class<?>
getTargetClass()

Implements org.springframework.aop.TargetSource.getTargetClass.

Return the type of the current target object.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public synchronized Object

Returns:

the old target object
swap
(Object
the new target object
newTarget
)

Swap the target, returning the old target object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

use serialVersionUID from Spring 1.2 for interoperability.

targetback to summary
private Object target

The current target object.

Annotations
@SuppressWarnings:serial

Constructor Detail

HotSwappableTargetSourceback to summary
public HotSwappableTargetSource(Object initialTarget)

Create a new HotSwappableTargetSource with the given initial target object.

Parameters
initialTarget:Object

the initial target object

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Two HotSwappableTargetSources are equal if the current target objects are equal.

Parameters
other:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getTargetback to summary
public synchronized Object getTarget()

Implements org.springframework.aop.TargetSource.getTarget.

Doc from org.springframework.aop.TargetSource.getTarget.

Return a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.

Returns:Object

the target object which contains the joinpoint, or null if there is no actual target instance

Annotations
@Override
getTargetClassback to summary
public synchronized Class<?> getTargetClass()

Implements org.springframework.aop.TargetSource.getTargetClass.

Return the type of the current target object.

The returned type should usually be constant across all target objects.

Returns:Class<?>

Doc from org.springframework.aop.TargetSource.getTargetClass.

the type of targets returned by this TargetSource

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
swapback to summary
public synchronized Object swap(Object newTarget) throws IllegalArgumentException

Swap the target, returning the old target object.

Parameters
newTarget:Object

the new target object

Returns:Object

the old target object

Exceptions
IllegalArgumentException:
if the new target is invalid
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override