3 Replies Latest reply on Oct 12, 2006 12:12 PM by tterm

    EJB3 container configuration and interceptors

    fakeer

      how can i add custom interceptors in ejb3??

      with ejb2 i have been using the standardjboss.xml to insert my own interceptors into the standard container interceptor stack (see ActivityInterceptor below). i also used a client side invocation interceptor to make some client information ride with the invocation payload (further below)

      with my beans no on ejb3 the stadardjboss.xml configuration is just ignored? is there a new container configuration file for ejb3? i'm cluless

      server side interceptor

       <container-configuration>
       <container-name>Standard Stateless SessionBean</container-name>
       <call-logging>false</call-logging>
       <invoker-proxy-binding-name>stateless-rmi-invoker</invoker-proxy-binding-name>
       <container-interceptors>
       <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
       <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
       <interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
       <!-- CMT -->
       <interceptor>com.test.server.ejb.ActivityInterceptor</interceptor>
       <interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
       <interceptor transaction="Container">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>
       <interceptor transaction="Container" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
       <interceptor transaction="Container">org.jboss.webservice.server.ServiceEndpointInterceptor</interceptor>
       <interceptor transaction="Container">org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor</interceptor>
       <!-- BMT -->
       <interceptor transaction="Bean">org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor</interceptor>
       <interceptor transaction="Bean">org.jboss.ejb.plugins.TxInterceptorBMT</interceptor>
       <interceptor transaction="Bean">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>
       <interceptor transaction="Bean" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
       <interceptor transaction="Bean">org.jboss.webservice.server.ServiceEndpointInterceptor</interceptor>
       <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>
       </container-interceptors>
       <instance-pool>org.jboss.ejb.plugins.StatelessSessionInstancePool</instance-pool>
       <instance-cache></instance-cache>
       <persistence-manager></persistence-manager>
       <container-pool-conf>
       <MaximumSize>100</MaximumSize>
       </container-pool-conf>
       </container-configuration>
      


      client side interceptor
       <invoker-proxy-binding>
       <name>stateless-rmi-invoker</name>
       <invoker-mbean>jboss:service=invoker,type=https</invoker-mbean>
       <proxy-factory>org.jboss.proxy.ejb.ProxyFactory</proxy-factory>
       <proxy-factory-config>
       <client-interceptors>
       <home>
       <interceptor>com.test.client.ActivityClientInterceptor</interceptor>
       <interceptor>org.jboss.proxy.ejb.HomeInterceptor</interceptor>
       <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
       <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
       <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
       <interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor>
       </home>
       <bean>
       <interceptor>com.test.client.ActivityClientInterceptor</interceptor>
       <interceptor>org.jboss.proxy.ejb.StatelessSessionInterceptor</interceptor>
       <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
       <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
       <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
       <interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor>
       </bean>
       </client-interceptors>
       </proxy-factory-config>
       </invoker-proxy-binding>
      


      thnx

        • 1. Re: EJB3 container configuration and interceptors
          tterm

          You can add your own interceptors in ejb3-interceptors-aop.xml for example. I guess you mean not the interceptors from the spec because those interceptors are jbossAOP interceptors.

          You can create your own interceptor stacks their!

          Regards
          Thomas Termin

          • 2. Re: EJB3 container configuration and interceptors
            fakeer

            thanks thomas,

            i tried to insert my interceptor to one of the existing stacks in ejb3-interceptors-aop.xml but that started throwing NullPointer exceptions.

            what i want to do is intercept ALL stateless bean calls on the client and the server. i used the existing stack called StatelessSessionClientInterceptor and Stateless Bean but that as i said ran into exceptions. i'm not sure if the order of interception matters.

            did your work involve intercepting all beans or one particular bean calls.

            thanks
            F

            • 3. Re: EJB3 container configuration and interceptors
              tterm

              I did it for all session beans. But you can also have a stack for a specific bean.

              I don't know where your problem comes from because I have not enough information.

              Did you deploy your interceptor classes correctly?

              I have a simple interceptor test on http://www.strace.org/~tterm/jboss-testcase.zip

              You should comment out the metadata stuff their because it will throw an exception but without it should work fine.

              Regards,
              Thomas