Package amxsamples

Appserver MBean API (AMX) Sample Guide

Last updated: 25 October 2005

Introduction
This document gives an overview on using the Appserver Management Extensions (AMX) API.

See:
          Description

Class Summary
CmdTemplate Write your own code, then run it in the command line eg: Enter Command > mystuff.MyCmd [args] Implement the runCmd() method any way you like.
ConfigSetup  
Demo  
DeployNotificationListener A JMX NotificationListener for deployment.
LineReaderImpl Reads a line from the specified input stream, outputs the prompt to System.out.
LoggingListener A JMX NotificationListener for deployment.
SampleHandshakeCompletedListener Demonstrates how to write a HandshakeCompletedListener.
SampleListener Displays any Notification received.
SampleMain Main class demonstrating a variety of MBean API (AMX) usages.
Samples Main class demonstrating a variety of MBean API (AMX) usages.
SampleUtil Utility methods for the samples.
 

Package amxsamples Description

Appserver MBean API (AMX) Sample Guide

Last updated: 25 October 2005

Introduction

This document gives an overview on using the Appserver Management Extensions (AMX) API.  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.

Compile checklist:

  1. JDK 1.5.0 or later is required.
  2. Copy appserv-ext.jar into this directory before running the 'compile-samples' script.  It is found in ${INSTALL_ROOT}/lib.  Alternately, you may modify the compile script to point to this jar in your install (or build) directory.
Run checklist:
  1. Requirements as in Compile checklist above.
  2. Copy javaee.jar into this directory before running the 'run-samples' script.  It is found in ${INSTALL_ROOT}/lib/.  Alternately, you may modify the script to point to this jar in your install (or build) directory.


Running the sample command line

The samples are demonstrated using a simple command-line interface. You can run it as follows:

sh run-samples.sh   (unix)
run.samples.bat     (Windows)

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=samples-truststore
connect.truststorePassword=changeme
connect.useTLS=false

IMPORTANT:  Note that in an Enterprise Edition build, TLS is generally enabled, so useTLS must be true and the trustStore and truststorePassword are required (truststore will be created automatically).  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;  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.