public interface TargetSource extends TargetClassAware
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.
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getTarget()
Return a target instance.
|
java.lang.Class<?> |
getTargetClass()
Return the type of targets returned by this
TargetSource . |
boolean |
isStatic()
Will all calls to
getTarget() return the same object? |
void |
releaseTarget(java.lang.Object target)
Release the given target object obtained from the
getTarget() method, if any. |
java.lang.Class<?> getTargetClass()
TargetSource
.
Can return null
, although certain usages of a TargetSource
might just work with a predetermined target class.
getTargetClass
in interface TargetClassAware
TargetSource
boolean isStatic()
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()
.
true
if the target is immutablegetTarget()
java.lang.Object getTarget() throws java.lang.Exception
null
if there is no actual target instancejava.lang.Exception
- if the target object can't be resolvedvoid releaseTarget(java.lang.Object target) throws java.lang.Exception
getTarget()
method, if any.target
- object obtained from a call to getTarget()
java.lang.Exception
- if the object can't be released