Java Dynamic Management Kit 3.2 Programming Guide
[ Previous ][ Fast Back ]Chapter 12. Dynamic Loading Services[ Fast Forward ][ Next ]

Class Loaders

Class loaders enable Java Dynamic Management agents to obtain Java classes, m-beans and applications from remote servers or .jar files. The downloaded classes, m-beans and applications can then be loaded into the agent's framework. The Java classes must be present on the machine on which the server is running. You can implement your own class loaders for specific applications. The following class loaders are supplied with the Java Dynamic Management Kit:

The Java Dynamic Management Kit enables you to add a class loader to an agent in either of the following ways:

The Java Dynamic Management Kit allows an agent to contain more than one class loader. This enables you to specify a particular class loader to be used for loading a class, so that you can load classes from a number of different servers.

RMI Network Class Loader

The RMI network class loader enables you to obtain classes from a remote class server. The network class loader must be added to an agent before it can be used. The network class loader must be assigned an object name that contains information on the remote class server. To use the network class loader, you add it to an agent. When you add a network class loader to an agent, you must assign it an object name. The object name you assign to a network class loader must contain configuration information that the class loader requires, as explained in Object Name of an RMI Network Class Loader in Chapter 13.

M-Let Service Class Loader

The management applet or m-let service enables an agent to obtain m-beans from a remote .jar file. The agent does this by loading an m-let text file, which specifies information on the m-beans to be obtained. The information on each m-bean is specified in a single instance of a tag, called the MLET tag. The location of the m-let text file is specified by a URL. When an m-let text file is loaded, an instance of each m-bean specified in the file is created.

Bootstrap Service Class Loader

The bootstrap service simplifies the distribution of new releases of an application (that is, an agent or a manager) from a central server. It is a standalone Java program that enables you to load an application from a remote .jar file. To obtain a new version of an application, all you have to do is run the bootstrap service on the system that requires the application to be loaded and run. Information on the application is contained in an m-let text file. You specify the URL of the m-let text file when you run the bootstrap service.

Loader Repository

All Java Dynamic Management Kit class loaders running in the same Java virtual machine register with the loader repository. When an agent tries to load a class where no class loader has been specified, the agent looks in the framework's class loader, the system (using the class path) if no class loader is defined for the framework and finally in the loader repository. The loader repository contains pointers to all of the class loaders that have registered.

Figure 12-1. Operation of the Class Loaders

fig629.epsi

Instantiating a Remote M-Bean Using a Specific Class Loader

The Java Dynamic Management Kit allows an agent to contain several instances of a class loader, provided that every instance is registered with the repository. This enables, for example, each class loader to be connected to a different remote server. Therefore, by using a specific class loader, an application is able to specify the remote server to be used for loading a particular class. In this way, the application can load classes from a number of different servers.

To use a particular class loader, make sure that the request to create an object specifies that class loader. The class loader must be identified by its object name. If you do not specify the class loader, the Java Dynamic Management Kit uses the framework classloader, the system (using the class path) if no class loader is defined for the framework and finally the loader repository. If the class is not found by the loader repository, then the class is not available within the Java virtual machine.

The methods for instantiating a remote m-bean are the same as those for instantiating any other m-bean, as described in Chapter 4. When an agent invokes a method to instantiate a remote m-bean, all of these conditions must be satisfied:


[ Previous ][ Home ][ Next ]
Dynamic Loading Services[ Up ]Library Loaders