The example shows an agent and an m-bean that are designed to be loaded into the BeanBox as .jar files. Once these objects have been instantiated, you can manage the agent through an adaptor client, such as the Java Dynamic Management M-Bean Browser.
The directory containing the source files for this example depend on the platform shown in the table.
|
Platform |
Directory |
|
Solaris |
installDir/SUNWconn/jaw/examples/src/agentbean |
|
Windows NT |
installDir\SUNWconn\jaw\examples\src\agentbean |
AgentMain.java
AgentMain.java provides an implementation of a Java Dynamic Management agent in which the core management framework object is declared as static. This class is designed to be loaded into the BeanBox application by means of a .jar file. The AgentMain class, once instantiated, can interact with any m-bean instantiated in the BeanBox application, provided the m-bean contains the code required to register itself with the repository. TextSample.java
TextSample.java defines a simple m-bean for use with this example. It contains in its constructor the code required to register itself with the m-bean repository, as shown in CODE EXAMPLE D-1.
Makefile
The Makefile compiles the example Java classes and creates the manifest files and .jar files required to enable the example to be used with the BeanBox application.
Making a Manageable JavaBeans Component
The Java Dynamic Management agent, once instantiated, can manage any bean instantiated in the BeanBox that contains the lines in its code shown in CODE EXAMPLE D-1.
In addition, TextSample.java contains the import lines for Java Dynamic Management Kit packages shown in CODE EXAMPLE D-2:
|
|
|
import com.sun.jaw.reference.agent.cmf.*;
|
|
import com.sun.jaw.reference.common.*;
|
|
|
Compiling the Agent
Before compiling the example, copy the contents of the directory containing the example to another location. The file access permissions of the directories under the home directory of your Java Dynamic Management Kit installation do not allow write access to ordinary users.
prompt% make
|
To Set a Property Using the BeanBox |
prompt% java sun.beanbox.BeanBoxFrame
PATH variable.