类 AopContext
The currentProxy() method is usable if the AOP framework is configured to
expose the current proxy (not the default). It returns the AOP proxy in use. Target objects
or advice can use this to make advised calls, in the same way as getEJBObject()
can be used in EJBs. They can also use it to find advice configuration.
AOP framework does not expose proxies by default, as there is a performance cost in doing so.
The functionality in this class might be used by a target object that needed access to resources on the invocation. However, this approach should not be used when there is a reasonable alternative, as it makes application code dependent on usage under AOP and the AOP framework in particular.
- 从以下版本开始:
- 3.0
- 作者:
- Rod Johnson, Juergen Hoeller, TODAY 2021/2/1 19:39
-
字段概要
字段修饰符和类型字段说明private static final ThreadLocal<Object>ThreadLocal holder for AOP proxy associated with this thread. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static ObjectTry to return the current AOP proxy.(专用程序包) static ObjectsetCurrentProxy(Object proxy) Make the given proxy available via thecurrentProxy()method.
-
字段详细资料
-
currentProxy
ThreadLocal holder for AOP proxy associated with this thread. Will containnullunless the "exposeProxy" property on the controlling proxy configuration has been set to "true".
-
-
构造器详细资料
-
AopContext
public AopContext()
-
-
方法详细资料
-
currentProxy
Try to return the current AOP proxy. This method is usable only if the calling method has been invoked via AOP, and the AOP framework has been set to expose proxies. Otherwise, this method will throw an IllegalStateException.- 返回:
- the current AOP proxy (never returns
null) - 抛出:
IllegalStateException- if the proxy cannot be found, because the method was invoked outside an AOP invocation context, or because the AOP framework has not been configured to expose the proxy
-
setCurrentProxy
Make the given proxy available via thecurrentProxy()method.Note that the caller should be careful to keep the old value as appropriate.
- 参数:
proxy- the proxy to expose (ornullto reset it)- 返回:
- the old proxy, which may be
nullif none was bound - 另请参阅:
-