users@glassfish.java.net

Re: Custom MBean question/sample

From: <glassfish_at_javadesktop.org>
Date: Wed, 29 Aug 2007 11:00:20 PDT

This helps a lot. Thank you for taking the time to help me understand. Once of the primary reasons that I was looking at the Custom MBean was because of its ability to persist the management properties.

Here is my my scenario. I've written a Resource Adapter that allows our applications to interact with networking devices via the Simple Network Management Protocol (SNMP). Because of our target audience, I need to have our application basically packaged up as an EAR and dropped into Glassfish without much additional hand holding. The Resource Adapter is actually embedded within the EAR and not deployed separately.

Because of the EAR deployment I would like to be able to have the customer be able to alter some configurable parameters after the deployment. I do have configuration parameters set through the deployment descriptors for the Resource Adapter and these are fine to update at installation time, but I need something a little more dynamic. So I was hoping that Custom MBeans might be the answer.

Looking at JMX and seeing that it really is an interface and an implementation, I was hoping that I could define the MBean interface and then for the implementation, I could make that a nested class within my Resource Adapter. As a nested class, it would have access to the internals of the Resource Adapter but only its interface would be visible via JMX. In fact, I tried this as an example. I created my interface and MBean implementation and then retrieved the platform MBeanServer and registered by MBean and viola within JConsole, I could see and manage my Resource Adapter. The part that is missing, however is the persistence of these management parameters.

So I guess with the Custom MBean and Glassfish, I need to change my thinking a little. I need to have the MBean implemented wholly with the classes that I provide to Glassfish when I deploy the MBean. Somehow I then need to have this MBean interact with my Resource Adatper. From reading the document that you provided (and that I found doing a search), the Glassfish will instantiate an MBean just to make sure it is valid and able to be instantiated. So from my thinking the MBean itself is its own entity rather than the what I was shooting for where the MBean was a piece of the Resource Adapter.

Does this sound about right?

Again, thanks for your time.
[Message sent by forum member 'bbergquist' (bbergquist)]

http://forums.java.net/jive/thread.jspa?messageID=233146