4 Replies Latest reply on Aug 13, 2003 6:41 PM by adrian.brock

    Howto get the EJB-Name by an Interceptor

    kristoeffy

      Hi! I've implemented an MBean that buffers an flushes TimeStamping-Information, which are given by Interceptors.
      The information is flushed to a DB, and of course I want to safe _which_ EJB was called with which Method and which arguments.

      I'm looking at it from the Interceptor-perspective:

      The Method-name and given arguments are easy...
      But how do I now which EJB is called.
      I can only get the "Object objName" by "mi.getObjectName()" which is an Integer (e.g. -2051066433).
      There must be a registry that does the mapping. Where? Which?
      How do I get the reference?

      I know that the Container (e.g. StatelessSessionContainer) builds itself a "beanMap" which he asks.
      But it does not export any functionality which I could use, does it?

      I just want to get something like the corresponding Class-Obj. for the EJB so I can store "de.uni-erlangen.ejb.myGreatBean" in my DB-Tuple.

      Please answer me anybody out there (perhaps with a few lines of code).


      P.S. During a invokeHome(mi)-call (for example by a create()-method) there is even no EnterpriseContext given. So how the could I get my information then!?!

        • 1. Re: Howto get the EJB-Name by an Interceptor
          kristoeffy

          Okay, with:
          EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext();
          Container container = ctx.getContainer();
          Class beanClass = container.getBeanClass();
          I do come to a result.

          But there is still the basic problem that I have NOT the EnterpriseContext during create()-calls. But also in that case the EJB must be known anyhow. So my solution lacks generality and therefore seems to be a "hack-around".

          • 2. Re: Howto get the EJB-Name by an Interceptor

            Each interceptor has a setContainer() method.
            From that you can get the BeanMetaData.

            Regards,
            Adrian

            • 3. Re: Howto get the EJB-Name by an Interceptor
              kristoeffy

              Ahh, I missed this!
              Nice that the answer comes so fast.
              Thank you very much.
              Now the server-side works (org.jboss.ejb.Interceptor)!

              But on Client side I have to extend org.jboss.proxy.Interceptor, haven't I?
              It hasn't the setContainer().
              So we are back to the problem that I still don't know
              how the basic information "Which Bean is meant" is passed.
              In my opinion this is independant to whether I have access to the Container or not.

              Glad, if someone could help and explain.

              • 4. Re: Howto get the EJB-Name by an Interceptor

                On the client side you have the invocation has
                an InvocationContext. One of the keys for getValue()
                is InvocationKey.JNDI_NAME

                Regards,
                Adrian