public interface InvocationContext
Exposes context information about the intercepted invocation and operations that enable interceptor methods to control the behavior of the invocation chain.
@AroundInvoke public Object logInvocation(InvocationContext ctx) throws Exception { String class = ctx.getMethod().getDeclaringClass().getName(); String method = ctx.getMethod().getName(); Logger.global.entering(class, method, ctx.getParameters()); try { Object result = ctx.proceed(); Logger.global.exiting(class, method, result); return result; } catch (Exception e) { Logger.global.throwing(class, method, e); throw e; } }
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
getContextData()
Returns the context data associated with this invocation or
lifecycle callback.
|
Method |
getMethod()
Returns the method of the target class for which the interceptor
was invoked.
|
Object[] |
getParameters()
Returns the parameter values that will be passed to the method of
the target class.
|
Object |
getTarget()
Returns the target instance.
|
Object |
getTimer()
Returns the timer object associated with a timeout
method invocation on the target class, or a null value for method
and lifecycle callback interceptor methods.
|
Object |
proceed()
Proceed to the next interceptor in the interceptor chain.
|
void |
setParameters(Object[] params)
Sets the parameter values that will be passed to the method of the
target class.
|
Object getTarget()
Object getTimer()
Timer
Method getMethod()
Object[] getParameters()
setParameters()
has been called,
getParameters()
returns the values to which the parameters
have been set.IllegalStateException
- if invoked within
a lifecycle callback method.void setParameters(Object[] params)
params
- the parameter values, as an arrayIllegalStateException
- if invoked within
a lifecycle callback method.IllegalArgumentException
- if the types of the
given parameter values do not match the types of the method parameters,
or if the number of parameters supplied does not equal the number of
method parameters.Map<String,Object> getContextData()
Map<String,Object>
object will be returned.Copyright © 1996-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.