I have a MBean which I want to access in other classes. I assume that I should get a reference to this MBean via a JNDI lookup. If this is true then what name should I use for the lookup ? Do I need to bind the MBean to a name in the MBean's constructor or start() method, and then use this name for the lookups ? Or can I use the name specified in the mbean element for the MBean (found in the jboss-service.xml of the MBean's SAR) ?
Thanks in advance for any information.
--James
James Adams
Ranch Hand
Joined: Sep 12, 2003
Posts: 188
posted
0
BTW my aplogies if this is the wrong forum for this question -- there's no JMX forum here and I don't think this question is really JBoss-specific. If there's a better place for JMX questions then please let me know.
I think that works on any JBoss server. I know that it does not work on other app servers. According to the spec, you can also use an MBeanServerDelegate, but I'll let you read the spec to figure out how to do that.
Once you have the MBeanServer, you can use it to invoke methods on the MBeans registered with it. Basically, you want to call MBeanServer.invoke. It takes a number of parameters to specify the name of the mbean, the method on the mbean to call, the parameters to pass, and the class names of those parameters. Download the api spec for more information.
Correct me if If I am wrong a reference to mbean is usually get by the mbean agent in which you register the name by which it can be called by remote clients as well as provide the detailed implementation. In weblogic its done like that not sure of Jboss.
regards, Amit
coffee drinker and Sun Certified Programmer for Java 2 Platform
Brian Tinnel
Ranch Hand
Joined: Aug 25, 2003
Posts: 69
posted
0
In WebLogic, you use a different method to get an MBeanServer. But you still get the MBeanServer and use it.
James Adams
Ranch Hand
Joined: Sep 12, 2003
Posts: 188
posted
0
Thanks so much, the MBeanServer.invoke() method was the solution I needed.