DynamicMBean implementation

Hi,

I'm trying to use Jboss JMX console to configure my application. Some of the properties I need, I know in advance. Some of them though(like connections I need to be able to add/delete/modify on the fly ) are not. I don't know how many of them I'll need, I don't know what their names will be. Reading piles of MBean related docs I came to the conclusion that maybe DynamicMBeans are the the answer to my problem. Being new to this technology I struggle to create the implementation that works. I was just wondering - is there a working example how this dynamics can be achieved. All of the examples of dynamic mbeans I saw, actually work with predefined attributes.

Thanks in advance.

[712 byte] By [JavaSufferera] at [2007-10-3 8:57:06]
# 1

It is very unusual for the MBean interface not to be known at compile time. It would be somewhat analogous to a Java class where you don't know what the methods will be until run time. There are applications, for example if your MBean model is derived from a set of XML files, but they're definitely unusual and advanced.

Even if you don't know the name of your connections at compile time, you know that there will be connections. So your best bet might be something on the lines of:

public interface ConnectorManagerMBean {

public String[] getConnectionNames();

public long getConnectionCreationTime(String connectionName);

}

The getConnectionNames() method lets the caller discover what connections there are, and then the getConnectionCreationTime method lets the caller discover the creation time for any given connection.

Given an interface like this, you can make a Standard MBean, and you don't need to get into the details of Dynamic MBeans.

emcmanusa at 2007-7-15 4:07:28 > top of Java-index,Core,Monitoring & Management...