Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.aop.framework
Class AopContext

    java.lang.Object
      org.springframework.aop.framework.AopContext

    public abstract class AopContext

extends Object

Class containing static methods used to obtain information about the current AOP invocation.

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.

Since:
  13.03.2003
Author:
  Rod Johnson, Juergen Hoeller

Constructor Summary
`AopContext()`

Method Summary
`static Object` | `currentProxy()` Try to return the current AOP proxy.
`static Object` | `setCurrentProxy(Object proxy)` Make the given proxy available via the `currentProxy()` method.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AopContext

    public AopContext()

Method Detail

### currentProxy

    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.

  Returns:
    Object the current AOP proxy (never returns `null`)
  Throws:
    `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

    public static Object setCurrentProxy(Object proxy)

  Make the given proxy available via the `currentProxy()` method.

  Note that the caller should be careful to keep the old value as appropriate.

  Parameters:
    `proxy` - the proxy to expose (or `null` to reset it)
  Returns:
    the old proxy, which may be `null` if none was bound
  See Also:
    `currentProxy()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2007 The Spring Framework.