Java Reference
In-Depth Information
Acquiring resources
Finally, the MBean interface declares several methods that expose the class
loader capability of the MBean's super class. The resource acquisition methods
like getResource() are declared to expose some of the functionality inherited
from the MBean's super class, java.net.URLClassLoader . You can use these
methods to acquire resources outside the normal CLASSPATH of the JMX agent
containing the MLet MBean.
You can use the resource-loading capability to download a new internationaliza-
tion file into the agent and thereby provide internationalized notification messages.
10.3 Using the M-let service to load MBeans
Now that we have examined the M-let service, let's create some examples. In this
section, you will build two examples. The first example loads MBeans with the
M-let service, using an M-let file. The second example shows you that by using
the M-let service to expand the agent's codebase, you can also load MBeans with-
out using an M-let file.
10.3.1
Adding to the JMXBookAgent class
The first step in writing your M-let examples is to add the M-let service to your
JMXBookAgent class. You will do this by adding the method startMletService() to
the agent and invoking it in the agent's constructor. Once you've made the agent
class changes, you will be able to use the agent for the examples. Listing 10.1
shows the startMletService() method.
Listing 10.1
The startMletService() method
protected void startMletService()
{
ObjectName mletName = null;
try
{
mletName = new ObjectName( "JMXBookAgent:name=mlet" );
server.createMBean( "javax.management.loading.MLet",
mletName );
}
catch( Exception e )
{
ExceptionUtil.printException( e );
}
}
Search WWH ::




Custom Search