Package org.apache.tomcat.util.modeler
Class Registry
- java.lang.Object
- 
- org.apache.tomcat.util.modeler.Registry
 
- 
- All Implemented Interfaces:
- javax.management.MBeanRegistration,- RegistryMBean
 - Direct Known Subclasses:
- NoDescriptorRegistry
 
 public class Registry extends java.lang.Object implements RegistryMBean, javax.management.MBeanRegistration Registry for modeler MBeans. This is the main entry point into modeler. It provides methods to create and manipulate model mbeans and simplify their use. This class is itself an mbean. IMPORTANT: public methods not marked with@since x.xare experimental or internal. Should not be used.- Author:
- Craig R. McClanahan, Costin Manolache
 
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedRegistry()
 - 
Method SummaryAll Methods Static 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.java.lang.ObjectconvertValue(java.lang.String type, java.lang.String value)EXPERIMENTAL Convert a string to object, based on type.static voiddisableRegistry()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 methodjavax.management.MBeanOperationInfogetMethodInfo(javax.management.ObjectName oname, java.lang.String opName, int argCount)Find the operation info for a method.static RegistrygetRegistry(java.lang.Object key, java.lang.Object guard)Factory method to create (if necessary) and return ourRegistryinstance.java.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 a 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)Experimental.voidloadDescriptors(java.lang.String packageName, java.lang.ClassLoader classLoader)Lookup the component descriptor in the package and in the parent packages.voidpostDeregister()voidpostRegister(java.lang.Boolean registrationDone)voidpreDeregister()javax.management.ObjectNamepreRegister(javax.management.MBeanServer server, javax.management.ObjectName name)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 componentvoidstop()Lifecycle method - clean up the registry metadata.voidunregisterComponent(java.lang.String oname)Unregister a component.voidunregisterComponent(javax.management.ObjectName oname)Unregister a component.
 
- 
- 
- 
Method Detail- 
getRegistrypublic static Registry getRegistry(java.lang.Object key, java.lang.Object guard) Factory method to create (if necessary) and return ourRegistryinstance.- Parameters:
- key- Unused
- guard- Prevent access to the registry by untrusted components
- Returns:
- the registry
- Since:
- 1.1
 
 - 
disableRegistrypublic static void disableRegistry() 
 - 
stoppublic void stop() Lifecycle method - clean up the registry metadata. Called from resetMetadata().- Specified by:
- stopin interface- RegistryMBean
- Since:
- 1.1
 
 - 
registerComponentpublic void registerComponent(java.lang.Object bean, java.lang.String oname, java.lang.String type) throws java.lang.ExceptionRegister 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. it's metadata will be converted to a model mbean and we'll wrap it - so modeler services will be supported If the metadata is still not found, introspection will be used to extract it automatically. If an 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 interface- RegistryMBean
- Parameters:
- bean- Object to be registered
- oname- Name used for registration
- type- 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
- Since:
- 1.1
 
 - 
unregisterComponentpublic void unregisterComponent(java.lang.String oname) Unregister a component. We'll first check if it is registered, and mask all errors. This is mostly a helper.- Specified by:
- unregisterComponentin interface- RegistryMBean
- Parameters:
- oname- Name used for unregistration
- Since:
- 1.1
 
 - 
invokepublic void invoke(java.util.List<javax.management.ObjectName> mbeans, java.lang.String operation, boolean failFirst) throws java.lang.ExceptionInvoke a operation on a list of mbeans. Can be used to implement lifecycle operations.- Specified by:
- invokein interface- RegistryMBean
- Parameters:
- mbeans- list of ObjectName on which we'll invoke the operations
- operation- Name of the operation ( init, start, stop, etc)
- failFirst- If false, exceptions will be ignored
- Throws:
- java.lang.Exception- Error invoking operation
- Since:
- 1.1
 
 - 
getIdpublic int getId(java.lang.String domain, java.lang.String name)Return an int ID for faster access. Will be used for notifications and for other operations we want to optimize.- Specified by:
- getIdin interface- RegistryMBean
- Parameters:
- domain- Namespace
- name- Type of the notification
- Returns:
- A unique id for the domain:name combination
- Since:
- 1.1
 
 - 
addManagedBeanpublic void addManagedBean(ManagedBean bean) Add a new bean metadata to the set of beans known to this registry. This is used by internal components.- Parameters:
- bean- The managed bean to be added
- Since:
- 1.0
 
 - 
findManagedBeanpublic ManagedBean findManagedBean(java.lang.String name) Find and return the managed bean definition for the specified bean name, if any; otherwise returnnull.- 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
- Since:
- 1.0
 
 - 
getTypepublic java.lang.String getType(javax.management.ObjectName oname, java.lang.String attName)Get the type of an attribute of the object, from the metadata.- Parameters:
- oname- The bean name
- attName- The attribute name
- Returns:
- null if metadata about the attribute is not found
- Since:
- 1.1
 
 - 
getMethodInfopublic javax.management.MBeanOperationInfo getMethodInfo(javax.management.ObjectName oname, java.lang.String opName)Find the operation info for a method- Parameters:
- oname- The bean name
- opName- The operation name
- Returns:
- the operation info for the specified operation
 
 - 
getMethodInfopublic javax.management.MBeanOperationInfo getMethodInfo(javax.management.ObjectName oname, java.lang.String opName, int argCount) throws javax.management.InstanceNotFoundExceptionFind the operation info for a method.- Parameters:
- oname- The bean name
- opName- The operation name
- argCount- The number of arguments to the method
- Returns:
- the operation info for the specified operation
- Throws:
- javax.management.InstanceNotFoundException- If the object name is not bound to an MBean
 
 - 
unregisterComponentpublic void unregisterComponent(javax.management.ObjectName oname) Unregister a component. This is just a helper that avoids exceptions by checking if the mbean is already registered- Parameters:
- oname- The bean name
 
 - 
getMBeanServerpublic javax.management.MBeanServer getMBeanServer() Factory method to create (if necessary) and return ourMBeanServerinstance.- Returns:
- the MBean server
 
 - 
findManagedBeanpublic ManagedBean findManagedBean(java.lang.Object bean, java.lang.Class<?> beanClass, java.lang.String type) throws java.lang.Exception Find or load metadata.- Parameters:
- bean- The bean
- beanClass- The bean class
- type- The registry type
- Returns:
- the managed bean
- Throws:
- java.lang.Exception- An error occurred
 
 - 
convertValuepublic java.lang.Object convertValue(java.lang.String type, java.lang.String value)EXPERIMENTAL Convert a string to object, based on type. Used by several components. We could provide some pluggability. It is here to keep things consistent and avoid duplication in other tasks- Parameters:
- type- Fully qualified class name of the resulting value
- value- String value to be converted
- Returns:
- Converted value
 
 - 
loadpublic java.util.List<javax.management.ObjectName> load(java.lang.String sourceType, java.lang.Object source, java.lang.String param) throws java.lang.ExceptionExperimental. Load descriptors.- Parameters:
- sourceType- The source type
- source- The bean
- param- A type to load
- Returns:
- List of descriptors
- Throws:
- java.lang.Exception- Error loading descriptors
 
 - 
registerComponentpublic void registerComponent(java.lang.Object bean, javax.management.ObjectName oname, java.lang.String type) throws java.lang.ExceptionRegister a component- Parameters:
- bean- The bean
- oname- The object name
- type- The registry type
- Throws:
- java.lang.Exception- Error registering component
 
 - 
loadDescriptorspublic void loadDescriptors(java.lang.String packageName, java.lang.ClassLoader classLoader)Lookup the component descriptor in the package and in the parent packages.- Parameters:
- packageName- The package name
- classLoader- The class loader
 
 - 
preRegisterpublic javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name) throws java.lang.Exception- Specified by:
- preRegisterin interface- javax.management.MBeanRegistration
- Throws:
- java.lang.Exception
 
 - 
postRegisterpublic void postRegister(java.lang.Boolean registrationDone) - Specified by:
- postRegisterin interface- javax.management.MBeanRegistration
 
 - 
preDeregisterpublic void preDeregister() throws java.lang.Exception- Specified by:
- preDeregisterin interface- javax.management.MBeanRegistration
- Throws:
- java.lang.Exception
 
 - 
postDeregisterpublic void postDeregister() - Specified by:
- postDeregisterin interface- javax.management.MBeanRegistration
 
 
- 
 
-