1 Reply Latest reply on Aug 26, 2007 5:20 PM by Krisha Verumuri

    Client-interceptor

    Krisha Verumuri Newbie

      Version: jboss-4.2.0 (default config), EJB


      I have a requirement of sending in an extra-arg from the client to the server for every remote call, and the Interceptor on the server would validate this extra arg.

      I was able to successfully add the Interceptor on the server by adding to the ejb-jar.xml

      <ejb-jar>
      <assembly-descriptor>
      <interceptor-binding>
      <ejb-name>*</ejb-name>
      <interceptor-class>
      com.acme.MyServerInterceptor
      </interceptor-class>
      </interceptor-binding>
      </assembly-descriptor>
      </ejb-jar>



      The client side interceptor I have added to the StandardJboss.xml, to the stateless-rmi-invoker proxy-binding, does not get invoked.

      The only Interceptors I could see on the client are these

      org.jboss.ejb3.remoting.IsLocalInterceptor
      org.jboss.aspects.security.SecurityClientInterceptor
      org.jboss.aspects.tx.ClientTxPropagationInterceptor
      org.jboss.aspects.remoting.InvokeRemoteInterceptor


      These interceptors are getting picked up from StatelessSessionClientInterceptors entry of server\default\deploy\ejb3-interceptors-aop.xml

      How do I add the client-interceptor, to add this extra arg to the contextData and beable to read this on the server.

        • 1. Re: Client-interceptor
          Krisha Verumuri Newbie

          I could get it to work by making these changes.

          Is this the right way??


          //ClientInterceptor

          package com.acme.ejb;

          import java.io.Serializable;

          import org.jboss.aop.advice.Interceptor;
          import org.jboss.aop.joinpoint.Invocation;
          import org.jboss.aop.util.PayloadKey;

          public class AcmeOPClientInterceptor implements Interceptor, Serializable
          {
          public String getName()
          {
          return "AcmeClientInterceptor";
          }

          public Object invoke(Invocation invocation) throws Throwable
          {
          invocation.getMetaData().addMetaData("TEST", PayloadKey.MARSHALLED, "IDDD");
          return invocation.invokeNext();
          }
          }

          //ServerInterceptor

          package com.acme.ejb;

          import java.io.Serializable;
          import java.util.Date;

          import org.jboss.aop.advice.Interceptor;
          import org.jboss.aop.joinpoint.Invocation;
          import org.jboss.aop.metadata.SimpleMetaData;
          import org.jboss.aop.util.PayloadKey;

          public class AcmeServerInterceptor implements Interceptor, Serializable
          {
          public String getName()
          {
          return "AcmeServerInterceptor";
          }

          public Object invoke(Invocation invocation) throws Throwable
          {
          SimpleMetaData sm = invocation.getMetaData();
          Object o = invocation.getMetaData("TEST",PayloadKey.MARSHALLED));
          return invocation.invokeNext();
          }
          }


          Add client interceptor to StatelessSessionClientInterceptors to ejb3-interceptors-aop.xml



          <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
          <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
          <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
          <interceptor-ref name="com.acme.ejb.AcmeClientInterceptor"/>
          <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>


          for the domain name "Stateless Bean" add the interceptor

          com.acme.ejb.AcmeServerInterceptor

          to the bind pointcut="execution(public * *->*(..))"