Java Reference
In-Depth Information
You use the MBean server's createMBean() method to create an instance of the
MLet MBean. This MBean will be your focus for the M-let service examples. The
MBean is registered with the ObjectName value JMXBookAgent:name=mlet .
10.3.2
Example: using an M-let file
The first example involves the main feature of the M-let service: creating MBeans
by loading M-let files. You begin by creating an M-let file.
The example M-let file
Using the attributes we examined earlier in section 10.2.2, you will create an M-
let file to load and create an instance of the HelloWorld MBean you used in
chapter 2. The following is the MLET entry for the file:
<MLET CODE=jmxbook.ch2.HelloWorld
ARCHIVE=ch2. jar
NAME=MLetAgent:name=hello1>
</MLET>
This entry is saved in a file called ch10.mlet in your jmxbook/ch10 directory.
Setting up the environment
You need to ensure you have the correct environment before trying to load this
M-let file. Before you start the agent, make sure you don't have the jmxbook.
ch2.HelloWorld class in your CLASSPATH (but keep your jmxbook.ch10 package in
the CLASSPATH ). Next, create the ch2.jar file that contains the jmxbook.ch2.Hello-
World class and copy it to the same directory as your M-let file. Use the following
command to create the JAR file (from the parent directory of your jmxbook pack-
age structure):
jar -cvf ch2.jar jmxbook\ch2\HelloWorld.class
To be sure you do not have the HelloWorld class in the CLASSPATH , delete the class
file before executing your environment setup script. After your environment is
ready, you can start the JMXBookAgent class with the following command:
java jmxbook.ch3.JMXBookAgent
For this example, you won't see any output from the agent. After starting the
agent, open your web browser and connect to the agent's HTML adapter.
Loading the M-let file
When you connect to the HTML adapter of the agent and select the MLet MBean,
the first thing you will notice is that the HTML adapter does not support all the
Search WWH ::




Custom Search