| java.lang.Object org.mockejb.interceptor.InvocationContext
InvocationContext | public class InvocationContext (Code) | | Performs the invocation of interceptors in their order in the
interceptor list.
Each interceptor is called in turn until we get to the target object.
At this point, the target object's method is called using reflection.
Also keeps the invocation's custom context (properties).
To be thread safe, clients should create a new object of this
class for each method call.
author: Alexander Ananiev |
Constructor Summary | |
public | InvocationContext(List interceptorList, Object proxyObj, Method proxyMethod, Object targetObj, Method targetMethod, Object[] paramVals) Creates a new instance of the InvocationContext.
Parameters: interceptorList - interceptors that will be invoked before the target method Parameters: proxyObj - object that was intercepted, most likely it is the dynamic proxy object. | public | InvocationContext(List interceptorList, Object proxyObj, Method proxyMethod, Object targetObj, Method targetMethod, Object[] paramVals, Map contextProperties) Creates a new instance of the InvocationContext.
Parameters: interceptorList - interceptors that will be invoked before the target method Parameters: proxyObj - object that was intercepted, most likely it is the dynamic proxy object. |
InvocationContext | public InvocationContext(List interceptorList, Object proxyObj, Method proxyMethod, Object targetObj, Method targetMethod, Object[] paramVals)(Code) | | Creates a new instance of the InvocationContext.
Parameters: interceptorList - interceptors that will be invoked before the target method Parameters: proxyObj - object that was intercepted, most likely it is the dynamic proxy object. Can be null. Parameters: proxyMethod - method invoked on the proxy. The declaring class of the method is the interface's class. Parameters: targetObj - target object being called. Parameters: targetMethod - method being called. Parameters: paramVals - parameter values |
InvocationContext | public InvocationContext(List interceptorList, Object proxyObj, Method proxyMethod, Object targetObj, Method targetMethod, Object[] paramVals, Map contextProperties)(Code) | | Creates a new instance of the InvocationContext.
Parameters: interceptorList - interceptors that will be invoked before the target method Parameters: proxyObj - object that was intercepted, most likely it is the dynamic proxy object. Can be null if the object is not known. Parameters: proxyMethod - method invoked on the proxy. The declaring class of the method is the interface's class. Parameters: targetObj - target object being called. Parameters: targetMethod - method being called. Parameters: paramVals - parameter values Parameters: contextProperties - any additional context info for the interceptors |
clear | public void clear()(Code) | | Clears the context properties and resets the interceptor iterator.
|
getInterceptedMethod | public Method getInterceptedMethod()(Code) | | |
getInterceptedObject | public Object getInterceptedObject()(Code) | | proxy object |
getInterceptorIterator | public ListIterator getInterceptorIterator()(Code) | | Returns the iterator currently in use to traverse the
interceptor list. Clients can use the returned iterator
to find out their place in the call chain.
list iterator |
getInterceptorList | public List getInterceptorList()(Code) | | |
getOptionalPropertyValue | public Object getOptionalPropertyValue(String key)(Code) | | Returns the context property value associated with the provided key
or null if the key is not found
Parameters: key - contextProperties key contextProperties data |
getPropertyValue | public Object getPropertyValue(String key)(Code) | | Returns the custome context's property value associated with the provided key
or throws IllegalStateException if the key is not found
Parameters: key - contextProperties key contextProperties data |
getProxyMethod | public Method getProxyMethod()(Code) | | Returns the proxy method, the method that was called on the proxy.
For example, "find" method
of the Entity business interface is the proxy method,
and "ejbFind" method of the entity implementation class
is the target method.
proxy method |
getProxyObject | public Object getProxyObject()(Code) | | Returns the proxy object. This is a dynamic proxy
object implementing an interface or a CGLIB-enhanced class
intercepted object |
getReturnObject | public Object getReturnObject()(Code) | | Returns the return value of the invocation. Normally,
this is a return value of the target method, however interceptors
can change it.
Object or null if the method has void type or if the method threw exception |
getTargetMethod | public Method getTargetMethod()(Code) | | Returns the target method of the invocation.
This is the target method being called in response to the
call to the proxy's method. For example, "find" method
of the Entity business interface is the intercepted method,
whereas "ejbFind" method of the entity implementation class
is the target method.
method |
getTargetObject | public Object getTargetObject()(Code) | | Returns the target object of the invocation.
This is the target object being called in response to the
call of the proxy (interface).
target object |
getThrownThrowable | public Object getThrownThrowable()(Code) | | Returns the throwable thrown by the target method or by one of the
interceptors.
throwable or null if no exceptions were thrown during the invocation |
invokeMethod | protected Object invokeMethod(Object targetObj, Method method, Object[] paramVals) throws Throwable(Code) | | Calls the object's method using reflection.
This method takes InvocationTargetException out of the
stack in case of exception. This allows exception handlers not to deal with
reflection-specific exceptions.
Parameters: targetObj - target object being called Parameters: method - method being called Parameters: paramVals - parameter values value returned by the given method |
proceed | public void proceed() throws Exception(Code) | | Calls the next interceptor in the list. If this is the end of the list,
calls the given method of the target object using reflection if the target
object is not null.
"proceed" name is consistent with the "proceed" keyword used by AspectJ for "around"
advices.
Use "getReturnObject" to get the return value for this invocation.
|
reset | public void reset()(Code) | | Resets the interceptor iterator.
|
setContext | public void setContext(String key, Object data)(Code) | | Adds the invocation context property.
Context property is a piece of data made available
to all interceptors. Interceptors can add/modify the context properties during the call.
Parameters: key - key for this contextProperties's data Parameters: data - contextProperties data |
setInterceptorList | public void setInterceptorList(List interceptorList)(Code) | | Sets the list of interceptors
Parameters: interceptorList - list to set |
setReturnObject | public void setReturnObject(Object returnObject)(Code) | | Sets the return value of the invocation. This allows interceptors
to change the current return value.
Parameters: returnObject - return object to set |
setThrownThrowable | public void setThrownThrowable(Throwable throwable)(Code) | | Sets the throwable thrown by the invoked method
Parameters: throwable - |
|
|