Java Dynamic Management Kit 3.2 Programming Guide
[ Previous ][ Fast Back ]Chapter 7. Adaptor Clients [ Next ]

Advanced Configuration

You may configure the default behavior of an adaptor client in the following two ways:

Customizing the Mapping Rules

An adaptor client uses mapping rules to determine the Java class name of both m-beans and c-beans from the class part of an object name.

The default mapping rules are described in Mapping Rules for Class Names. These rules are embodied in the com.sun.jaw.impl.mapper.DefaultMapper Java class provided with the Java Dynamic Management Kit. This class implements the com.sun.jaw.reference.mapper.MapperSrvIf Java interface which specifies the methods used by the adaptor client to obtain m-bean and c-bean class names.

If you wish to customize the mapping rules you must provide another implementation of the MapperSrvIf interface. This interface specifies the following two methods which return the name of a Java class:

Then, you need to specify the use of your new mapping rules in your adaptor client. Example 7-22 shows how to do this within a management application.

Example 7-22. Specifying New Mapping Rules
// Instantiate an adaptor client (HTTP/TCP in this case) 
AdaptorMO AdaptorClient = new
    com.sun.jaw.impl.adaptor.http.AdaptorClient;

// Instantiate the object which implements mapping rules
MapperSrvIf newMapper = new MyMappingRules();

// Tell the adaptor client to use these new rules
AdaptorClient.setMapperSrv( newMapper );

Specifying a Class Loader

An adaptor client uses a class loader to load the c-beans that it needs when creating managed objects. By default, adaptor clients use the system class loader. The system class loader looks in the path defined at run-time in the CLASSPATH environment variable, or, in the case of a Java applet, classes are loaded from the same URL as was the applet.

If you wish to use a different class loader in your adaptor client, you can force it to use a class loader which you specify. First you must instantiate the new class loader in your management application, they you call the following method of the AdaptorMO interface:

Example 7-23 shows how to instantiate and add a class loader to an adaptor client. This example uses the com.sun.jaw.impl.agent.services.loader.rmi.NetClassLoader class provided with the Java Dynamic Management Kit. When using this class loader, the corresponding class and library server must run on the specified host machine. The newly instantiated class loader will obtain classes and libraries from an RMI server that has the URL rmi://myHost:1099/NetClassServer. For more information, refer to Chapter 13.

Example 7-23. Specifying a New Class Loader
import com.sun.jaw.impl.agent.services.loader.rmi.*

// When using the NetClassLoader, the object name is used
// to specify the target host machine and port number
//
ObjectName name = new ObjectName(
    "D:C.host=myHost,port=1099,service=NetClassServer" );
NetClassLoader newLoader = new NetClassLoader( name );

// Tell the adaptor client to use this new class loader
AdaptorClient.setClassLoader( (ClassLoader) newLoader );


[ Previous ][ Home ][ Next ]
Operations on an Agent[ Up ]Problem Solving