Class MbeansSource
- java.lang.Object
-
- org.apache.commons.modeler.modules.ModelerSource
-
- org.apache.commons.modeler.modules.MbeansSource
-
- All Implemented Interfaces:
MbeansSourceMBean
public class MbeansSource extends ModelerSource implements MbeansSourceMBean
This will create mbeans based on a config file. The format is an extended version of MLET. Classloading. We don't support any explicit classloader tag. A ClassLoader is just an mbean ( it can be the standard MLetMBean or a custom one ). XXX add a special attribute to reference the loader mbean, XXX figure out how to deal with private loaders
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
MbeansSource.ArgsInfo
-
Field Summary
Fields Modifier and Type Field Description private org.w3c.dom.Document
document
(package private) long
lastUpdate
(package private) static boolean
loaderLoaded
(package private) boolean
loading
private static org.apache.commons.logging.Log
log
(package private) java.util.List
mbeans
private java.util.HashMap
object2Node
(package private) Registry
registry
(package private) java.lang.String
type
(package private) long
updateInterval
-
Fields inherited from class org.apache.commons.modeler.modules.ModelerSource
location, source
-
-
Constructor Summary
Constructors Constructor Description MbeansSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
void
execute()
java.lang.String
getLocation()
java.util.List
getMBeans()
Return the list of mbeans created by this source.java.lang.Object
getSource()
void
init()
Call the init method on all mbeans.void
load()
Load the mbeans from the source.java.util.List
loadDescriptors(Registry registry, java.lang.String location, java.lang.String type, java.lang.Object source)
Load data, returns a list of items.private MbeansSource.ArgsInfo
processArg(org.w3c.dom.Node mbeanN)
private void
processAttribute(javax.management.MBeanServer server, org.w3c.dom.Node descN, java.lang.String objectName)
void
save()
Store the mbeans.void
setLocation(java.lang.String loc)
void
setRegistry(Registry reg)
void
setSource(java.lang.Object source)
Set the source to be used to load the mbeansvoid
setType(java.lang.String type)
Used if a single component is loadedvoid
start()
void
stop()
void
updateField(javax.management.ObjectName oname, java.lang.String name, java.lang.Object value)
Callback from the BaseMBean to notify that an attribute has changed.-
Methods inherited from class org.apache.commons.modeler.modules.ModelerSource
getInputStream, store
-
-
-
-
Field Detail
-
log
private static org.apache.commons.logging.Log log
-
registry
Registry registry
-
type
java.lang.String type
-
loading
boolean loading
-
mbeans
java.util.List mbeans
-
loaderLoaded
static boolean loaderLoaded
-
document
private org.w3c.dom.Document document
-
object2Node
private java.util.HashMap object2Node
-
lastUpdate
long lastUpdate
-
updateInterval
long updateInterval
-
-
Method Detail
-
setRegistry
public void setRegistry(Registry reg)
-
setLocation
public void setLocation(java.lang.String loc)
-
setType
public void setType(java.lang.String type)
Used if a single component is loaded- Parameters:
type
-
-
setSource
public void setSource(java.lang.Object source)
Description copied from interface:MbeansSourceMBean
Set the source to be used to load the mbeans- Specified by:
setSource
in interfaceMbeansSourceMBean
- Parameters:
source
- File or URL
-
getSource
public java.lang.Object getSource()
- Specified by:
getSource
in interfaceMbeansSourceMBean
-
getLocation
public java.lang.String getLocation()
-
getMBeans
public java.util.List getMBeans()
Return the list of mbeans created by this source. It can be used to implement runtime services.- Specified by:
getMBeans
in interfaceMbeansSourceMBean
- Returns:
- List of ObjectName
-
loadDescriptors
public java.util.List loadDescriptors(Registry registry, java.lang.String location, java.lang.String type, java.lang.Object source) throws java.lang.Exception
Description copied from class:ModelerSource
Load data, returns a list of items.- Overrides:
loadDescriptors
in classModelerSource
source
- Introspected object or some other source- Throws:
java.lang.Exception
-
start
public void start() throws java.lang.Exception
- Throws:
java.lang.Exception
-
stop
public void stop() throws java.lang.Exception
- Throws:
java.lang.Exception
-
init
public void init() throws java.lang.Exception
Description copied from interface:MbeansSourceMBean
Call the init method on all mbeans. Will call load if not done already- Specified by:
init
in interfaceMbeansSourceMBean
- Throws:
java.lang.Exception
-
destroy
public void destroy() throws java.lang.Exception
- Throws:
java.lang.Exception
-
load
public void load() throws java.lang.Exception
Description copied from interface:MbeansSourceMBean
Load the mbeans from the source. Called automatically on init()- Specified by:
load
in interfaceMbeansSourceMBean
- Throws:
java.lang.Exception
-
execute
public void execute() throws java.lang.Exception
- Throws:
java.lang.Exception
-
updateField
public void updateField(javax.management.ObjectName oname, java.lang.String name, java.lang.Object value)
Description copied from class:ModelerSource
Callback from the BaseMBean to notify that an attribute has changed. Can be used to implement persistence.- Overrides:
updateField
in classModelerSource
-
save
public void save()
Store the mbeans. XXX add a background thread to store it periodically- Specified by:
save
in interfaceMbeansSourceMBean
-
processAttribute
private void processAttribute(javax.management.MBeanServer server, org.w3c.dom.Node descN, java.lang.String objectName)
-
processArg
private MbeansSource.ArgsInfo processArg(org.w3c.dom.Node mbeanN)
-
-