Java Reference
In-Depth Information
As mentioned earlier, the M-let service provides for this situation by allowing
you to expand its codebase. By using its addURL() methods, you can add to the
list of searchable URL s for classes and resources. After URL s are added, you can
access classes at the new locations, even in order to create MBeans. For exam-
ple, follow these steps to create the HelloWorld MBean again without using an
M-let file:
Make sure the agent process is stopped.
1
Restart the agent using the command from section 10.3.2.
2
Connect to the HTML adapter of the agent and select the MLet MBean.
3
Invoke the MBean's addURL() method with the file URL pointing to the
ch2.jar file. In our case, this value is file://c:/jmxbook/ch10/ch2.jar.
4
After receiving the success message, go to the Admin View of the adapter.
5
Enter the appropriate parameters to create a HelloWorld MBean. For the
Class Loader entry, enter the ObjectName value for the M-let service:
MLetAgent:name=mlet .
6
Execute the create request. You should receive a success message.
7
Go back to the Agent View, and you should see the new HelloWorld
MBean in the MBean list.
8
If you experience any errors with the MBean create request, be sure you typed
in the correct value for the added URL pointing to the ch10.jar file. You can ver-
ify the value you entered by viewing the URLs attribute of the MLet MBean.
10.4 Wrapping the M-let service to
p rovide notifications
You should know enough about the M-let service now that you could begin
including it in your JMX applications to expand their codebases and increase
their usefulness. However, if you used the M-let service with any frequency, you
might notice that the service does not emit any notifications. For example, you
cannot emit a notification indicating that a remote class was loaded. If your
agent persists notifications for later analysis of the agent's activity, you will prob-
ably want to include the activity of the M-let service. Otherwise, you will be miss-
ing valuable information from the activity log of your agent.
This section builds an MBean that wraps the M-let service to provide notifica-
tions for the M-let events that could occur. Figure 10.4 illustrates this idea.
Search WWH ::




Custom Search