1 Reply Latest reply on Mar 26, 2009 10:00 AM by vit.jonas

    How to access class of EJB Session Bean from listener MBean

      I'm using JBoss 4.2.2GA

      I've implemented MBean that listen on EAR deployment. I can access enumeration of started mbeans via notification.getUserData(). Example:

      mbeans:
       persistence.units:ear=cobeco-next-server-gateway-.ear,jar=cobeco-next-server-gateway-services.jar,unitName=cobeco-next-gateway state: Started
       jboss.j2ee:ear=cobeco-next-server-gateway-.ear,jar=cobeco-next-server-gateway-services.jar,name=ServiceGateway,service=EJB3 state: Started
      


      May be I'm completly dumb but I can't find way how to get to class of EJB (ServiceGateway in the example) in the listener MBean. Given MBean for jboss.j2ee:ear=cobeco-next-server-gateway-.ear,jar=cobeco-next-server-gateway-services.jar,name=ServiceGateway,service=EJB3 is type of StatelessDelegateWrapper and I'm not able to dig any information how to get to class of underlying EJB.

      Could somebody give me some clue?

        • 1. Re: How to access class of EJB Session Bean from listener MB

          OK, I was finaly able to solve this by EJB3Deployer source code. I use following snipet to extract informations about classes in deployed jar:

           DeploymentInfo info = (DeploymentInfo)notification.getUserData();
           Iterator it = ArchiveBrowser.getBrowser(info.localUrl, new MyClassFileFilter());
           try
           {
           while (it.hasNext())
           {
           InputStream stream = (InputStream) it.next();
           DataInputStream dstream = new DataInputStream(new BufferedInputStream(stream));
           ClassFile cf = null;
           try
           {
           cf = new ClassFile(dstream);
           log.debug("ClassFile: " + cf.getName());
           AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
           if (visible != null)
           {
           Annotation myAnnotation = visible.getAnnotation("my.test.MyAnnotation");
           if(myAnnotation != null) {
           ...
           }
           }
           }
           finally
           {
           dstream.close();
           stream.close();
           }
           }
           }
           catch (IOException e)
           {
           }