Hi,
I have a MDB called FileMessage. I have to make a simple servlet for the
admins to be able to start and stop the MDB easily (i.e. not having to learn to
use the JMX console). To do this I've made the code below. I feel there must
be a better way to start and stop MBeans at random. For instance, I have to
use queryNames() to get the uniqueIdentifier for the MDB as it has a hashcode
appended to it to make it impossible to hardcode.
This also returns 3 ObjectNames as well:
jboss.j2ee:jndiName=local/[EMAIL PROTECTED],plugin=pool,service=EJB
jboss.j2ee:binding=message-driven-bean,jndiName=local/[EMAIL
PROTECTED],plugin=invoker,service=EJB
jboss.j2ee:jndiName=local/[EMAIL PROTECTED],service=EJB
The last one seems to be the one I need to invoke the stop(). Ideally I want
to be able to specify the ObjectName by hand.
If anyone can see a way to improve the code below could you let me know please.
Cheers,
Joe.
| MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
| java.util.Set s =
| mbeanServer.queryNames(new ObjectName(""), new ObjectName(""));
| java.util.Iterator iter = s.iterator();
| ObjectName ejbToStop = null;
| while(iter.hasNext()) {
| Object obj = iter.next();
| if(
| (obj.toString().indexOf("FileMessage") > -1) &&
| obj.toString().endsWith("service=EJB")) {
| ejbToStop = (ObjectName) obj;
| }
| }
|
| mbeanServer.invoke(ejbToStop, "stop", new Object[0], new String[0]);
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3932398#3932398
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3932398
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user