Java Reference
In-Depth Information
3.5 Running the agent
Now that you have constructed the agent and written a factory class that provides
RMI clients, it is time to test the agent. In this section, you will test the agent by
connecting to it with an HTML client and an RMI client.
Using one of the build environments created in chapter 2, compile the
JMXBookAgent , RMIClientFactory , and ExceptionUtil classes. With the code
compiled, you are ready to run the agent. To execute the agent, use the follow-
ing command:
java jmxbook.ch3.JMXBookAgent
You should see the following output from the agent:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> START of JMXBook Agent
>>> CREATE the agent...
CREATE the MBeanServer.
Agent is Ready for Service...
With the JMXBookAgent running, you can now connect to it using the two methods
you have set up ( HTML and RMI ).
3.5.1
Connecting to the agent with the browser
To connect to the agent's HTML adapter, open a web browser to http://local-
host:9092 (opening on the same machine). The H TML adapter should display
the Agent View in your browser. The Agent View should show you three MBeans:
the adapter, the connector, and MBeanServerDelegate . (In fact, you could use this
agent to redo the HelloWorld example in chapter 2.)
3.5.2
Connecting to the agent with an RMI client
To test the RMI connector, you need to write a little program to use an RMI client
that reaches the agent. You'll take the HelloWorld MBean from chapter 2 and
register it in the agent by using an RMI client. Listing 3.7 shows the HelloWorld-
Setup class, which does just that. You'll use setup classes like this one throughout
the topic to register other MBeans, so this won't be the last time you see this type
of simple program.
Search WWH ::




Custom Search