Java Reference
In-Depth Information
you wrote the HelloWorld MBean to contain a single exposed attribute: its greet-
ing. That means the greeting attribute of the HelloWorld MBean is accessible for
both reading and writing, and the attribute table of the MBean View includes a
text field allowing you to enter a value. Clicking the Apply button commits any
changes. Go ahead and change the value for the greeting, and then click Apply.
The page reloads, and the text field displays the current value of Greeting , which
reflects the changes you just made.
Now look at the MBean Operations section, and you will see one available
operation. The MBean View constructs each operation as a button labeled with
the name of the method. For the HelloWorld MBean View, you see a button with
printGreeting as a label. That is the remaining method from the HelloWorld-
MBean interface. Just before the button, you see void , which is the return type of
the method. If this method had any input parameters, you would see a text field
for each input value.
NOTE
The HTML adapter can provide input only for certain types of parame-
ters. It supports only String s, primitive types, and the standard classes
related to the primitive types, such as java.lang.Integer .
When you click the printGreeting button, you will see two things happen. First,
the web browser navigates to a page indicating that the method succeeded and
did not return a value. Second, if you look at the output of your agent, you
should see the update value you entered for the Greeting attribute.
Congratulations—you have successfully managed the HelloWorld MBean.
There is only one more page to examine from the HTML adapter: the Admin
View. Go back to the Agent View and click the Admin button to go to the Admin
View of the HelloAgent .
2.5.3
Admin View
Using the first two HTML pages, you can configure and query MBeans registered
in the agent. However, what if you want to add additional MBeans to the agent
without writing more code? The Admin View is an HTML page presented by the
HTML adapter that gives you access to the agent's MBean server in order to
remove or add MBeans. From this page, you can specify an ObjectName value and
associate it with a Java class that is an MBean. The MBean server will construct
and register an MBean corresponding to your input. The Admin View presents
four text fields (see figure 2.8):
Search WWH ::




Custom Search