0 Replies Latest reply on Oct 17, 2002 3:42 PM by Philippe C

    EJB Instance Info in Interceptor

    Philippe C Newbie

      Dear JBosseurs,

      I'm building an Entity Bean Interceptor and I want to have access to attributes of the Entity Bean whose calls I'm intercepting. For instance I want to get the primary key of the EJB instance.

      this is the way I do it now: I basicaly getInstance on the EntityEnterpriseContext and then invoke a methods on it.
      [pre]
      public Object invoke(Invocation mi) throws Exception {

      // other code ...

      EntityEnterpriseContext eec = (EntityEnterpriseContext) mi.getEnterpriseContext();
      if( eec != null ) {
      Object instance = eec.getInstance() {
      if( instance != null ) {
      Method getMethod = instance.getClass().getMethod("getOrderid", new Class[] {} );
      Object orderidObject = getMethod.invoke(instance, new Object[] {} );
      log.debug("orderid=" + orderidObject);

      // do something with orderid (post JMS message)

      }
      }
      }
      return getNext().invoke(mi);
      }
      [/pre]

      My questions are:

      - Is this the best way of reading attributes of the EJB instance?

      - How can I know if the transaction was rolled back or if an exception happened in other interceptors or in the container?

      - Am I inside the transaction if I place my Interceptor after the TxInterceptorCMT. Can I take advantage of transacted JMS?

      - I placed my interceptor after the JDBCRelationInterceptor to take advantage of the cache and to make sure the state was in sync with the database. Is this the best spot? The possibilities seem endless.

      PhilC