[jboss-user] [EJB 3.0 Users] - Getting the ejbName inside an interceptor

pete.muir@jboss.org do-not-reply at jboss.com
Thu Aug 27 18:08:18 EDT 2009


This is for JBoss EJB 3 integration code, so we can use JBoss interfaces, not just EJB standard interfaces.

Inside an interceptor instance, I need access to the ejbName of the EJB being intercepted (so I can use this as a unique key to look up other info on the EJB). Currently I am doing this ugly hack:

      try {
  |          guidField = StatefulSessionContextImpl.class.getDeclaredField("containerGuid");
  |          guidField.setAccessible(true);
  |       } catch (Exception e) {
  |          throw new RuntimeException(e);
  |       }
  | 
  |       ...
  | 
  |       try {
  |          String guid = (String) guidField.get(sessionContext);
  |          Container container = Ejb3Registry.getContainer(guid);
  |          return container.getEjbName();
  |       } catch (Exception e) {
  |          throw new RuntimeException(e);
  |       }

Any suggestions on how to improve?

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4252158#4252158

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4252158



More information about the jboss-user mailing list