public abstract class AopContext extends java.lang.Object
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
can be used in EJBs. They can also use it to find advice configuration.
Spring's 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 Spring AOP framework in particular.
|Modifier and Type||Field and Description|
ThreadLocal holder for AOP proxy associated with this thread.
|Constructor and Description|
|Modifier and Type||Method and Description|
Try to return the current AOP proxy.
Make the given proxy available via the
private static final java.lang.ThreadLocal<java.lang.Object> currentProxy
nullunless the "exposeProxy" property on the controlling proxy configuration has been set to "true".
public static java.lang.Object currentProxy() throws java.lang.IllegalStateException
java.lang.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
static java.lang.Object setCurrentProxy(java.lang.Object proxy)
Note that the caller should be careful to keep the old value as appropriate.
proxy- the proxy to expose (or
nullto reset it)
nullif none was bound