javax.interceptor

Interface InvocationContext


  • 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;
           }
    
        }
     
     
    Since:
    Interceptors 1.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      Constructor<?> getConstructor()
      Returns the constructor of the target class for which the interceptor was invoked.
      Map<String,Object> getContextData()
      Enables an interceptor to retrieve or update the data associated with the invocation by another interceptor, business method,and/or webservices context in the invocation chain.
      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 or constructor 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 or constructor of the target class.

      Eerste pagina van API Java Inhoudsopgave Haut

    • Method Detail

      • getTarget

        Object getTarget()
        Returns the target instance. For the AroundConstruct lifecycle callback interceptor method, the getTarget returns null if called before the proceed() method.
        Returns:
        the target instance
      • getTimer

        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. For example, when associated with an EJB component timeout, this method returns Timer
        Returns:
        the timer object or a null value
        Since:
        Interceptors 1.1
      • getMethod

        Method getMethod()
        Returns the method of the target class for which the interceptor was invoked. In a lifecycle callback interceptor for which there is no corresponding lifecycle callback method on the target class or in the AroundConstruct lifecycle callback interceptor method, getMethod returns null.
        Returns:
        the method, or a null value
      • 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()
        Returns the parameter values that will be passed to the method or constructor of the target class. If setParameters(java.lang.Object[]) has been called, getParameters returns the values to which the parameters have been set.
        Returns:
        the parameter values, as an array
        Throws:
        IllegalStateException - if invoked within a lifecycle callback method which is not an AroundConstruct callback.
      • setParameters

        void setParameters(Object[] params)
        Sets the parameter values that will be passed to the method or constructor of the target class.
        Parameters:
        params - the parameter values, as an array
        Throws:
        IllegalStateException - if invoked within a lifecycle callback method which is not an AroundConstruct callback.
        IllegalArgumentException - if the types of the given parameter values do not match the types of the method or constructor parameters, or if the number of parameters supplied does not equal the number of method or constructor parameters (if the last parameter is a vararg parameter of type T, it is considered to be equivalent to a parameter of type T[]).
      • getContextData

        Map<String,Object> getContextData()
        Enables an interceptor to retrieve or update the data associated with the invocation by another interceptor, business method,and/or webservices context in the invocation chain. If interceptors are invoked as a result of the invocation on a web service endpoint, the returned value will be an instance of javax.xml.rpc.handler.MessageContext
        Returns:
        the context data associated with this invocation or lifecycle callback. If there is no context data, an empty Map<String,Object> object will be returned.
      • proceed

        Object proceed()
                throws Exception
        Proceed to the next interceptor in the interceptor chain. For the around-invoke or around-timeout interceptor methods, the invocation of the last interceptor method in the chain causes the invocation of the target class method. For AroundConstruct lifecycle callback interceptor methods, the invocation of the last interceptor method in the chain causes the target instance to be created. For all other lifecycle callback interceptor methods, if there is no callback method defined on the target class, the invocation of proceed in the last interceptor method in the chain is a no-op

        Return the result of the next method invoked, or a null value if the method has return type void.

        Returns:
        the return value of the next method in the chain
        Throws:
        Exception

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/interceptor/InvocationContext.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com, InvocationContext (Java(TM) EE 7 Specification APIs)

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.