Package org.apache.commons.modeler
Class JndiJmx
- java.lang.Object
-
- org.apache.commons.modeler.BaseModelMBean
-
- org.apache.commons.modeler.JndiJmx
-
- All Implemented Interfaces:
java.util.EventListener
,javax.management.DynamicMBean
,javax.management.MBeanRegistration
,javax.management.modelmbean.ModelMBean
,javax.management.modelmbean.ModelMBeanNotificationBroadcaster
,javax.management.NotificationBroadcaster
,javax.management.NotificationListener
,javax.management.PersistentMBean
public class JndiJmx extends BaseModelMBean implements javax.management.NotificationListener
Link between JNDI and JMX. JNDI can be used for persistence ( it is an API for storing hierarchical data and a perfect fit for that ), as well as an alternate view of the MBean registry. If this component is enabled, all MBeans will be registered in JNDI, and all attributes that are set via JMX can be stored in a DirContext. This acts as a "recorder" for creation of mbeans and attribute changes done via JMX. XXX How can we control ( filter ) which mbeans will be registere ? Or attributes ? XXX How can we get the beans and attributes loaded before jndijmx ? The intended use: - do whatever you want to start the application - load JndiJmx as an mbean - make changes via JMX. All changes are recorded - you can use JndiJmx to save the changes in a Jndi context. - you can use JndiJmx to load changes from a JndiContext and replay them. The main benefit is that only changed attributes are saved, and the Jndi layer can preserve most of the original structure of the config file. The alternative is to override the config files with config info extracted from the live objects - but it's very hard to save only what was actually changed and preserve structure and comments.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.modeler.BaseModelMBean
BaseModelMBean.MethodKey
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.Hashtable
attributes
protected javax.naming.Context
componentContext
protected javax.naming.Context
configContext
protected javax.naming.Context
descriptorContext
(package private) java.util.Hashtable
instances
private static org.apache.commons.logging.Log
log
(package private) javax.management.MBeanServer
mserver
-
Fields inherited from class org.apache.commons.modeler.BaseModelMBean
attributeBroadcaster, generalBroadcaster, info, NO_ARGS_PARAM, NO_ARGS_PARAM_SIG, oname, registry, resource, resourceType, source
-
-
Constructor Summary
Constructors Constructor Description JndiJmx()
Protected constructor to require use of the factory create method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
dumpStatus()
void
handleNotification(javax.management.Notification notification, java.lang.Object handback)
void
init()
void
replay()
void
setComponentContext(javax.naming.Context ctx)
If a JNDI context is set, all components will be registered in the context.void
setConfigContext(javax.naming.Context ctx)
JNDI context where attributes will be stored for persistencevoid
setDescriptorContext(javax.naming.Context ctx)
JNDI context for component descriptors ( metadata ).-
Methods inherited from class org.apache.commons.modeler.BaseModelMBean
addAttributeChangeNotificationListener, addNotificationListener, createDefaultModelMBeanInfo, createResource, getAttribute, getAttributes, getClassName, getJmxName, getManagedResource, getMBeanInfo, getModelerType, getNotificationInfo, getObjectName, getRegistry, initModelInfo, invoke, isModelMBeanInfoValid, load, postDeregister, postRegister, preDeregister, preRegister, removeAttributeChangeNotificationListener, removeAttributeChangeNotificationListener, removeNotificationListener, removeNotificationListener, removeNotificationListener, sendAttributeChangeNotification, sendAttributeChangeNotification, sendNotification, sendNotification, setAttribute, setAttributes, setManagedResource, setModeledType, setModelMBeanInfo, setRegistry, store, toString
-
-
-
-
Field Detail
-
log
private static org.apache.commons.logging.Log log
-
componentContext
protected javax.naming.Context componentContext
-
descriptorContext
protected javax.naming.Context descriptorContext
-
configContext
protected javax.naming.Context configContext
-
mserver
javax.management.MBeanServer mserver
-
attributes
java.util.Hashtable attributes
-
instances
java.util.Hashtable instances
-
-
Method Detail
-
setComponentContext
public void setComponentContext(javax.naming.Context ctx)
If a JNDI context is set, all components will be registered in the context.- Parameters:
ctx
-
-
setDescriptorContext
public void setDescriptorContext(javax.naming.Context ctx)
JNDI context for component descriptors ( metadata ).- Parameters:
ctx
-
-
setConfigContext
public void setConfigContext(javax.naming.Context ctx)
JNDI context where attributes will be stored for persistence
-
handleNotification
public void handleNotification(javax.management.Notification notification, java.lang.Object handback)
- Specified by:
handleNotification
in interfacejavax.management.NotificationListener
-
dumpStatus
public java.lang.String dumpStatus() throws java.lang.Exception
- Throws:
java.lang.Exception
-
replay
public void replay() throws java.lang.Exception
- Throws:
java.lang.Exception
-
init
public void init() throws java.lang.Exception
- Throws:
java.lang.Exception
-
-