1 Reply Latest reply on Jun 4, 2010 3:23 AM by Carlo de Wolf

    Obtaining the Container in an Interceptor

    Andrew Rubinger Master

      Currently we've no way of injecting the EJB Container into an Interceptor instance.

       

      Instead, how do we feel about setting Invocation metadata to add the container under some known key in before SessionSpecContainer.invoke() calls invocation.invokeNext?  Then interceptors could grab the container via the metadata.

       

      The other way we do this now is:

       

      ((ManagedObjectAdvisor) invocation.getAdvisor()).getContainer()

       

      ...which is good for unit tests, but in a real environment it's:

       

      ((ManagedObjectAdvisor) invocation.getAdvisor()).getContainer().getEJBContainer();

       

      S,

      ALR

        • 1. Re: Obtaining the Container in an Interceptor
          Carlo de Wolf Master

          What exactly do you need from the container?

           

          The code you quote must never be used from an interceptor it's either:

          AbstractContainer.getContainer(invocation.getAdvisor());
          

          or

          EJBContainer.getContainer(invocation.getAdvisor());
          

          depending on which container you want to talk (the low-level one or the real one).

           

          Alternatively and I think the better approach, because we should be moving away from AOP and onto the real interceptor API.

          InvocationContext context = CurrentInvocationContext.get();
          AsyncBeanManager manager = (AsyncBeanManager) context.getBeanManager();
          

          (needs work because of the cast.)

          boolean doAsync = manager.isAsync(context.getMethod());