Top Description Methods
org.springframework.aop

public Interface TargetSource

extends TargetClassAware
Known Direct Implementers
org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource, org.springframework.aop.target.AbstractLazyCreationTargetSource, org.springframework.aop.target.EmptyTargetSource, org.springframework.aop.target.HotSwappableTargetSource, org.springframework.aop.target.SingletonTargetSource, org.springframework.aop.target.dynamic.AbstractRefreshableTargetSource
Imports
org.springframework.lang.Nullable

A TargetSource is used to obtain the current "target" of an AOP invocation, which will be invoked via reflection if no around advice chooses to end the interceptor chain itself.

If a TargetSource is "static", it will always return the same target, allowing optimizations in the AOP framework. Dynamic target sources can support pooling, hot swapping, etc.

Application developers don't usually need to work with TargetSources directly: this is an AOP framework interface.

Authors
Rod Johnson, Juergen Hoeller

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

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

Return a target instance.

public Class<?>

Returns:

the type of targets returned by this TargetSource
getTargetClass
()

Redeclares org.springframework.aop.TargetClassAware.getTargetClass.

Return the type of targets returned by this TargetSource.
public default boolean

Returns:

true if the target is immutable
isStatic
()

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

public default void
releaseTarget(Object
object obtained from a call to getTarget()
target
)

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

Method Detail

getTargetback to summary
public Object getTarget() throws Exception

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
@Nullable
Exceptions
Exception:
if the target object can't be resolved
getTargetClassback to summary
public Class<?> getTargetClass()

Redeclares org.springframework.aop.TargetClassAware.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
@Nullable
isStaticback to summary
public default 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().

The default implementation returns false.

Returns:boolean

true if the target is immutable

See Also
getTarget
releaseTargetback to summary
public default void releaseTarget(Object target) throws Exception

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

The default implementation is empty.

Parameters
target:Object

object obtained from a call to getTarget()

Exceptions
Exception:
if the object can't be released