How Does Dynamic Loading Work?
In this section, we will take a detailed look at the mechanics of the M-Let service. We will first look at an example of how to use an M-Let file to load an MBean from a JAR file. Then we will see how to use the M-Let service as the class loader for MBeans without the use of an M-Let file. For the sake of clarity and brevity, the examples in this section show agent-side code and do not contain complete exception-handling constructs.
We have discussed the tags used in the M-Let file, as well as the getMBeansFromURL( ) method of the M-Let service, which is used to load the MBeans specified in the M-Let file. Now let’s look at a couple of code examples.
method allows you to specify the URL of an
M-Let text file that contains the information necessary for the M-Let
load your MBeans. There are two versions of this method. The first
version takes a
String that contains the complete
URL to the M-Let text file. (We will deal only with URLs that are of the
file and http varieties
here, although many other protocols are conceivably supported.) Once
an MBean is loaded using getMBeansFromURL( ), it
is then registered with the same MBean server with which the M-Let
service is registered.
Suppose the M-Let text file is called
and resides in the
c:\jmxbook directory on the
local Windows-based filesystem. The URL to the M-Let text file would
then be file:/c:\jmxbook. Furthermore, suppose the contents ...