Package org.javasimon.jmx

JMX capabilities for Simons.

See:
          Description

Interface Summary
CounterMXBean Interface for MX Bean representing a particular Counter.
SimonManagerMXBean Interface of Simon management bean (MXBean) representing single point of access to a particular Simon Manager.
SimonSuperMXBean Interface with common methods for JMX beans for a signle Simon that corresponds to AbstractSimon in the core package.
StopwatchMXBean Interface for MX Bean representing a particular Stopwatch.
 

Class Summary
AbstractSimonMXBeanImpl Common functionality for JMX bean for a signle Simon that corresponds to AbstractSimon in the core package.
CounterMXBeanImpl MX Bean representing a particular Counter.
CounterSample Value object for retrieving data from Counter Simon.
JmxRegisterCallback Callback that registers MXBeans for Simons after their creation.
SimonInfo Value object for retrieving Simon name and type info via Simon MXBean (SimonManagerMXBean).
SimonManagerMXBeanImpl Simon MXBean implementation.
StopwatchMXBeanImpl MX Bean representing a particular Stopwatch.
StopwatchSample Value object for retrieving data from Stopwatch Simon.
 

Package org.javasimon.jmx Description

JMX capabilities for Simons. Package provides two ways of working with Simons via JMX:

Simon MBean (SimonManagerMXBean) implements jmx support for core functionality, it means firstly management of java Simons during runtime and secondly, very requested, way how to get gathered data by Simons out of application (jvm) for aditional processing.

From management point of view it provides similar functionality like Manager, but this functionality is accessible remotely. Management features are:

For retrieving data from Simons is used new feature: return custom object from MBean's method. This is one of news in JMX 1.4 introduced with Java 6. Compared to calling many getters on an MBean custom object as a return value has following advantages: there is only a single call (faster - especially in case of a remote call) and all data is consistent (from one moment) which makes it better for graphing, logging, etc.

Technically, there are two methods, each for one Simon type, SimonManagerMXBean#getCounterSample(String) for retrieving data from Counter Simon and SimonManagerMXBean#getStopwatchSample(String) for retrieving data from Stopwatch Simon. Returned value object is basically Sample object for each type of Simon as is known from core package. Each sample has all needed access methods of its Simon. Parameter for retrieving methods is Simon hierarchical name. To know all existing Simons and its type, use SimonManagerMXBean#getSimonInfos().

Both MBean needs to be registered first. Snippet bellow registers the Simon MBean:

MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
        ObjectName name = new ObjectName("org.javasimon.jmx.example:type=Simon");
        if (mbs.isRegistered(name)) {
                mbs.unregisterMBean(name);
        }
        SimonManagerMXBean simon = new SimonManagerMXBeanImpl(SimonManager.manager());
        mbs.registerMBean(simon, name);
        System.out.println("SimonManagerMXBean registerd under name: "+name);
} catch (JMException e) {
        System.out.println("SimonManagerMXBean registration failed!\n"+e);
}
 
Following code then unregisters the MBean.
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
        ObjectName name = new ObjectName("org.javasimon.jmx.example:type=Simon");
        if (mbs.isRegistered(name)) {
                mbs.unregisterMBean(name);
        }
        System.out.println("SimonManagerMXBean was unregisterd");
} catch (JMException e) {
        System.out.println("SimonManagerMXBean unregistration failed!\n"+e);
}
 
Java Simon doesn't provide any automatic mechanism or util functions to register or unregister Simon MBean becouse there are simply too many things which could be customized. It is programmer's responsibility to properly register and later unregister MBean from MBean server.



Copyright © 2013. All Rights Reserved.