程序包 infra.aop
接口 TargetSource
- 所有超级接口:
TargetClassAware
- 所有已知实现类:
AbstractBeanFactoryTargetSource,AbstractLazyCreationTargetSource,AbstractPoolingTargetSource,AbstractPrototypeTargetSource,AbstractRefreshableTargetSource,BeanFactoryRefreshableTargetSource,CommonsPool2TargetSource,EmptyTargetSource,HotSwappableTargetSource,LazyInitTargetSource,PrototypeTargetSource,SimpleBeanTargetSource,SingletonTargetSource,ThreadLocalTargetSource
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.
- 作者:
- Rod Johnson, Juergen Hoeller, TODAY 2021/2/1 19:00
-
方法概要
修饰符和类型方法说明Return a target instance.Class<?>Return the type of targets returned by thisTargetSource.default booleanisStatic()Will all calls togetTarget()return the same object?default voidreleaseTarget(Object target) Release the given target object obtained from thegetTarget()method, if any.
-
方法详细资料
-
getTargetClass
Return the type of targets returned by thisTargetSource.Can return
null, although certain usages of aTargetSourcemight just work with a predetermined target class.- 指定者:
getTargetClass在接口中TargetClassAware- 返回:
- the type of targets returned by this
TargetSource
-
isStatic
default boolean isStatic()Will all calls togetTarget()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 ofgetTarget().The default implementation returns
false.- 返回:
trueif the target is immutable- 另请参阅:
-
getTarget
Return a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.- 返回:
- the target object which contains the join-point,
or
nullif there is no actual target instance - 抛出:
Exception- if the target object can't be resolved
-
releaseTarget
Release the given target object obtained from thegetTarget()method, if any.The default implementation is empty.
- 参数:
target- object obtained from a call togetTarget()- 抛出:
Exception- if the object can't be released
-