Top Description Fields Constructors Methods
org.eclipse.jetty.jmx

public Class MBeanContainer

extends Object
implements InheritedListener, Dumpable, Destroyable
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener, java.util.EventListener
Annotations
@ManagedObject:The component that registers beans as MBeans
Imports
java.io.IOException, java.lang.reflect.Constructor, java.util.Arrays, .Collections, .List, .Locale, .Map, .Objects, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.concurrent.atomic.AtomicInteger, java.util.stream.Collectors, javax.management.DynamicMBean, .InstanceNotFoundException, .MBeanInfo, .MBeanRegistrationException, .MBeanServer, .MXBean, .ObjectName, javax.management.modelmbean.ModelMBean, org.eclipse.jetty.util.Loader, .StringUtil, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.eclipse.jetty.util.component.Container, .ContainerLifeCycle, .Destroyable, .Dumpable, org.slf4j.Logger, .LoggerFactory

Container class for the MBean instances

Field Summary

Modifier and TypeField and Description
private 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

AccessConstructor and Description
public
MBeanContainer(MBeanServer
instance of MBeanServer for use by container
server
)

Constructs MBeanContainer

public
MBeanContainer(MBeanServer
instance of MBeanServer for use by container
server
,
boolean
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.
cacheOtherClassLoaders
)

Constructs MBeanContainer

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.

public String
public Object

Returns:

instance associated with specified object name, or null if not found
findBean
(ObjectName
object name of instance
objectName
)

Lookup an instance by object name

private static Constructor<?>
public ObjectName

Returns:

object name associated with specified instance, or null if not found
findMBean
(Object
instance for which object name is looked up
object
)

Lookup an object name by instance

pack-priv static MetaData
findMetaData(MBeanContainer container, Class<?> klass)

public String

Returns:

domain name
getDomain
()

Retrieve domain name used to add MBeans

public MBeanServer

Returns:

instance of MBeanServer
getMBeanServer
()

Retrieve instance of MBeanServer used by container

private static MetaData
getMetaData(MBeanContainer container, Class<?> klass)

public boolean
public String
makeName(String
name to strip of special characters.
basis
)

Returns: normalized name

public Object

Returns:

A new instance of an MBean for the object or null.
mbeanFor
(Object
The object
o
)

Creates an ObjectMBean for the given object.

pack-priv static Object
private static MetaData
newMetaData(MBeanContainer container, Class<?> klass)

private String
reflectBasis(Object mbean, String methodName)

private String
private String
public void
setDomain(String
domain name
domain
)

Set domain to be used to add MBeans

private void
unregister(ObjectName objectName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__uniqueback to summary
private static final ConcurrentMap<String, AtomicInteger> __unique
_beansback to summary
private final ConcurrentMap<Object, Container> _beans
_domainback to summary
private String _domain
_mbeansback to summary
private final ConcurrentMap<Object, ObjectName> _mbeans
_mbeanServerback to summary
private final MBeanServer _mbeanServer
_metaDataback to summary
private final ConcurrentMap<Class<?>, MetaData> _metaData
_useCacheForOtherClassLoadersback to summary
private final boolean _useCacheForOtherClassLoaders
LOGback to summary
private static final Logger LOG
ROOTback to summary
private static final Container ROOT

Constructor Detail

MBeanContainerback to summary
public MBeanContainer(MBeanServer server)

Constructs MBeanContainer

Parameters
server:MBeanServer

instance of MBeanServer for use by container

MBeanContainerback to summary
public MBeanContainer(MBeanServer server, boolean cacheOtherClassLoaders)

Constructs MBeanContainer

Parameters
server:MBeanServer

instance of MBeanServer for use by container

cacheOtherClassLoaders:boolean

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 Detail

beanAddedback to summary
public void beanAdded(Container parent, Object obj)

Implements org.eclipse.jetty.util.component.Container.Listener.beanAdded.

Annotations
@Override
beanRemovedback to summary
public void beanRemoved(Container parent, Object obj)

Implements org.eclipse.jetty.util.component.Container.Listener.beanRemoved.

Annotations
@Override
destroyback to summary
public void destroy()

Implements org.eclipse.jetty.util.component.Destroyable.destroy.

Annotations
@Override
dumpback to summary
public void dump(Appendable out, String indent) throws IOException

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Doc from org.eclipse.jetty.util.component.Dumpable.dump.

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.

Parameters
out:Appendable

The appendable to dump to

indent:String

The indent to apply after any new lines.

Annotations
@Override
Exceptions
IOException:
if unable to write to Appendable
dumpback to summary
public String dump()

Overrides default org.eclipse.jetty.util.component.Dumpable.dump.

Annotations
@Override
findBeanback to summary
public Object findBean(ObjectName objectName)

Lookup an instance by object name

Parameters
objectName:ObjectName

object name of instance

Returns:Object

instance associated with specified object name, or null if not found

findConstructorback to summary
private static Constructor<?> findConstructor(Class<?> klass)
findMBeanback to summary
public ObjectName findMBean(Object object)

Lookup an object name by instance

Parameters
object:Object

instance for which object name is looked up

Returns:ObjectName

object name associated with specified instance, or null if not found

findMetaDataback to summary
pack-priv static MetaData findMetaData(MBeanContainer container, Class<?> klass)
getDomainback to summary
public String getDomain()

Retrieve domain name used to add MBeans

Returns:String

domain name

Annotations
@ManagedAttribute:The default ObjectName domain
getMBeanServerback to summary
public MBeanServer getMBeanServer()

Retrieve instance of MBeanServer used by container

Returns:MBeanServer

instance of MBeanServer

getMetaDataback to summary
private static MetaData getMetaData(MBeanContainer container, Class<?> klass)
isUseCacheForOtherClassLoadersback to summary
public boolean isUseCacheForOtherClassLoaders()
Annotations
@ManagedAttribute:Whether to use the cache for MBeans loaded by other ClassLoaders
readonly:true
makeNameback to summary
public String makeName(String basis)
Parameters
basis:String

name to strip of special characters.

Returns:String

normalized name

mbeanForback to summary
public Object mbeanFor(Object o)

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:Object

The object

Returns:Object

A new instance of an MBean for the object or null.

mbeanForback to summary
pack-priv static Object mbeanFor(MBeanContainer container, Object o)
newMetaDataback to summary
private static MetaData newMetaData(MBeanContainer container, Class<?> klass)
reflectBasisback to summary
private String reflectBasis(Object mbean, String methodName)
reflectContextBasisback to summary
private String reflectContextBasis(Object mbean)
reflectNameBasisback to summary
private String reflectNameBasis(Object mbean)
setDomainback to summary
public void setDomain(String domain)

Set domain to be used to add MBeans

Parameters
domain:String

domain name

unregisterback to summary
private void unregister(ObjectName objectName)