Java Reference
In-Depth Information
This chapter's purpose is to lay the groundwork for many of the examples
throughout the topic. As you read the following chapters, most of your coding time
will be spent writing and working with MBeans. Most examples in this topic are
executed within the chapter to demonstrate the working code. In all the examples,
you will need to have a JMX agent to contain your MBeans. In order to spare you
from repeatedly writing the same agent code, you'll construct your JMX agent in
this chapter to use throughout the topic. In addition, as the topic progresses, you
will add functionality to the agent by including other services or utilities.
3.1 T he scope of the agent
Before you begin writing any code, you should understand that the agent you
will write in this chapter will end up closely resembling the HelloAgent class from
chapter 2. In fact, there will be only one major difference. The important point
is that as the topic moves along, you will add code to your agent as needed.
Therefore, because we have not discussed any new topics, your agent code will
closely resemble the HelloAgent example.
Your agent will be defined by the class jmxbook.ch3.JMXBookAgent . At this
point in the topic, it has two responsibilities:
Create an MBean server
Provide connectivity
Just like the HelloAgent from the previous chapter, your JMXBookAgent class must
contain an MBean server. In addition, it too will create an HTML adapter so that
you can examine and interact with MBeans residing on the agent. However, in
addition to the HTML adapter, you will add a Java Remote Method Invocation
( RMI ) connector to the agent in order to provide your future code examples with
a programmatic way of interacting with the agent. Figure 3.1 illustrates the two
ways this agent will be used.
Looking at the figure, you can see that you will be able to interact with your
agent both through a web browser and by using a Java RMI client. You will con-
struct a factory class for creating RMI clients later in this chapter. Later examples
that need an RMI client will use this factory class to acquire it.
3.1.1
Using the HTML adapter
Adding the HTML adapter to your agent will be useful for some of the reasons
presented in chapter 2. It will give you a view into the agent, allowing you to see
a list of MBeans residing in the MBean server. Not only that, but as you wit-
Search WWH ::




Custom Search