4 Replies Latest reply on Sep 11, 2009 7:16 AM by tombol

    Pluggable Interceptors

    patrickdalla

      Is it possible to make pluggable interceptors?

        • 1. Re: Pluggable Interceptors
          patrickdalla

          i. e. hot deployable interceptors

          • 2. Re: Pluggable Interceptors

            It is possible in 2.2 and 2.4 to manipulate an interceptor stack at runtime using JMX :

            http://fisheye.jboss.org/viewrep/~raw,r=1.10/JBoss/jboss-portal/server/src/main/org/jboss/portal/server/impl/invocation/JBossInterceptorStack.java

            however that will probably not work in 3.x serie when we refactor around the microcontainer.

            • 3. Re: Pluggable Interceptors
              legolas

              In addition to Julian's answer I can give a usage example.
              This is a snippet of an interceptor that injects itself into the server interceptor chain:

              /**
               * Injects the LocaleInterceptor into the Server InterceptorStack.
               * @throws Exception
               */
              protected void startService() throws Exception {
              
               ObjectName name = getInterceptorStack();
               Object [] params = new Object[] {this.serviceName};
               String [] signature = new String [] {ObjectName.class.getName()};
              
               // Add the interceptor
               server.invoke(name, "addInterceptor", params, signature);
              
               // Rebuild the interceptor chain
               server.invoke(name, "rebuild", new Object[]{}, new String[]{});
              }
              
              /**
               * Removes the LocaleInterceptor from the Server InterceptorStack.
               * @throws Exception
               */
              protected void stopService() throws Exception {
              
               ObjectName name = getInterceptorStack();
               Object [] params = new Object[] {this.serviceName};
               String [] signature = new String [] {ObjectName.class.getName()};
              
               // Remove the interceptor
               server.invoke(name, "removeInterceptor", params, signature);
              
               // Rebuild the interceptor chain
               server.invoke(name, "rebuild", new Object[]{}, new String[]{});
              }
              


              Cheers,
              Marcel


              • 4. Re: Pluggable Interceptors

                Hello,

                My name is tom. I have some questions for you.I'm developing an interceptor to read the HttpSession for an attribute (e.g. thePortalLanguage )
                from a portlet that changes the portal's language.

                But when i access this attribute within the invoke method it is null. I observed that the session is accessed firstly from the interceptor an after from my servlet that sets the attribute. Why is that?

                Secondly i would like to ask you about the snippet that injects itself. Obviously these are two extra methods inside the interceptor, right?

                I cant figure out the methods getInterceptorStack() and your server variable, is it invocation.getRequest().getServer() ??

                And what about serviceName variable?

                Thank you!