|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mockejb.interceptor.InvocationContext
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.
Constructor Summary | |
InvocationContext(java.util.List interceptorList,
java.lang.Object proxyObj,
java.lang.reflect.Method proxyMethod,
java.lang.Object targetObj,
java.lang.reflect.Method targetMethod,
java.lang.Object[] paramVals)
Creates a new instance of the InvocationContext. |
|
InvocationContext(java.util.List interceptorList,
java.lang.Object proxyObj,
java.lang.reflect.Method proxyMethod,
java.lang.Object targetObj,
java.lang.reflect.Method targetMethod,
java.lang.Object[] paramVals,
java.util.Map contextProperties)
Creates a new instance of the InvocationContext. |
Method Summary | |
void |
clear()
Clears the context properties and resets the interceptor iterator. |
java.lang.reflect.Method |
getInterceptedMethod()
Deprecated. Use getProxyMethod instead |
java.lang.Object |
getInterceptedObject()
Deprecated. Use getProxyObject instead |
java.util.ListIterator |
getInterceptorIterator()
Returns the iterator currently in use to traverse the interceptor list. |
java.util.List |
getInterceptorList()
|
java.lang.Object |
getOptionalPropertyValue(java.lang.String key)
Returns the context property value associated with the provided key or null if the key is not found |
java.lang.Object[] |
getParamVals()
|
java.lang.Object |
getPropertyValue(java.lang.String key)
Returns the custome context's property value associated with the provided key or throws IllegalStateException if the key is not found |
java.lang.reflect.Method |
getProxyMethod()
Returns the proxy method, the method that was called on the proxy. |
java.lang.Object |
getProxyObject()
Returns the proxy object. |
java.lang.Object |
getReturnObject()
Returns the return value of the invocation. |
java.lang.reflect.Method |
getTargetMethod()
Returns the target method of the invocation. |
java.lang.Object |
getTargetObject()
Returns the target object of the invocation. |
java.lang.Object |
getThrownThrowable()
Returns the throwable thrown by the target method or by one of the interceptors. |
protected java.lang.Object |
invokeMethod(java.lang.Object targetObj,
java.lang.reflect.Method method,
java.lang.Object[] paramVals)
Calls the object's method using reflection. |
void |
proceed()
Calls the next interceptor in the list. |
void |
reset()
Deprecated. |
void |
setContext(java.lang.String key,
java.lang.Object data)
Adds the invocation context property. |
void |
setInterceptorList(java.util.List interceptorList)
Sets the list of interceptors |
void |
setReturnObject(java.lang.Object returnObject)
Sets the return value of the invocation. |
void |
setThrownThrowable(java.lang.Throwable throwable)
Sets the throwable thrown by the invoked method |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public InvocationContext(java.util.List interceptorList, java.lang.Object proxyObj, java.lang.reflect.Method proxyMethod, java.lang.Object targetObj, java.lang.reflect.Method targetMethod, java.lang.Object[] paramVals)
interceptorList
- interceptors that will be invoked before the target methodproxyObj
- object that was intercepted,
most likely it is the dynamic proxy object. Can be null.proxyMethod
- method invoked on the proxy. The declaring class of the method is the
interface's class.targetObj
- target object being called.targetMethod
- method being called.paramVals
- parameter valuespublic InvocationContext(java.util.List interceptorList, java.lang.Object proxyObj, java.lang.reflect.Method proxyMethod, java.lang.Object targetObj, java.lang.reflect.Method targetMethod, java.lang.Object[] paramVals, java.util.Map contextProperties)
interceptorList
- interceptors that will be invoked before the target methodproxyObj
- object that was intercepted,
most likely it is the dynamic proxy object. Can be null if the object is not known.proxyMethod
- method invoked on the proxy. The declaring class of the method is the
interface's class.targetObj
- target object being called.targetMethod
- method being called.paramVals
- parameter valuescontextProperties
- any additional context info for the interceptorsMethod Detail |
public void setInterceptorList(java.util.List interceptorList)
interceptorList
- list to setpublic java.util.List getInterceptorList()
public java.util.ListIterator getInterceptorIterator()
public void reset()
public void clear()
public void proceed() throws java.lang.Exception
java.lang.Exception
public java.lang.Object getProxyObject()
public java.lang.Object getTargetObject()
public java.lang.reflect.Method getTargetMethod()
public java.lang.Object getInterceptedObject()
public java.lang.reflect.Method getInterceptedMethod()
public java.lang.reflect.Method getProxyMethod()
public java.lang.Object[] getParamVals()
public java.lang.Object getReturnObject()
public void setReturnObject(java.lang.Object returnObject)
returnObject
- return object to setpublic java.lang.Object getThrownThrowable()
public void setThrownThrowable(java.lang.Throwable throwable)
throwable
- public void setContext(java.lang.String key, java.lang.Object data)
key
- key for this contextProperties's datadata
- contextProperties datapublic java.lang.Object getPropertyValue(java.lang.String key)
key
- contextProperties key
public java.lang.Object getOptionalPropertyValue(java.lang.String key)
key
- contextProperties key
protected java.lang.Object invokeMethod(java.lang.Object targetObj, java.lang.reflect.Method method, java.lang.Object[] paramVals) throws java.lang.Throwable
InvocationTargetException
out of the
stack in case of exception. This allows exception handlers not to deal with
reflection-specific exceptions.
targetObj
- target object being calledmethod
- method being calledparamVals
- parameter values
java.lang.Throwable
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |