Sometimes, launching an MBean requires several steps: this is particularly the case for agent services which require some sort of configuration. For example, you can instantiate another HTML adaptor for connecting to a different port. Usually, this would be done programmatically in the agent application, but we need to do it through the browser for the minimal agent.
On the agent administration page, fill in the fields as follows:
Domain: | Communications |
Keys: | protocol=html,port=8088 |
Java Class: | com.sun.jdmk.comm.HtmlAdaptorServer |
Class Loader: | leave blank |
Note: In previous versions of product, specifying the port number in the object name would initialize communication MBeans. Starting with the Java Dynamic Management Kit 4.0, 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 selected action is "Create" and send the request. If you scroll down the page, you should see if your request was successful.
We can't connect to this HTML adaptor quite yet, we need to configure it first.
Go to the new HTML adaptor's MBean view with the provided link.
We couldn't modify any of the adaptor's attributes before because the implementation is designed so that they can't be modified while it 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 may also click the attribute names to get an explanation for them.
Scroll down the MBean view to the Start operation and click its button. This brings up a new page 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 should be able to access your minimal agent through a browser on port 8088. Try going to a different machine on the same network and connecting to the URL:
where agentHostName is the name or IP address of the machine where you launched the MinimalAgent. If you reload the MBean view of the new HTML adaptor on either browser, the name of this other machine should be the new value of the LastConnectedClient attribute.
Through this other connection, you could stop, modify or remove the HTML adaptor MBean using port 8082. In that case, your original browser will have to use http://localhost:8088/ as well to connect. Instead, we will manage the minimal agent from this other machine.
From the browser on the other machine, go to the 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 given at the bottom of the page. The MBean name is also given: 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 will be appended to the bottom of the page. Scroll down and go to the MBean view with the provided link.
Since 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 original browser window, click in the filter field and hit "Return" to refresh the agent view. Click on the new MBean's name and set its reload period to 15. Back on the other machine, type in a different string for the State attribute and click "Apply".
On the original machine, you should see the MBean's attributes get updated when the MBean view is periodically reloaded.
On the other machine, click the reset operation button at the bottom of the MBean view page. This brings up the operation result page which indicates the success of the operation.
This page also gives 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 original machine after it reloads.
The browser on the other machine 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 we want to remove (you don't need its Java class to unregister it):
Domain: | Communications |
Keys: | protocol=html,port=8088 |
Java Class: | leave blank |
Class Loader: | leave blank |
Select "Unregister" from the drop down menu and click the "Send Request" button. The result then appears at the bottom of the page.
You can also unregister an MBean directly from its MBean view: just click the "Unregister" button on the upper right hand-side of the page.