ix.util.context
Class ContextLockingProxy.Handler
java.lang.Object
ix.util.context.ContextLockingProxy.Handler
- All Implemented Interfaces:
- java.lang.reflect.InvocationHandler
- Enclosing class:
- ContextLockingProxy
public static class ContextLockingProxy.Handler
- extends java.lang.Object
- implements java.lang.reflect.InvocationHandler
The invocation-handler for a context-locking proxy.
When the handler is created, it grabs the current context
which is assumed to be the right context for the first method
call handled by the proxy. That's saved as the "instance context".
Then, whenever the handler is given a method to call, it
does the following while synchronized on the current
ContextHolder
:
- Remember the current context.
- Set the current context to the saved instance context.
- Invoke the method, and then in a "finally" clause:
- Record as the instance context whatever context is current
now that the method's returned, and
- restore the context remembered earlier.
Method Summary |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
instance
protected java.lang.Object instance
instanceContext
protected Context instanceContext
ContextLockingProxy.Handler
public ContextLockingProxy.Handler(java.lang.Object instance)
invoke
public java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
- Specified by:
invoke
in interface java.lang.reflect.InvocationHandler
- Throws:
java.lang.Throwable