Module
JMX- Instantiate and Register MBean Action - UI Specification
Authors: Alexandre Neubert, Thomas Leveque, Jean-Francois Denise
Instantiate
and Register MBean Action
This action helps user
in generating code to instantiate, name and register MBeans within a
JMX Agent.
Within a JMX Agent, the init method is the place to proceed
with these tasks.
This action results in some generated code at the end of JMX Agent init method.
The action is enabled
for all class having an init
and a getMBeanServer method.
[PENDING] We are thinking at making
this action an Editor one. The user could click somewhere in the source
code in order to generate code at the selected location.
Call
the Action
Current module actions are located under
Run menu. We could introduce a new
Management menu if the set of
actions requires it.
This ui spec defines a new
Management
menu. It could be replaced by a
Management
submenu
under
Tools.
- From contextual menu :
- The Instantiate and
Register MBean action is called by right click on a JMX
module generated Agent class in the project view.
- Select Management submenu. Select the Instantiate
and Register MBean... item.
- From main menu :
- Management
menu then select the Instantiate
and
Register MBean...
item.

The following popup
window is displayed :

Scope
of the action
This action should
be accessible from any kind of project.
Instantiate and register a
javax.management.StandardMBean
The user have to select the second RadioButton
Register Java Object wrapped in a
StandardMBean.
javax.management.StandardMBean
is dedicated to wrap a java object in order to make it an MBean.
A warning message indicates that the specified class doesn't exist.
Steps to follow :
- The user specify a Java Class to wrap. Thanks to "Java Class" Textfield. In our
example we type java.lang.String.
- Once we detect that the typed class is valid, the discovery
of implemented interfaces and constructors by this class is performed.
- An ObjectName is computed based on the Class name. The rule is
<reverse package name>:type=<class name>. The user can edit
and type in his own ObjectName.
- The user can then select an Interface that will be used as the
management interface or, select "Apply
JMX Design Pattern Management Interface"
if he wants all its public methods to be exported.
- The user can then select a Constructor that will be used to
create the wrapped Object instance or choose to not instantiate a new
object by selecting "Object
Instantiation Not Generated" (in this case, we generate null as intantiation code and inform
the user by a comment).
- Clicking OK will generate the following peace of code at the end
of JMX Agent init method:
//TODO replace StandardMBean constructor
first parameter by your own java.lang.String object.
getMBeanServer().registerMBean(new
javax.management.StandardMBean(null, java.lang.CharSequence.class),
new
ObjectName("lang.java:type=String"));
Instantiate and register an
MBean (Standard or Dynamic)
Such MBeans are MBeans that have been developed by the user.
Steps to follow:
- In the MBean class dropdown list, the user select an MBean class.
These MBean classes have been discovered. The user can type in his own
MBean Class.
- Once we detect that the specified class is valid, the discovery
of constructors by this MBean class is performed.
- An ObjectName is computed based on the MBean Class name. The rule
is
<reverse package name>:type=<class name>. The user can edit
and type in his own ObjectName.
- The user can then select a Constructor that will be used to
create the MBean
- Clicking OK will generate the following peace of code at the end
of JMX Agent init method:
//TODO update
NewJMXClass2(String) constructor parameters with valid values.
getMBeanServer().registerMBean(new
com.toto.NewJMXClass2(null),
new
ObjectName("toto.com:type=NewJMXClass2"));