public class

HotSwappableTargetSource

extends Object
implements Serializable TargetSource
java.lang.Object
   ↳ org.springframework.aop.target.HotSwappableTargetSource

Class Overview

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.

Summary

Public Constructors
HotSwappableTargetSource(Object initialTarget)
Create a new HotSwappableTargetSource with the given initial target object.
Public Methods
boolean equals(Object other)
Two HotSwappableTargetSources are equal if the current target objects are equal.
synchronized Object getTarget()
Return a target instance.
synchronized Class<?> getTargetClass()
Return the type of the current target object.
int hashCode()
final boolean isStatic()
Will all calls to getTarget() return the same object?

In that case, there will be no need to invoke releaseTarget(Object), and the AOP framework can cache the return value of getTarget().

void releaseTarget(Object target)
Release the given target object obtained from the getTarget() method.
synchronized Object swap(Object newTarget)
Swap the target, returning the old target object.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.aop.TargetClassAware
From interface org.springframework.aop.TargetSource

Public Constructors

public HotSwappableTargetSource (Object initialTarget)

Create a new HotSwappableTargetSource with the given initial target object.

Parameters
initialTarget the initial target object

Public Methods

public boolean equals (Object other)

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

public synchronized Object getTarget ()

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

Returns
  • the target object, which contains the joinpoint

public synchronized Class<?> getTargetClass ()

Return the type of the current target object.

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

Returns

public int hashCode ()

public final boolean isStatic ()

Will all calls to getTarget() return the same object?

In that case, there will be no need to invoke releaseTarget(Object), and the AOP framework can cache the return value of getTarget().

Returns
  • true if the target is immutable

public void releaseTarget (Object target)

Release the given target object obtained from the getTarget() method.

Parameters
target object obtained from a call to getTarget()

public synchronized Object swap (Object newTarget)

Swap the target, returning the old target object.

Parameters
newTarget the new target object
Returns
  • the old target object
Throws
IllegalArgumentException if the new target is invalid

public String toString ()