org.mockejb.interceptor
Class InterceptorInvoker

java.lang.Object
  extended byorg.mockejb.interceptor.InterceptorInvoker
All Implemented Interfaces:
java.io.Serializable

public class InterceptorInvoker
extends java.lang.Object
implements java.io.Serializable

Requests the interceptors from the AspectSystem and initiates the call to the interceptor chain. Allows to setup the custom context (properties) that is passed down to interceptors. Clients can reuse the same object of this class for all method calls (provided that that the custom context is the same).

Author:
Alexander Ananiev
See Also:
Serialized Form

Nested Class Summary
static class InterceptorInvoker.CglibMethodInvoker
          Calls the object's method using Cglib.
 
Constructor Summary
InterceptorInvoker()
           
 
Method Summary
 java.lang.Object getContext(java.lang.String key)
          Returns the context associated with the provided key or null if the key is not found.
 java.lang.Object invoke(java.lang.Object proxyObj, java.lang.reflect.Method proxyMethod, java.lang.Object targetObj, java.lang.reflect.Method targetMethod, java.lang.Object[] paramVals)
          Calls AspectSystem to find the interceptors for the given invokedMethod and targetMethod, creates the invocationContext and proceeds to calling the first interceptor.
 void setContext(java.lang.String key, java.lang.Object data)
          Sets the custom context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterceptorInvoker

public InterceptorInvoker()
Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxyObj,
                               java.lang.reflect.Method proxyMethod,
                               java.lang.Object targetObj,
                               java.lang.reflect.Method targetMethod,
                               java.lang.Object[] paramVals)
                        throws java.lang.Exception
Calls AspectSystem to find the interceptors for the given invokedMethod and targetMethod, creates the invocationContext and proceeds to calling the first interceptor.

Parameters:
proxyObj - dynamic proxy or the object enhanced by CGLIB.
proxyMethod - method invoked by the client on the proxy. Normally, this is an interface method (the declaring class is the interface).
targetObj - object to call, e.g., EJB implementation object
targetMethod - method to call on the target object, e.g., method of the EJB implementation clsess
paramVals - method parameters
Returns:
return value
Throws:
java.lang.Exception

setContext

public void setContext(java.lang.String key,
                       java.lang.Object data)
Sets the custom context. Custome context is the is a piece of data made available to all interceptors

Parameters:
key - key for this context's data
data - context data

getContext

public java.lang.Object getContext(java.lang.String key)
Returns the context associated with the provided key or null if the key is not found.

Parameters:
key - context key
Returns:
context data