Appserver MBean API (AMX) Sample Guide


This document gives an overview on using the Appserver MBean API (AMX).  Sample source code may be viewed directly by clicking on individual method names within the Javadoc. Nearly all the source code is contained within Samples.

Please see System Requirements before using the samples.


Running the sample command line

You can invoke the sample code program, a simple command-line interface as follows:

java -classpath classpath com.sun.appserv.management.sample.SampleMain SampleMain.properties

See SampleMain.connect() for an example of how to connect to the server.  If a properties file is not specified it uses default values for the above items.  If specified, the properties file uses the following format:

connect.host=localhost
connect.port=8686
connect.user=admin
connect.password=admin123
connect.truststore=~/.keystore
connect.truststorePassword=changeme
connect.useTLS=false

Note that in an EE build, TLS is generally enabled, so useTLS must be true and the trustStore and truststorePassword are required.  Connections will fail (or hang)  if useTLS is not set appropriately.

Once you have connected to the DAS via an AppserverConnectionSource call getDomainRoot() to get an instance of DomainRoot.  All further interfaces may be obtained from DomainRoot, directly or indirectly.

Viewing and running the sample code

Javadoc for all samples is found in Samples.java.  Each method is accompanied by Javadoc.  While viewing the Javadoc for a particular method (not just the summary of all methods), clicking on the method name displays the source code for that method.

You may wish to run the SampleMain command line interface while viewing the Javadoc.  The available samples are summarized here:

SampleMain command name
Samples.java method name
Discussion
demo-jmx-monitor
demoJMXMonitor()
Demonstrates the use of a javax.management.monitor MBean to be notified of changes in the value of an javax.management.Attribute.
deploy
deploy()
Demonstrates how to deploy an archive using the low-level API.
list-attributes
displayAllAttributes()
Demonstrates how to access and display available Attributes on a AMX.
list
handleList()
Demonstrates how to access various types of  AMX by obtaining a Map and then displaying it.
list-properties
displayAllProperties()
Display all properties found on all AMX.
query
demoQuery()
Demonstrate how to use the QueryMgr facilities.
quit
-

run-all
-
Runs all samples that do not require additional arguments.
start-server
startServer(String serverName)
Starts a server.
stop-server
stopServer(String serverName)
Stops a server.
show-hierarchy
displayHierarchy() Displays the hierarchy of all available AMX.
set-monitoring
setMonitoring( configName, level)
Sets the monitoring state for all available modules.
undeploy
undeploy(String moduleName)
Undeploys a deployed module.