Java Dynamic Management Kit 3.2 Programming Guide | ||||
---|---|---|---|---|
![]() | ![]() | Chapter 7. Adaptor Clients | ![]() |
Adaptor clients are the objects that management applications use to communicate with the agents that they wish to manipulate. These objects establish a connection to a corresponding adaptor server in an agent, through the specific protocol they implement. There is thus one adaptor server and client pair for each supported protocol.
An adaptor client enables Java managers to perform management operations on a Java agent. It does this first by connecting to a specific agent, then by providing a Java manager with handles on m-beans in that agent. These handles are either object names or c-beans which the manager instantiates locally to manipulate remote m-beans.
Adaptor clients provide a level of abstraction by allowing a manager to manipulate local objects whose effects are remote. The manager does not need information on the protocol used to communicate with the agent; rather it needs the class name or object name of the objects to be managed.
There are two ways for a manager to interact with its adaptor client:
The management application can call the methods of the adaptor client to interact with remote m-beans directly; these methods are defined in the AdaptorMO interface.
The application can have the adaptor client instantiate local c-bean objects which represent each m-bean in a remote agent; in this case, the manager calls the methods of the c-bean, those derived from its corresponding m-bean.
In fact, the c-beans themselves rely upon the AdaptorMO interface, so they provide a simplified access to the remote objects. In both cases, a manager must have information on the semantics of the m-beans it manages. It is much easier to write a management application using c-beans rather than calling the AdaptorMO interface. However, this requires that the appropriate c-bean objects be available to the management application. Manipulating c-beans also uses more memory resources since they are instantiated objects.
An adaptor client necessarily implements the com.sun.jaw.reference.client.adaptor.AdaptorMO interface which is protocol independent. Therefore, all code you write using this interface can run on any adaptor client that implements the interface, regardless of the protocol that the adaptor client uses. The implementations of the AdaptorMO interface supplied with the Java Dynamic Management Kit are described in Supported Protocols.
The AdaptorMO provides an abstraction of the connection between a manager and an agent. Its methods allow you to manage a remote agent without dealing with the communication protocol. One subset of these methods allows you to control the adaptor client instance, its parameters and the connection it establishes. Once the adaptor client is connected to a particular agent, the rest of the methods are used to access and control the m-beans of the agent.
However, the AdaptorMO interface is said to provide a low-level abstraction because you must tell it which operations to apply to which remote objects. Every time you call these methods, you must refer to the object names of the target m-beans and specify which property or action you wish to affect. While this might be appropriate for a small management scheme, you can more easily manage complex agents by using c-beans.
At the higher level of abstraction, the management application operates directly on c-bean instances. A c-bean is a local representation of a remote Java object, namely its corresponding m-bean. For more information on c-beans, see Interface and Stub of a C-Bean in Chapter 6.
When using c-beans, the application only calls the methods of the AdaptorMO interface to establish a connection to an agent and specify which m-beans it wishes to manipulate. Thereafter, the manager can directly manipulate the c-bean representation. The method signatures of a c-bean are identical to those in the original m-bean, which makes calling them more straightforward.
A Java manager obtains a reference to a c-bean through the adaptor client. Methods in the adaptor client instantiate the c-bean corresponding to a given object name. A Java manager performs management operations on an m-bean by invoking the methods of the c-bean that represents it. Figure 6-1 in Chapter 6 shows the relationship between a c-bean and its m-bean through the adaptor client in a management application.
The mogen compiler automatically generates the Java source code for a c-bean from the Java class of an m-bean. The generated code relies on the AdaptorMO interface so that operations on a local c-bean are propagated through any adaptor client to the remote m-bean. The c-bean's interface defines how a Java manager accesses an m-bean.
The mogen compiler also allows you to generate several different c-beans from the same m-bean. This enables different representations of the same m-bean to be presented to different Java managers. For information on how to use the mogen compiler, refer to Overview of the mogen Compiler in Chapter 6.
Object names in all Java Dynamic Management agents and managers must contain the class name of the Java object they represent. However, corresponding m-beans and c-beans have different class names because of the latter's MOStub suffix.
For more flexibility, you may specify either class name in the object names you pass to methods of the AdaptorMO interface. The adaptor client will apply mapping rules to the object name in order to determine the Java class of both c-bean and m-bean. For example, if the Java class name of your m-bean is beanName, you may use any of the following when specifying the class part of your object name:
beanName
beanNameMO
beanNameMOStub
Given any one of these, the adaptor client will know to use the m-bean called beanName and the c-bean called beanNameMOStub.
If you wish to do so, you may force an adaptor client to use different mapping rules. For more details, see Customizing the Mapping Rules.
![]() | ![]() | ![]() |
Adaptor Clients | ![]() | Supported Protocols |