Hi Geeks

I recenlty take the job to create a GUI for the jBoss Administration
trough JMX-RMI Adaptor. Now I will first explain my proposal and
afterwards (for the people who do not now JMX) explain JMX and
the JMX-RMI Adaptor. But first lets go to my proposal:

EJX GUI to administrate jBoss through JMX-RMI Adaptor
========================================

Through the JMX-RMI Adaptor a client program can access the service
of jBoss and thus change the attributes of the services and execute
operations on the services (like you can call the "stop" operation to stop
this particular service -> org.jboss.jmx.client.Stop.java).

- Within EJX I would create a Panel containing a vertical SplitPanel
- The left hand side of the SplitPanel contains a list of the found services
  within jBoss. The query has to be performed in order to get the list
  of services (or through properties the program can also during startup
  perform a certain query).
- The list is a Tree where I would suggest the following hirarchy
    - 1. jBoss Application
    - 2. Domains of services
    - 3. Services within its domain
    - 4. Attributes or Operations
- The right hand side gives a more detailed with of the selected item within
  the list (like infos about the attribute (is type, read only or writable,
...) or
  a list of the parameters of the operation)
- The user can changes the attributes if they are writable
- The user can invoke an operation with a list of paramters he/she can enter
  in a dialog
- The user can record and replay maintenace steps to ease repeative work

This week I will create a simple GUI with the Tree and the simple detail
panels
on the right hand side. But if you have already some comments or critiques
please let me know because then I can save time.

2. Short introduction to JMX and our JMX-RMI Adaptor
=======================================

This is a short introduction to JMX for all of you who do not know JMX and
for me a way to see if I understand it (when I am wrong please correct me).

JMX is an architecture to make parts of an application or system manageable
from the outside of the application/system even when it is part of it. And
if the
user likes he/she can replace the management tool by another one like SNMP
(Simple network management protocol) client. This gives the user the
possiblity
to manage their environment in one tools (if desired) instead of learning
all the
different tools to manage all your applications.

JMX architecture are divided roughly in five parts:
1) Manage(able) Beans (or short MBeans)
2) Manage Bean Server (or short MBeanServer)
3) Adaptor
4) Connector Server
3) Client

The client is seperated into two parts:
1) Connector Client
2) Management program

If a Java class becomes a MBean it can be managed from the outside. It
provides
the MBeanServer with the necessary information about itself:
- Service, Class etc.
- All attributes it will expose to the outside
- All operations it will expose to the outside
The MBeanServer collects the MBeans together and is the visible part to the
outside
world. The MBeanServer itself is a MBean also manageable by the client.

The Adaptor is a view for the MBeans to a given protocol. This protocol can
be
HTML or like in our case RMI. The Adaptor is part of the
The Connector is an interface which allows the client to work the same way
on
different protocols. Therefore it is necessary to have an Connection on
Server and
Client side.

For jBoss the outside view is the
    org.jboss.jmx.interface.JMXAdaptor
which is our RMI Adaptor supporting the RMI protocol. It allows a Java class
running
in a different JVM to access the jBoss services (MBeans) and manipulate
their attributes
and invoke operations on them.

Here is now an example Java class printing all the available services, its
attributes and
operations. When you want to run it do the following:
- add /lib/jmxri.jar, /lib/ext/jboss.jar,/lib/ext.jar and your local
directory to the classpath
- add /client/stop.jar to your classpath (it needs JMXAdaptor.class and
JMXAdaptorImpl_Stub.class)
- copy jndi.properties from /conf to your local directory
- compile this class
- add /client/jnp-client.jar to the classpath (!!)
- start jBoss if not already done (wait till it is completely loaded)
- let it run

Here is now the Java class (have
fun): -------------------------------------------
/*
 * jBoss, the OpenSource EJB server
 *
 * Distributable under GPL license.
 * See terms of license at gnu.org.
 */

import java.util.Collection;
import java.util.Iterator;

import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.ObjectInstance;
import javax.naming.InitialContext;

import org.jboss.jmx.interfaces.JMXAdaptor;

/**
 *   <description>
 *
 *   @see <related>
 *   @author Andreas "Mad" Schaefer ([EMAIL PROTECTED])
 */
public class TestJmxClient
{
   // Constants -----------------------------------------------------

   // Attributes ----------------------------------------------------

   // Static --------------------------------------------------------
 public static void main(String[] args)
  throws Exception
 {
  System.out.println( "Testing JMX connection to server" );
  new TestJmxClient().listServices();
  System.out.println( "Testing JMX connection to server finished" );
 }

   // Constructors --------------------------------------------------

   // Public --------------------------------------------------------
   public void listServices()
  throws Exception
   {
    JMXAdaptor server = (JMXAdaptor) new InitialContext().lookup( "jmx" );
  try
  {
   Iterator i = server.getMBeanInfos().iterator();
   while( i.hasNext() ) {
    MBeanInfo info = (MBeanInfo) i.next();
    System.out.println( "MBean: " + info.getClassName() );
    MBeanAttributeInfo[] aInfos = info.getAttributes();
    for( int k = 0; k < aInfos.length; k++ ) {
     System.out.println( "\t" + k + ". Attribute: " +
aInfos[ k ].getName() );
    }
    MBeanOperationInfo[] oInfos = info.getOperations();
    for( int k = 0; k < oInfos.length; k++ ) {
     System.out.println( "\t" + k + ". Operation: " +
oInfos[ k ].getName() );
    }
   }
  } catch (Exception e)
  {
   System.err.println( e );
  }
   }

   // Protected -----------------------------------------------------
}

Bye-bye

Andy "Mad" Schaefer





Reply via email to