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

public Class SingletonTargetSource

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, .ObjectUtils

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

Authors
Rod Johnson, Juergen Hoeller
See Also
org.springframework.aop.framework.AdvisedSupport#setTarget(Object)

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

use serialVersionUID from Spring 1.2 for interoperability.

private final Object
target

Target cached and invoked using reflection.

Constructor Summary

AccessConstructor and Description
public
SingletonTargetSource(Object
the target object
target
)

Create a new SingletonTargetSource for the given target.

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 invoker interceptors are equal if they have the same target or if the targets or the targets are equal.

public Object
getTarget()

Implements org.springframework.aop.TargetSource.getTarget.

Return a target instance.

public Class<?>
getTargetClass()

Implements org.springframework.aop.TargetSource.getTargetClass.

Return the type of targets returned by this TargetSource.

public int
hashCode()

Overrides java.lang.Object.hashCode.

SingletonTargetSource uses the hash code of the target object.

public boolean
isStatic()

Overrides default org.springframework.aop.TargetSource.isStatic.

Will all calls to getTarget() return the same 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 final Object target

Target cached and invoked using reflection.

Annotations
@SuppressWarnings:serial

Constructor Detail

SingletonTargetSourceback to summary
public SingletonTargetSource(Object target)

Create a new SingletonTargetSource for the given target.

Parameters
target:Object

the target object

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Two invoker interceptors are equal if they have the same target or if the targets or the targets 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 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 Class<?> getTargetClass()

Implements org.springframework.aop.TargetSource.getTargetClass.

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

Return the type of targets returned by this TargetSource.

Can return null, although certain usages of a TargetSource might just work with a predetermined target class.

Returns:Class<?>

the type of targets returned by this TargetSource

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

SingletonTargetSource uses the hash code of the target object.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
isStaticback to summary
public boolean isStatic()

Overrides default org.springframework.aop.TargetSource.isStatic.

Doc from org.springframework.aop.TargetSource.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().

The default implementation returns false.

Returns:boolean

true if the target is immutable

Annotations
@Override
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