![]() |
|||
![]() |
![]() ![]() |
![]() |
![]() ![]() |
![]() |
![]() ![]() |
![]() |
| ||||||||||||||||||||||||
6.2.3 List of OperationsThe last part of the MBean view contains all the operations exposed by the MBean. Each operation in the list is presented like a method signature. There is a return type, then a button with the operation name, and if applicable, a list of parameters, each with their type as well. As with the table of attributes, the list of operations contains only those involving types that can be represented as strings. The return type must support the toString method and the type of each parameter must be one of basic data types supported by the HTML adaptor. For the complete list, see the Javadoc API of the HtmlAdaptorServer class. Above each operation name is a link to its description. Parameter names are also active links that display a window with a description. Again, descriptions are only meaningful when provided by dynamic MBeans. The following figure shows some of the operations exposed by the HTML adaptor MBean and a description of the Start operation. Figure 6-4 MBean Operations With a Description Window (Partial View) ![]() We will not perform any operations on this MBean until after a brief explanation in 6.3.1 Instantiating and Managing MBeans. To perform an operation, fill in any and all parameter values in the corresponding text fields and click the operation's button. The HTML adaptor displays a page with the result of the operation, either the return value if successful or the reason why the operation was unsuccessful. 6.3 Agent AdministrationThe agent administration page contains a form for entering MBean information when creating or unregistering MBeans. You can also instantiate an MBean through one of its public constructors. In order to instantiate an MBean, its class must be available in the agent application's classpath. Optionally, you can specify a different class loader if the agent contains other class loader MBeans.
|
Domain | Communications |
Keys: | protocol=html,port=8088 |
Java Class: | com.sun.jdmk.comm.HtmlAdaptorServer |
Class Loader: | leave blank |
In versions of the Java DMK prior to version 4.0, specifying the port number in the object name would initialize communication MBeans. Now, the names and contents of key properties no longer have any significance for any components of the product. We must set the port in other ways.
Make sure the action selected is Create and send the request. If you scroll down the page, you will see whether your request was successful.
We cannot connect to this HTML adaptor quite yet. First we need to configure it .
Go to the new HTML adaptor's MBean view with the provided link.
Remember that we could not modify any of the adaptor's attributes in To View an Attribute Description because the implementation does not allow them to be modified while the HTML adaptor is online. Our new HTML adaptor is instantiated in the stopped state (the StateString attribute indicates OFFLINE), so we can change its attributes.
Set the Port attribute to 8088 and MaxActiveClientCount to 2, then click the Apply button.
If the page is reloaded and the new values are displayed, the attribute write operation was successful. You can also click the attribute names to get a description them.
Scroll down the MBean view to the Start operation and click the Start button.
A new page is displayed to tell us the operation was successful. If you go back to the MBean view with the provided link, you can see that the StateString is now indicating ONLINE.
Now you can access your agent through a browser on port 8088. Try going to a different host on the same network and connecting to the following URL:
In the above URL, agentHostName is the name or IP address of the host where you launched the BaseAgent. If you reload the MBean view of the new HTML adaptor on either browser, the name of this other host should be the new value of the LastConnectedClient attribute.
Through this new connection, you can stop, modify or remove the HTML adaptor MBean using port 8082. In that case, your original browser will also have to use http://localhost:8088/ to connect. Instead, we will manage the agent from the second host.
From the browser on the second host, go to the agent administration page. Fill in the fields as follows and request the constructors:
Domain: | Standard_MBeans |
Keys: | name=SimpleStandard,number=1 |
Java Class: | SimpleStandard |
Class Loader: | leave blank |
The list of constructors for the SimpleStandard class is displayed at the bottom of the page. The MBean name is also shown. This is the object name that will be assigned to the MBean when using one of the listed constructors. As you can see, the SimpleStandard class only has one constructor that takes no parameters.
Click on the Create button. The result is appended to the bottom of the page. Scroll down and go to the MBean view with the provided link.
Because it is a standard MBean, all of its description strings are generic. This shows the necessity of programming meaningful attribute names.
In the agent view on the first browser window, click in the filter field and press Return to refresh the agent view.
Click the new MBean's name and set its reload period to 15.
On the second host, type in a different string for the State attribute and click Apply.
On the first host, you should see the MBean's attributes are updated when the MBean view is periodically reloaded.
On the second host, click the Reset operation button at the bottom of the MBean view page.
The operation result page is displayed and indicates the success of the operation.
This page also provides the return value of the operation when it is not void. If you go back to the MBean view, you will see the result of the operation on the attributes. You should also see it on the first host after it reloads.
The browser on the second host is no longer needed and we can remove the HTML adaptor on port 8088.
Go to the administration page and fill in the object name of the HTML adaptor you want to remove (you do not need its Java class to unregister it):
Domain: | Communications |
Keys: | protocol=html,port=8088 |
Java Class: | leave blank |
Class Loader: | leave blank |
Choose Unregister from the pull-down menu and click the Send Request button.
The result is displayed at the bottom of the page.
You can also unregister an MBean directly from its MBean view. Click the Unregister button on the upper right side of the page.
![]() ![]() |