Change your working directory to %XMOJO_HOME%/tutorials directory.
Execute the build.bat (This batch file compiles the Java files under
the src directory and the output class files will be stored in the classes
directory.)
Execute the run.bat (This batch file executes the RunNotifAgent
class.)
The JMX Agent will be started. RMI Server will be started at port 1099.
HTML Server will be started at port 8030. For testing the example,
refer to the section, "Testing the Agent" given below.
For Unix OS
Change your working directory to $XMOJO_HOME/tutorials directory.
Execute the build.sh (This script file compiles the Java files under
the src directory and the output class files will be stored in the classes
directory.)
Execute the run.sh (This script file executes the RunNotifAgent
class.)
The JMX Agent will be started. RMI Server will be started at port 1099.
HTML Server will be started at port 8030. For testing the example,
refer to the section, "Testing the Agent" given below:
Testing the Agent
Using the RMI Client
Start the MBeanBrowser tool by executing the mbeanbrowser.bat/mbeanbrowser.sh
file under XMOJO_HOME/bin directory.
Connect to the RMI Server. (In the menu bar, choose Settings >>
Client Settings. Configure the HostName and PortNumber. Here, HostName
is the machine name where the RMI Server is running. After configuring
the client settings, choose Operations >> Connect). This will
establish a connection with the RMI Server.
The registered MBeans is listed in the left frame.
Under the domain ShoppingCart, an MBean with the name type=MBean
is present. Under this MBean node, click Attributes. It lists
three read only attributes. The attributes are TotalItemCount, TotalPrice,
and ItemsPurchased. Click Operations.
Three operations, reset, addItem,
and updateItem, are listed. Invoke the addItem operation passing the
values Parrot and 4. Click OK. Click Attributes. Now,
once again click Attributes. Now, the attributes are
updated with new values. TotalItemCount will be with the value 4 and TotalPrice
will be with the value 80. The ItemsPurchased will display Value Not Obtained.
(This is a limitation in the MBeanBrowser tool.)
Under the domain InventoryMBean, two MBeans with the names Pet=Parrot and Pet=Fish are listed.
Under the MBean node Pet=Parrot, click Attributes. It lists four read
only attributes. The InventoryLevel and Purchased have the value 16
and 4 respectively. Click Operations. No Operations are listed.
When the InventoryLevel reaches below 6, an operation, increaseStock will be exposed.
To decrease the InventoryLevel below 6, some more parrots need to be purchased.
For purchasing parrots, either the ShoppingCart application can be used
or the ShoppingCart MBean can be used. In the ShoppingCart application,
choose the Parrot pet and click the Edit button. (If no item
is selected, an error message "Select an item to edit" pops up). Modify
the Quanity value to 12. Click OK. Now, the Quantity added will
be 16. (4 + 12) The inventory level will be decreased to 4 which is
less than six.
Using the Web Browser
Open any Web browser and type the URL http://localhost:8030. If you
are testing from a remote machine, enter the URL http://hostName:8030; here,
hostName is the machine name where the JMX agent is running. If the
HTML Adaptor is listening at some other port, replace the 8030 with the appropriate
port number in the above URL.
The index page lists the various domains and some useful links for viewing
notifications, searching the MBeans, customizing MBean views, etc.
Click the ShoppingCart link under Domains. One MBean is listed. Click
the link ShoppingCart:type=MBean. Three readOnly attributes
are listed. The attributes are TotalItemCount, TotalPrice, and ItemsPurchased.
Click the Operations image. Three operations, reset, addItem,
and updateItem, are listed. Invoke the addItem operation passing the
values Parrot and 4. Click the Continue button. Click
the link ShoppingCart:type=MBean. Now, the attributes are
updated with new values. TotalItemCount will be with the value 4 and TotalPrice
will be with the value 80. Click the Home link.
Click the InventoryMBean link under Domains. Two MBeans are listed.
Click the link InventoryMBean:Pet=Parrot. It lists four read
only attributes. The InventoryLevel and Purchased have the value 16
and 4 respectively. No Operations are listed, i.e, the Operations image
does not exist. When the InventoryLevel reaches below 6, the InventoryMBean
exposes an operation, increaseStock.
To decrease the InventoryLevel below 6, some more parrots need to be purchased.
For purchasing parrots, either the ShoppingCart application can be used
or the ShoppingCart MBean can be used. In the ShoppingCart application,
choose the Parrot pet and click the Edit button. (If no item
is selected, an error message "Select an item to edit" pops up). Modify
the Quanity value to 12. Click OK. Now, the Quantity added will
be 16. (4 + 12) The inventory level will be decreased to 4 which is
less than six.
After reducing the inventory level below 6, refresh the HTML page.
Now, the Operations image appears. Click the Operations image. An
operation with the name increaseStock is exposed.