Jadmin
If
you're like
me
and need to administer the components of IBM Workplace
and or
WebSphere but don't enjoy working with
TCL, the default scripting language, then perhaps you will find this
foundation for building Java based Workplace and Websphere utilities
helpful. Jadmin provides a simple mechanism for writing and
invoking WebSphere and Workplace MBeans in Java.
The secret to Jadmin simplicity is that it uses Java interface proxies
to map standard Java calls to the less direct MBean calls. Rather
than being required to call the .invoke() method of the MBean and
supply a method name and array of parameters, with Jadmin you work with
a Java interface that reflects the MBean.
Jadmin 1.1 provides direct support for the Workplace MailService
MBean and WebSphere TraceService MBean but can easily be extended to
work with other MBeans. If
you have an MBean you think should also be included please let me know
and I can add the interface to the distribution. But remember the
intention of Jadmin is to provide a foundation for creating custom
administration scripts not to provide an extensive set of pre-built
scripts
What's
New
1.1 -
Released, Jan 27 2005
- Adds embedded support for WebSphere's TraceService MBean
- Bat files now automatically generated by the build.
- Added new examples: GetTraceSettings and TraceMsgs
Installing
Jadmin
1. Unpack the jadmin zip into the directory of your choice. I
use a directory called jadmin within my AppServer directory.
2. Open a command prompt window and change directories into the jadmin
directory.
3. Make sure the environment variable WAS_HOME is set to point to
(WebSphere or Workplace)/AppServer directory.
4. Edit jadmin.properties and configure the properties as follows
com.developingstorm.jadmin.host=[The host of the
server that contain the MBean: localhost]
com.developingstorm.jadmin.port=[The port of the
server that contains the MBean: 8880 or 8881 or 8882, etc...]
com.developingstorm.jadmin.node=[The name of the
server node: mynode]
com.developingstorm.jadmin.user=[The WebSphere or
Workplace server's administrators user name]
com.developingstorm.jadmin.password=[The
WebSphere or Workplace server's administrators password]
These values will be the defaults used by the utilities
you create. You can override them on the command line by using
the flags: -host ?, -port ?, -node ?,
etc...
Sample Utilities
Jadmin comes with seven sample utilities.
| QueueReport |
Asks the MailService MBean to
generate a report on the contents of the mail queue. |
| ListPending |
Asks the MailService MBean to
list just the list of undelivered messages. |
| StopMailProcessing |
Asks the MailService
MBean to stop the handling and delivery of mail. |
| StartMailProcessing |
Asks the MailService
MBean to start the handling and delivery of mail. |
| MailProcessingStatus |
Asks the MailService
MBean the status of the SMTP server, Mail Handler and Mail Deliverer. |
| GetTraceSettings |
Asks the TraceService MBean for
the current trace settings. |
| TraceMsgs |
Asks the TraceService MBean to
add full tracing for LWP 2.5 MTA related activities. |
Building Jadmin
The sub directory 'project' within the jadmin directory contains the
sources for Jadmin. This also contain an Ant build script for
compiling and jarring the Jadmin classes and for generating the bat
files to run your utilities. You can modify the
existing source and add
new Java files as you need them.
Adding
new Utilities
If you want to create a new utility I suggest copying an existing
sample utility like QueueReport.java or ListPending.java as a starting
point. This will save you the hassle of recreating the
configuration loading and MBean discovery code. Once you have the
MBean proxy instantiated you can call any of the methods it supplies.
Jadmin 1.1 will automatically generate batch files to call any class
withing jadmin.jar that implements the marker interface
com.developingstorm.jadmin.Utility. You no longer need to
explicity call MakeBat like you did with Jadmin 1.0.
Adding
new MBean Proxies
To create a new MBean proxy you will need to get some information on
the methods the MBean supports. You can do this by consulting the
documentation or by introspecting the MBean. Jadmin provides a
utility that does the latter called MBeanReporter. MBeanReporter
will list information about all the MBeans on a server and even
generate a stub Java interface that may be used to call it.
Usage:
MBeanReporter
However you find out about your MBean's interface you will need to
create a Java interface that reflects the MBean methods you want to
call. The methods of the interface must match the exact
name of the MBean methods and the parameters must match the exact order
and types of those passed to the MBean. Jadmin uses interface
proxies to map calls to the interface's methods to the actual 'Invoke'
calls of the MBean. If the name and parameters don't match it
wont be able to map the two correctly.
The last step when adding a new MBean proxy is to create a factory for
it. There is already a factory for the MailService MBean, called
MailServiceFactory, so you can just copy that and modify it to
reference your new interface.