1 Reply Latest reply on Jun 5, 2009 10:58 AM by je.a.le

    Accessing JBoss service from EJB

    vlotarev

      Dear guru!

      Coudl you please tell me how is it possible to access JBoss service (POJO marked with @Service and @Local/@Remote) from EJB? Is it possible just to inject such bean? What will be a JNDI name of a @Service POJO?

      Thanks in advance,
      Vadim

        • 1. Re: Accessing JBoss service from EJB
          je.a.le

           

          "vlotarev" wrote:
          Dear guru!

          Coudl you please tell me how is it possible to access JBoss service (POJO marked with @Service and @Local/@Remote) from EJB? Is it possible just to inject such bean? What will be a JNDI name of a @Service POJO?

          Thanks in advance,
          Vadim


          from an ejb, if the service has @Service & @Remote |& @Local, simply use @EJB :
          @Service(name = "InitMarchePublicJMX", objectName = "org.portal.marchep.jmx.initialization:name=InitMarchePublicJMX,type=ManagementInterface")
          @Management(InitMarchePublicJMXManagement.class)
          @Local(InitMarchePublicJMXLocal.class)
          public class InitMarchePublicJMX implements InitMarchePublicJMXManagement, InitMarchePublicJMXLocal {
          ....
          }
          
          in the ejb :
          @EJB
          InitMarchePublicJMXLocal jmxinstance;
          
          


          if the service is a jmx (@management) (like the one of the code over) :
          MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
          InitMarchePublicJMXManagement bean = () MBeanProxy.get(InitMarchePublicJMXManagement.class,
           new OjectName(
          "org.portal.marchep.jmx.initialization:name=InitMarchePublicJMX,type=ManagementInterface"),
           mbeanServer);
          


          and last, you can go with :
          MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
          ObjectName mbeanName = new ObjectName(Config.FILTRELINGUISTIQUEJMX);
          String str = (String) mbeanServer.invoke(mbeanName, "FiltrerList", new Object[]{str, true}, new String[]{"java.lang.String", "boolean"});
          

          What's really interesting with this one is you do not need dependencies, though you should stick with default type.

          A+