-
1. Re: mbean lifecycle
starksm64 Apr 21, 2005 11:37 AM (in response to dabramov)I can assert that this supposition is completely false. The lifecycle has nothing to do with the existence of an mbean since jmx has no lifecycle/dependency notion inherently. The lifecycle notion is something we add on top of an mbean to create an mbean service construct.
The started state is reflected in jmx by the mbean State attribute and a jmx notification. -
2. Re: mbean lifecycle
mazz Apr 21, 2005 11:37 AM (in response to dabramov)that's easy to find out. In a test MBean start() method, do a wait(). Then in some other thread, look it up :-)
-
3. Re: mbean lifecycle
dimitris Apr 21, 2005 11:41 AM (in response to dabramov)Nope.
The MBean becomes immediately available after registration. You should guard inside your mbean code if you don't want to receive calls, e.g. (assuming you extend ServiceMBeanSupport, so the baseclass keeps track of state):private void checkStarted() { int state = this.getState(); if (state != ServiceMBean.STARTED) { throw new IllegalStateException("Cannot perform operations unless service is started"); } }
then at your operations:public void someOperation(...) { checkStarted(); ... //do whatever }
-
4. Re: mbean lifecycle
dabramov Apr 21, 2005 12:20 PM (in response to dabramov)Thanks for the quick replies.
In this case, the MBean that I'm looking up is not extending ServiceMBeanSupport. Can I get at the state information via another mehtod (MBeanServer.getAttribute()) ? -
5. Re: mbean lifecycle
starksm64 Apr 21, 2005 12:30 PM (in response to dabramov)Not unless you provide it.
-
6. Re: mbean lifecycle
dabramov Apr 21, 2005 12:32 PM (in response to dabramov)Fair enough. Thanks.