Package org.apache.tomcat.util.modeler
Class NoDescriptorRegistry
- java.lang.Object
-
- org.apache.tomcat.util.modeler.Registry
-
- org.apache.tomcat.util.modeler.NoDescriptorRegistry
-
- All Implemented Interfaces:
javax.management.MBeanRegistration,RegistryMBean
public class NoDescriptorRegistry extends Registry
An implementation of the MBean registry that effectively disables MBean registration. This is typically used when low memory footprint is a primary concern.
-
-
Constructor Summary
Constructors Constructor Description NoDescriptorRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddManagedBean(ManagedBean bean)Add a new bean metadata to the set of beans known to this registry.ManagedBeanfindManagedBean(java.lang.Object bean, java.lang.Class<?> beanClass, java.lang.String type)Find or load metadata.ManagedBeanfindManagedBean(java.lang.String name)Find and return the managed bean definition for the specified bean name, if any; otherwise returnnull.intgetId(java.lang.String domain, java.lang.String name)Return an int ID for faster access.javax.management.MBeanServergetMBeanServer()Factory method to create (if necessary) and return ourMBeanServerinstance.javax.management.MBeanOperationInfogetMethodInfo(javax.management.ObjectName oname, java.lang.String opName)Find the operation info for a methodjava.lang.StringgetType(javax.management.ObjectName oname, java.lang.String attName)Get the type of an attribute of the object, from the metadata.voidinvoke(java.util.List<javax.management.ObjectName> mbeans, java.lang.String operation, boolean failFirst)Invoke an operation on a list of mbeans.java.util.List<javax.management.ObjectName>load(java.lang.String sourceType, java.lang.Object source, java.lang.String param)Load descriptors.voidloadDescriptors(java.lang.String packageName, java.lang.ClassLoader classLoader)Lookup the component descriptor in the package and in the parent packages.voidregisterComponent(java.lang.Object bean, java.lang.String oname, java.lang.String type)Register a bean by creating a modeler mbean and adding it to the MBeanServer.voidregisterComponent(java.lang.Object bean, javax.management.ObjectName oname, java.lang.String type)Register a componentvoidunregisterComponent(java.lang.String oname)Unregister a component.voidunregisterComponent(javax.management.ObjectName oname)Unregister a component.-
Methods inherited from class org.apache.tomcat.util.modeler.Registry
convertValue, disableRegistry, getMethodInfo, getRegistry, getRegistry, postDeregister, postRegister, preDeregister, preRegister, stop
-
-
-
-
Method Detail
-
registerComponent
public void registerComponent(java.lang.Object bean, java.lang.String oname, java.lang.String type) throws java.lang.ExceptionDescription copied from class:RegistryRegister a bean by creating a modeler mbean and adding it to the MBeanServer. If metadata is not loaded, we'll look up and read a file named "mbeans-descriptors.ser" or "mbeans-descriptors.xml" in the same package or parent. If the bean is an instance of DynamicMBean. its metadata will be converted to a model mbean, and we'll wrap it so modeler services are supported. If the metadata is still not found, introspection will be used to extract it automatically. If a mbean is already registered under this name, it'll be first unregistered. If the component implements MBeanRegistration, the methods will be called. If the method has a method "setRegistry" that takes a RegistryMBean as parameter, it'll be called with the current registry.- Specified by:
registerComponentin interfaceRegistryMBean- Overrides:
registerComponentin classRegistry- Parameters:
bean- Object to be registeredoname- Name used for registrationtype- The type of the mbean, as declared in mbeans-descriptors. If null, the name of the class will be used. This can be used as a hint or by subclasses.- Throws:
java.lang.Exception- if a registration error occurred
-
unregisterComponent
public void unregisterComponent(java.lang.String oname)
Description copied from class:RegistryUnregister a component. We'll first check if it is registered, and mask all errors. This is mostly a helper.- Specified by:
unregisterComponentin interfaceRegistryMBean- Overrides:
unregisterComponentin classRegistry- Parameters:
oname- Name used for unregistration
-
invoke
public void invoke(java.util.List<javax.management.ObjectName> mbeans, java.lang.String operation, boolean failFirst) throws java.lang.ExceptionDescription copied from class:RegistryInvoke an operation on a list of mbeans. Can be used to implement lifecycle operations.- Specified by:
invokein interfaceRegistryMBean- Overrides:
invokein classRegistry- Parameters:
mbeans- list of ObjectName on which we'll invoke the operationsoperation- Name of the operation ( init, start, stop, etc)failFirst- If false, exceptions will be ignored- Throws:
java.lang.Exception- Error invoking operation
-
getId
public int getId(java.lang.String domain, java.lang.String name)Description copied from class:RegistryReturn an int ID for faster access. Will be used for notifications and for other operations we want to optimize.- Specified by:
getIdin interfaceRegistryMBean- Overrides:
getIdin classRegistry- Parameters:
domain- Namespacename- Type of the notification- Returns:
- A unique id for the domain:name combination
-
addManagedBean
public void addManagedBean(ManagedBean bean)
Description copied from class:RegistryAdd a new bean metadata to the set of beans known to this registry. This is used by internal components.- Overrides:
addManagedBeanin classRegistry- Parameters:
bean- The managed bean to be added
-
findManagedBean
public ManagedBean findManagedBean(java.lang.String name)
Description copied from class:RegistryFind and return the managed bean definition for the specified bean name, if any; otherwise returnnull.- Overrides:
findManagedBeanin classRegistry- Parameters:
name- Name of the managed bean to be returned. Since 1.1, both short names or the full name of the class can be used.- Returns:
- the managed bean
-
getType
public java.lang.String getType(javax.management.ObjectName oname, java.lang.String attName)Description copied from class:RegistryGet the type of an attribute of the object, from the metadata.
-
getMethodInfo
public javax.management.MBeanOperationInfo getMethodInfo(javax.management.ObjectName oname, java.lang.String opName)Description copied from class:RegistryFind the operation info for a method- Overrides:
getMethodInfoin classRegistry- Parameters:
oname- The bean nameopName- The operation name- Returns:
- the operation info for the specified operation
-
findManagedBean
public ManagedBean findManagedBean(java.lang.Object bean, java.lang.Class<?> beanClass, java.lang.String type) throws java.lang.Exception
Description copied from class:RegistryFind or load metadata.- Overrides:
findManagedBeanin classRegistry- Parameters:
bean- The beanbeanClass- The bean classtype- The registry type- Returns:
- the managed bean
- Throws:
java.lang.Exception- An error occurred
-
load
public java.util.List<javax.management.ObjectName> load(java.lang.String sourceType, java.lang.Object source, java.lang.String param) throws java.lang.ExceptionDescription copied from class:RegistryLoad descriptors.
-
loadDescriptors
public void loadDescriptors(java.lang.String packageName, java.lang.ClassLoader classLoader)Description copied from class:RegistryLookup the component descriptor in the package and in the parent packages.- Overrides:
loadDescriptorsin classRegistry- Parameters:
packageName- The package nameclassLoader- The class loader
-
registerComponent
public void registerComponent(java.lang.Object bean, javax.management.ObjectName oname, java.lang.String type) throws java.lang.ExceptionDescription copied from class:RegistryRegister a component- Overrides:
registerComponentin classRegistry- Parameters:
bean- The beanoname- The object nametype- The registry type- Throws:
java.lang.Exception- Error registering component
-
unregisterComponent
public void unregisterComponent(javax.management.ObjectName oname)
Description copied from class:RegistryUnregister a component. This is just a helper that avoids exceptions by checking if the mbean is already registered- Overrides:
unregisterComponentin classRegistry- Parameters:
oname- The bean name
-
getMBeanServer
public javax.management.MBeanServer getMBeanServer()
Description copied from class:RegistryFactory method to create (if necessary) and return ourMBeanServerinstance.- Overrides:
getMBeanServerin classRegistry- Returns:
- the MBean server
-
-