2 Replies Latest reply on May 2, 2013 8:26 AM by Wolf-Dieter Fink

    EJBClientContext registerInterceptor not working

    Julien Boz Newbie

      Bonjour à tous !

       

      I want to inject some metad data  into EJBContext like this : https://community.jboss.org/message/757523?tstart=0&_sscc=t

      But my client interceptor is never invoked.

       

      My code :

       

      1) EJBClientInterceptor

      public class RegisterUserInterceptor implements EJBClientInterceptor, Serializable {
                private static final long serialVersionUID = 1L;
      
      
                @Override
                public void handleInvocation(final EJBClientInvocationContext context) throws Exception {
                          // store user in context
                          if (!context.getContextData().containsKey("user")) {
                                    context.getContextData().put("user", "hello");
                          }
                          context.sendRequest();
                }
      
      
                @Override
                public Object handleInvocationResult(final EJBClientInvocationContext context) throws Exception {
                          return context.getResult();
                }
      }
      

       

      2) registerInterceptor

       

      version 1 not work :

      @WebListener
      public class StartupWebListener implements ServletContextListener {
      
      
                @Override
                public void contextInitialized(ServletContextEvent sce) {
                          // on startup
                          EJBClientContext.getCurrent().registerInterceptor(0, new RegisterUserInterceptor());
                }
      
      
                @Override
                public void contextDestroyed(ServletContextEvent sce) {
                          // on shutdown
                }
      }
      

       

      version 2, not work too :

      in file META-INF/services/org.jboss.ejb.client.EJBClientInterceptor

      ch.mobi.posi.presentation.interceptors.RegisterUserInterceptor
      

       

       

      The web listener is invoke, and my client interceptor is registered, but when i invoke my ejb, the class RegisterUserInterceptor is not invoked

       

      @Named
      @RequestScoped
      public class MyWebController implements Serializable {
                private static final long serialVersionUID = 1L;
      
                @Inject private MyEJBFacade facade;
      
                public void search(final AjaxBehaviorEvent event) {
                              // call facade, client interceptor must add meta data into call context
      
                               facade.callMethod();
                }
      }
      

       

      PS : I use jboss 7.0.1.Final and jboss-ejb-client-1.0.16.Final

       

       

      Thanks for your help.