xmlBlaster 2.2.0 API

org.xmlBlaster.util.admin.extern
Class JmxWrapper

java.lang.Object
  extended by org.xmlBlaster.util.admin.extern.JmxWrapper

public class JmxWrapper
extends java.lang.Object

JmxWrapper wraps the MBeanServer instance. Current supported adaptors are a HTTPAdaptor, the XmlBlasterAdaptor and the JDK1.5 jconsole adaptor.

1. xmlBlaster/jmx/HtmlAdaptor true: Start the adaptor for html-browser access
2. xmlBlaster/jmx/XmlBlasterAdaptor true
3a. java -Dcom.sun.management.jmxremote ... Start the JDK 1.5 jconsole adaptor by the java virtual machine
3b. xmlBlaster/jmx/rmi true: Start the JDK 1.5 jconsole adaptor by our own coding

Note for 3b.:
A rmiregistry server is created automatically. If there is running already one, that is used.
You can specify another port or host to create/use a rmiregistry server:

     -xmlBlaster/jmx/rmiregistry/port   Specify a port number where rmiregistry listens.
                         Default is port 1099
     -xmlBlaster/jmx/rmiregistry/hostname Specify a hostname where rmiregistry runs.
                         Default is the dns name of the running host.
 

See Also:
http://java.sun.com/developer/technicalArticles/J2SE/jmx.html, XmlBlasterSecurityManager, The admin.jmx requirement

Field Summary
private  boolean createSecurityManager
           
static int DEFAULT_REGISTRY_PORT
          XmlBlaster RMI registry listen port is 1099, to access for bootstrapping
private  Global glob
           
private  com.sun.jdmk.comm.HtmlAdaptorServer html
           
private  JmxLogLevel jmxLogLevel
           
private  JmxMBeanHandle jmxLogLevelHandle
           
private  JmxProperties jmxProperties
          Export Global.getProperty() to JMX
private  JmxMBeanHandle jmxPropertiesHandle
           
private static java.util.logging.Logger log
           
private  java.util.Map mbeanMap
          We hold an own map for mbeans registered to support renaming.
private  javax.management.MBeanServer mbeanServer
           
private  java.lang.String ME
           
private static JmxWrapper theJmxWrapper
           
private  int useJmx
           
 
Constructor Summary
JmxWrapper(Global glob)
          Constructs an initial JmxWrapper object.
 
Method Summary
private  java.lang.String getAction(java.lang.String s)
           
static JmxWrapper getInstance(Global glob)
          Singleton to avoid that different Global instances create more than one JmxWrapper.
 javax.management.MBeanServer getMBeanServer()
          Create the unique MBeanServer instance.
static java.lang.String getObjectNameLiteral(Global global, ContextNode contextNode)
           
private  java.lang.Object[] getParams(java.util.ArrayList sigs, java.lang.String callArgs)
           
 void init()
          Initialize the MBean server and adaptors.
 java.lang.Object invokeAction(java.lang.String args)
          Invoke xmlBlaster core JMX bean operations and getter/setter.
 java.lang.Object invokeCommand(java.lang.String command)
          Similat to invokeAction but the command does not need to start with "/InvokeAction//", additionally the "set" feature is activated.
 boolean isActivated()
          Check if JMX is activated.
 boolean isRegistered(ContextNode contextNode)
           
 JmxMBeanHandle registerMBean(ContextNode contextNode, java.lang.Object mbean)
          Registers the specified mbean into the mbean server.
private  JmxMBeanHandle registerMBean(ContextNode contextNode, java.lang.Object mbean, JmxMBeanHandle mbeanHandle, boolean isRename)
           
 int renameMBean(java.lang.String oldName, java.lang.String oldRootClassname, ContextNode newRootNode)
          Reorganize the registration for a new parent node.
 int renameMBean(java.lang.String oldName, java.lang.String classNameToChange, java.lang.String instanceName)
          Reorganize the registration for a new parent node.
 void shutdown()
           
private  void startRmiRegistry(java.lang.String registryHost, int registryPort)
          Start xmlBlaster security manager and RMI registry.
 void startXmlBlasterConnector(javax.management.MBeanServer mbeanServer)
          Starts XmlBlasterConnector on mbeanServer-Instance This is a small embedded xmlBlaster server instance which is started.
 void unregisterMBean(JmxMBeanHandle jmxMBeanHandle)
           
 void unregisterMBean(javax.management.ObjectName objectName)
          Unregisters the specified mbean from the mbean server.
static java.lang.String validateJmxValue(java.lang.String value)
          JMX property values may not contain a comma ','.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

glob

private final Global glob

log

private static java.util.logging.Logger log

ME

private final java.lang.String ME

mbeanServer

private javax.management.MBeanServer mbeanServer

html

private com.sun.jdmk.comm.HtmlAdaptorServer html

useJmx

private int useJmx

mbeanMap

private java.util.Map mbeanMap
We hold an own map for mbeans registered to support renaming. The key is the objectName.toString() and the value is the JmxMBeanHandle instance.


jmxProperties

private JmxProperties jmxProperties
Export Global.getProperty() to JMX


jmxPropertiesHandle

private JmxMBeanHandle jmxPropertiesHandle

jmxLogLevel

private JmxLogLevel jmxLogLevel

jmxLogLevelHandle

private JmxMBeanHandle jmxLogLevelHandle

DEFAULT_REGISTRY_PORT

public static final int DEFAULT_REGISTRY_PORT
XmlBlaster RMI registry listen port is 1099, to access for bootstrapping

See Also:
Constant Field Values

theJmxWrapper

private static JmxWrapper theJmxWrapper

createSecurityManager

private boolean createSecurityManager
Constructor Detail

JmxWrapper

public JmxWrapper(Global glob)
           throws XmlBlasterException
Constructs an initial JmxWrapper object.

Throws:
XmlBlasterException
Method Detail

getInstance

public static JmxWrapper getInstance(Global glob)
                              throws XmlBlasterException
Singleton to avoid that different Global instances create more than one JmxWrapper.

Throws:
XmlBlasterException

isActivated

public boolean isActivated()
Check if JMX is activated.

Returns:
true if JMX is in use

getMBeanServer

public javax.management.MBeanServer getMBeanServer()
Create the unique MBeanServer instance.


validateJmxValue

public static java.lang.String validateJmxValue(java.lang.String value)
JMX property values may not contain a comma ','. Here we replace commas with an underscore. Even if we use quoted ObjectName values the comma is not allowed.
Additionally we replace '/' as these would break the admin telnet commands syntax, it is nice to be able to use those interchangeable

Parameters:
value - The value to verify
Returns:
The beautified value to be usable as a value for JMX properties

init

public void init()
          throws XmlBlasterException
Initialize the MBean server and adaptors.

Throws:
XmlBlasterException

startRmiRegistry

private void startRmiRegistry(java.lang.String registryHost,
                              int registryPort)
                       throws XmlBlasterException
Start xmlBlaster security manager and RMI registry.

Parameters:
registryPort - xmlBlaster/jmx/rmiregistry/port=1099
registryHost - xmlBlaster/jmx/rmiregistry/hostname=loclhost
Throws:
XmlBlasterException

renameMBean

public int renameMBean(java.lang.String oldName,
                       java.lang.String oldRootClassname,
                       ContextNode newRootNode)
Reorganize the registration for a new parent node. Newer variant

Parameters:
oldName - The existing registry, is used to lookup all matching sub-entries. For example "org.xmlBlaster:nodeClass=node,node=clientSUB1"
oldRootClassname - The existing parent node like "org.xmlBlaster:nodeClass=node,node=clientjoe1" Note: Instance names may not contain commas "," for example "joe,Smith" is not valid
Returns:
The resulting registration like "org.xmlBlaster:nodeClass=node,node=heron,clientClass=connection,connection=jack,queueClass=queue,queue=connection-99"

renameMBean

public int renameMBean(java.lang.String oldName,
                       java.lang.String classNameToChange,
                       java.lang.String instanceName)
Reorganize the registration for a new parent node. Can we set this to deprecated?

Parameters:
oldName - The existing registry, is used to lookup all matching sub-entries. For example "org.xmlBlaster:nodeClass=node,node=clientSUB1"
newNodeClass - The new parent node like "org.xmlBlaster:nodeClass=node,node=heron" Note: Instance names may not contain commas "," for example "joe,Smith" is not valid
Returns:
The resulting registration like "org.xmlBlaster:nodeClass=node,node=heron,clientClass=connection,connection=jack,queueClass=queue,queue=connection-99"

registerMBean

public JmxMBeanHandle registerMBean(ContextNode contextNode,
                                    java.lang.Object mbean)
Registers the specified mbean into the mbean server. A typical registration string is org.xmlBlaster:nodeClass=node,node="heron",clientClass=client,client="joe",queueClass=queue,queue="subject665",entryClass=entry,entry="1002" which doesn't conform to the ObjectName recommendation as it does not contains the 'type=...' property. We have chosen this as it creates a nice hierarchy in the jconsole GUI tool.

Parameters:
contextNode - The unique name for JMX observation Note: Instance names may not contain commas "," for example "joe,Smith" is not valid
mbean - the MBean object instance If mbean implements MBeanRegistration:preRegister() we don't need the type, name
Returns:
The JmxMBeanHandle with object name used to register or null on error Note: You may not take a clone of it as we may change attributes of this instance during renaming operations.

getObjectNameLiteral

public static java.lang.String getObjectNameLiteral(Global global,
                                                    ContextNode contextNode)

registerMBean

private JmxMBeanHandle registerMBean(ContextNode contextNode,
                                     java.lang.Object mbean,
                                     JmxMBeanHandle mbeanHandle,
                                     boolean isRename)

invokeCommand

public java.lang.Object invokeCommand(java.lang.String command)
Similat to invokeAction but the command does not need to start with "/InvokeAction//", additionally the "set" feature is activated.

Parameters:
command - for example "org.xmlBlaster:nodeClass=node,node="heron"/action=getFreeMemStr"
Returns:
The methods return value
See Also:
invokeAction(String)

invokeAction

public java.lang.Object invokeAction(java.lang.String args)
Invoke xmlBlaster core JMX bean operations and getter/setter. To invoke getter/seeter you need to start with
java -Djmx.invoke.getters=set ... org.xmlBlaster.Main

Parameters:
args - could be somethig like: '/InvokeAction//org.xmlBlaster:nodeClass=node,node="izar",contribClass=contrib,contrib="Heini" /action=myNiceMethodName?action=myNiceMethodName&p1+java.lang.String=arg1&p2+java.lang.String=arg1' or 'org.xmlBlaster:nodeClass=node,node="heron",topicClass=topic,topic="watchDog"/action=getNumOfHistoryEntries' or 'org.xmlBlaster:nodeClass=node,node="heron",topicClass=topic,topic="watchDog"/action=usage' or 'j org.xmlBlaster:nodeClass=node,node="heron",topicClass=topic,topic="watchDog"/action=peekHistoryMessages?p1+int=1 or much simpler (will return the usage() string): org.xmlBlaster:nodeClass=node,node="heron"/action=usage

unregisterMBean

public void unregisterMBean(javax.management.ObjectName objectName)
Unregisters the specified mbean from the mbean server.

Parameters:
objectName - The object you got from registerMBean() of type ObjectName, if null nothing happens

unregisterMBean

public void unregisterMBean(JmxMBeanHandle jmxMBeanHandle)

startXmlBlasterConnector

public void startXmlBlasterConnector(javax.management.MBeanServer mbeanServer)
                              throws XmlBlasterException
Starts XmlBlasterConnector on mbeanServer-Instance This is a small embedded xmlBlaster server instance which is started. You can than access this adaptor using the SWING GUI "java org.xmlBlaster.jmxgui.Main"

Throws:
XmlBlasterException

shutdown

public void shutdown()

getAction

private final java.lang.String getAction(java.lang.String s)

getParams

private java.lang.Object[] getParams(java.util.ArrayList sigs,
                                     java.lang.String callArgs)

isRegistered

public boolean isRegistered(ContextNode contextNode)
                     throws XmlBlasterException
Throws:
XmlBlasterException

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.