-
1. Re: How to push data to JMX components?
ragsta Apr 19, 2006 7:56 AM (in response to ragsta)this is the solution i've found:
my stateless session bean:public class CounterBean implements SessionBean { public static MovementsMgr myMBean=null; public void ejbCreate() throws CreateException { if (myMBean == null){ myMBean= new com.alblab.management.MovementsMgr(); MBeanServerLocator.locateJBoss().registerMBean(myMBean,new bjectName("xxx:name=movements")); System.out.println("MovementsMgrMBean registered"); } } . . . // my Ejb remote business method public String putMoney(int amount) { myMBean.setInbound(amount); //my method on MovementsMgr not exposed in the MBean Interface . . } }
MBean interface:public interface MovementsMgrMBean extends ServiceMBean{ public int getInbound(); . . . }
MBean Implementation:public class MovementsMgr extends ServiceMBeanSupport implements MovementsMgrMBean { private int inbound; public MovementsMgr(){ inbound=0; } . . . public int getInbound() { return inbound; } //not exposed in the MBean interface public void setInbound(int amount){ inbound=inbound+amount; } }
Is this a right way to do it? -
2. Re: How to push data to JMX components?
dimitris Apr 19, 2006 8:33 AM (in response to ragsta)There is an issue with the lifecycle with the mbean, i.e. how it gets destroyed/deregistered?
My initial idea would be to have an mbean service deployed together with the ejb as an embedded .sar
The mean would be a frond-end to a data object (pojo) holding the actual metrics. The mbean would register this pojo to the internal jndi, so the ejb can look it up and update it. You need to synchronize access to that pojo, as it will be accessed by many threads (there maybe a performance issue there). -
3. Re: How to push data to JMX components?
ragsta Apr 19, 2006 9:24 AM (in response to ragsta)I like the idea but I've a question about.
Does it work in a clustered evironment? -
4. Re: How to push data to JMX components?
dimitris Apr 19, 2006 10:31 AM (in response to ragsta)Clustering has nothing to do with this, or I don't get you?
-
5. Re: How to push data to JMX components?
ragsta Apr 21, 2006 4:39 AM (in response to ragsta)Ok, I follow your hints with only a difference:
I've two interfaces implemented by the same pojo, the MBean interface and an interface for internal use.
Next I've registered in the jndi this pojo using the Nonserializablefactory.
By this way I can cast it in the internal interface for business requirements and use it with the standard MBean interface for management requirements.
Tanks again.