[jboss-user] [EJB/JBoss] - Re: Accessing JBoss service from EJB
je.a.le
do-not-reply at jboss.com
Fri Jun 5 12:22:49 EDT 2009
"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+
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4235698#4235698
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4235698
More information about the jboss-user
mailing list