Interface InvocationContext


public interface InvocationContext
Contextual information about a method invocation, along with methods to alter the invocation process in various ways.
  • Method Details

    • getTarget

      Object getTarget()
      Get the target instance for this invocation.
      Returns:
      the target instance
    • getMethod

      Method getMethod()
      Get the invoked method for this invocation. If the invoked method is an @AroundInvoke or @AroundTimeout interceptor method, the method of the target class is returned. For lifecycle callback interceptors (such as
      invalid reference
      @PostConstruct
      or
      invalid reference
      @PreDestroy
      ), null is returned.
      Returns:
      the invoked method, or null if none applies to the current invocation context
    • getConstructor

      Constructor<?> getConstructor()
      Returns the constructor of the target class for which the interceptor was invoked. For AroundConstruct interceptor, the constructor of the target class is returned. For all other interceptors, a null value is returned.
      Returns:
      the constructor, or a null value
    • getParameters

      Object[] getParameters() throws IllegalStateException
      Get the parameters of the method invocation (for method interceptors).
      Returns:
      the invoked method parameters
      Throws:
      IllegalStateException - if the current invocation context refers to a lifecycle callback invocation
    • setParameters

      void setParameters(Object[] params) throws IllegalStateException, IllegalArgumentException
      Replace the parameters of the method invocation.
      Parameters:
      params - the new parameter values to use for the current invocation
      Throws:
      IllegalStateException - if the current invocation context refers to a lifecycle callback invocation
      IllegalArgumentException - if the types or quantity of the method parameters does not match the method declaration
    • getContextData

      Map<String,Object> getContextData()
      Returns the context data associated with this invocation or lifecycle callback.

      If the current context is an invocation on a web service endpoint, the map returned will be the JAX-WS MessageContext. If there is no context data, an empty Map object will be returned. Normally, information stored in this map is available to subsequent interceptors in an interceptor chain, so this mechanism may be used to pass information from one interceptor to the next.

      Returns:
      the context map
    • getTimer

      Object getTimer()
      Get the timer associated with an @AroundTimeout interceptor method. When intercepting an EJB component timeout, the returned type is
      invalid reference
      javax.ejb.Timer
      .
      Returns:
      the timer object, or null if the invocation did not apply to a timeout method.
    • proceed

      Object proceed() throws Exception
      Proceed with the next stage of invocation processing. Calling this method may cause another interceptor to be invoked, or it may cause the final target object to be invoked. The return value of this method is the result of the subsequent invocation processing, or of the invocation itself. Normally an interceptor will return this value to its caller; however, it is also possible to return a different value.

      If the intercepted method's return type is void, or if this is a lifecycle method interceptor, then null is returned from this method, and should be returned by the interceptor as well.

      Returns:
      the result of subsequent interceptor method processing
      Throws:
      Exception - if an exception is thrown by subsequent processing