Package org.eclipse.jetty.jmx
Class MBeanContainer
java.lang.Object
org.eclipse.jetty.jmx.MBeanContainer
- All Implemented Interfaces:
Container.InheritedListener
,Container.Listener
,Destroyable
,Dumpable
@ManagedObject("The component that registers beans as MBeans")
public class MBeanContainer
extends Object
implements Container.InheritedListener, Dumpable, Destroyable
Container class for the MBean instances
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ConcurrentMap
<String, AtomicInteger> private final ConcurrentMap
<Object, Container> private String
private final ConcurrentMap
<Object, ObjectName> private final MBeanServer
private final ConcurrentMap
<Class, MetaData> private final boolean
private static final Logger
private static final Container
-
Constructor Summary
ConstructorsConstructorDescriptionMBeanContainer
(MBeanServer server) Constructs MBeanContainerMBeanContainer
(MBeanServer server, boolean cacheOtherClassLoaders) Constructs MBeanContainer -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
beanRemoved
(Container parent, Object obj) void
destroy()
dump()
void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.findBean
(ObjectName objectName) Lookup an instance by object nameprivate static Constructor
<?> findConstructor
(Class<?> klass) Lookup an object name by instance(package private) static MetaData
findMetaData
(MBeanContainer container, Class<?> klass) Retrieve domain name used to add MBeansRetrieve instance of MBeanServer used by containerprivate static MetaData
getMetaData
(MBeanContainer container, Class<?> klass) boolean
Creates an ObjectMBean for the given object.(package private) static Object
mbeanFor
(MBeanContainer container, Object o) private static MetaData
newMetaData
(MBeanContainer container, Class<?> klass) void
Set domain to be used to add MBeansprivate void
unregister
(ObjectName objectName)
-
Field Details
-
LOG
-
__unique
-
ROOT
-
_mbeanServer
-
_useCacheForOtherClassLoaders
private final boolean _useCacheForOtherClassLoaders -
_metaData
-
_beans
-
_mbeans
-
_domain
-
-
Constructor Details
-
MBeanContainer
Constructs MBeanContainer- Parameters:
server
- instance of MBeanServer for use by container
-
MBeanContainer
Constructs MBeanContainer- Parameters:
server
- instance of MBeanServer for use by containercacheOtherClassLoaders
- If true, MBeans from other classloaders (eg WebAppClassLoader) will be cached. The cache is never flushed, so this should be false if some classloaders do not live forever.
-
-
Method Details
-
getMBeanServer
Retrieve instance of MBeanServer used by container- Returns:
- instance of MBeanServer
-
isUseCacheForOtherClassLoaders
@ManagedAttribute(value="Whether to use the cache for MBeans loaded by other ClassLoaders", readonly=true) public boolean isUseCacheForOtherClassLoaders() -
setDomain
Set domain to be used to add MBeans- Parameters:
domain
- domain name
-
getDomain
Retrieve domain name used to add MBeans- Returns:
- domain name
-
mbeanFor
Creates an ObjectMBean for the given object.
Attempts to create an ObjectMBean for the object by searching the package and class name space. For example an object of the type:
class com.acme.MyClass extends com.acme.util.BaseClass implements com.acme.Iface
then this method would look for the following classes:
- com.acme.jmx.MyClassMBean
- com.acme.util.jmx.BaseClassMBean
- org.eclipse.jetty.jmx.ObjectMBean
- Parameters:
o
- The object- Returns:
- A new instance of an MBean for the object or null.
-
mbeanFor
-
findMetaData
-
getMetaData
-
newMetaData
-
findConstructor
-
findMBean
Lookup an object name by instance- Parameters:
object
- instance for which object name is looked up- Returns:
- object name associated with specified instance, or null if not found
-
findBean
Lookup an instance by object name- Parameters:
objectName
- object name of instance- Returns:
- instance associated with specified object name, or null if not found
-
beanAdded
- Specified by:
beanAdded
in interfaceContainer.Listener
-
beanRemoved
- Specified by:
beanRemoved
in interfaceContainer.Listener
-
makeName
- Parameters:
basis
- name to strip of special characters.- Returns:
- normalized name
-
dump
Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dump
in interfaceDumpable
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-
dump
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDestroyable
-
unregister
-