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.
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 |
|---|---|
| private static final ThreadLocal | currentProxy
ThreadLocal holder for AOP proxy associated with this thread. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Object | Returns: the current AOP proxy (never returnsnull)Try to return the current AOP proxy. |
| pack-priv static Object | Returns: the old proxy, which may benull if none was boundthe proxy to expose (or proxy)null to reset it)Make the given proxy available via the |
| currentProxy | back to summary |
|---|---|
| private static final ThreadLocal<Object> currentProxy ThreadLocal holder for AOP proxy associated with this thread.
Will contain
| |
| AopContext | back to summary |
|---|---|
| private AopContext() | |
| currentProxy | back to summary |
|---|---|
| public static Object currentProxy() throws IllegalStateException 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.
| |
| setCurrentProxy | back to summary |
|---|---|
| pack-priv static Object setCurrentProxy(Object proxy) Make the given proxy available via the Note that the caller should be careful to keep the old value as appropriate.
| |