public class Registry extends Object implements RegistryMBean, MBeanRegistration
Constructor and Description |
---|
Registry() |
Modifier and Type | Method and Description |
---|---|
void |
addManagedBean(ManagedBean bean)
Add a new bean metadata to the set of beans known to this registry.
|
Object |
convertValue(String type,
String value)
EXPERIMENTAL Convert a string to object, based on type.
|
ManagedBean |
findManagedBean(Class<?> beanClass,
String type)
Deprecated.
|
ManagedBean |
findManagedBean(Object bean,
Class<?> beanClass,
String type)
Find or load metadata.
|
ManagedBean |
findManagedBean(String name)
Find and return the managed bean definition for the specified bean name,
if any; otherwise return
null . |
String[] |
findManagedBeans()
Return the set of bean names for all managed beans known to
this registry.
|
String[] |
findManagedBeans(String group)
Return the set of bean names for all managed beans known to
this registry that belong to the specified group.
|
int |
getId(String domain,
String name)
Return an int ID for faster access.
|
MBeanServer |
getMBeanServer()
Factory method to create (if necessary) and return our
MBeanServer instance. |
MBeanOperationInfo |
getMethodInfo(ObjectName oname,
String opName)
Find the operation info for a method
|
MBeanOperationInfo |
getMethodInfo(ObjectName oname,
String opName,
int argCount)
Find the operation info for a method.
|
static Registry |
getRegistry(Object key,
Object guard)
Factory method to create (if necessary) and return our
Registry instance. |
String |
getType(ObjectName oname,
String attName)
Get the type of an attribute of the object, from the metadata.
|
void |
invoke(List<ObjectName> mbeans,
String operation,
boolean failFirst)
Invoke a operation on a list of mbeans.
|
List<ObjectName> |
load(String sourceType,
Object source,
String param)
Experimental.
|
void |
loadDescriptors(String packageName,
ClassLoader classLoader)
Lookup the component descriptor in the package and in the parent
packages.
|
List<ObjectName> |
loadMBeans(Object source,
ClassLoader cl)
Load an extended mlet file.
|
void |
loadMetadata(Object source)
Load descriptors.
|
void |
postDeregister() |
void |
postRegister(Boolean registrationDone) |
void |
preDeregister() |
ObjectName |
preRegister(MBeanServer server,
ObjectName name) |
void |
registerComponent(Object bean,
ObjectName oname,
String type)
Register a component
|
void |
registerComponent(Object bean,
String oname,
String type)
Register a bean by creating a modeler mbean and adding it to the
MBeanServer.
|
void |
removeManagedBean(ManagedBean bean)
Remove an existing bean from the set of beans known to this registry.
|
void |
resetMetadata() |
void |
setMBeanServer(MBeanServer server)
Set the
MBeanServer to be utilized for our
registered management beans. |
static void |
setUseContextClassLoader(boolean enable)
Allow containers to isolate apps.
|
void |
stop()
Lifecycle method - clean up the registry metadata.
|
void |
unregisterComponent(ObjectName oname)
Unregister a component.
|
void |
unregisterComponent(String oname)
Unregister a component.
|
public static Registry getRegistry(Object key, Object guard)
Registry
instance.
Use this method to obtain a Registry - all other static methods
are deprecated and shouldn't be used.
The current version uses a static - future versions could use
the thread class loader.key
- Support for application isolation. If null, the context class
loader will be used ( if setUseContextClassLoader is called ) or the
default registry is returned.guard
- Prevent access to the registry by untrusted componentspublic static void setUseContextClassLoader(boolean enable)
enable
- public void stop()
stop
in interface RegistryMBean
public List<ObjectName> loadMBeans(Object source, ClassLoader cl) throws Exception
loadMBeans
in interface RegistryMBean
source
- InputStream or URL of the filecl
- ClassLoader to be used to load the mbeans, or null to use the
default JMX mechanism ( i.e. all registered loaders )Exception
public void loadMetadata(Object source) throws Exception
loadMetadata
in interface RegistryMBean
source
- Exception
public void registerComponent(Object bean, String oname, String type) throws Exception
registerComponent
in interface RegistryMBean
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.Exception
- if a registration error occurredpublic void unregisterComponent(String oname)
unregisterComponent
in interface RegistryMBean
oname
- Name used for unregistrationpublic void invoke(List<ObjectName> mbeans, String operation, boolean failFirst) throws Exception
invoke
in interface RegistryMBean
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 ignoredException
- Error invoking operationpublic int getId(String domain, String name)
getId
in interface RegistryMBean
domain
- Namespacename
- Type of the notificationpublic void addManagedBean(ManagedBean bean)
bean
- The managed bean to be addedpublic ManagedBean findManagedBean(String name)
null
.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.public String[] findManagedBeans()
public String[] findManagedBeans(String group)
group
- Name of the group of interest, or null
to select beans that do not belong to a grouppublic void removeManagedBean(ManagedBean bean)
bean
- The managed bean to be removedpublic String getType(ObjectName oname, String attName)
oname
- attName
- public MBeanOperationInfo getMethodInfo(ObjectName oname, String opName)
oname
- The bean nameopName
- The operation namepublic MBeanOperationInfo getMethodInfo(ObjectName oname, String opName, int argCount) throws InstanceNotFoundException
oname
- The bean nameopName
- The operation nameargCount
- The number of arguments to the methodInstanceNotFoundException
- If the object name is not bound to an MBeanpublic void unregisterComponent(ObjectName oname)
oname
- The bean namepublic MBeanServer getMBeanServer()
MBeanServer
instance.public ManagedBean findManagedBean(Object bean, Class<?> beanClass, String type) throws Exception
bean
- The beanbeanClass
- The bean classtype
- The registry typeException
- An error occurredpublic Object convertValue(String type, String value)
type
- Fully qualified class name of the resulting valuevalue
- String value to be convertedpublic List<ObjectName> load(String sourceType, Object source, String param) throws Exception
sourceType
- The source typesource
- The beanparam
- A type to loadException
- Error loading descriptorspublic void registerComponent(Object bean, ObjectName oname, String type) throws Exception
bean
- The beanoname
- The object nametype
- The registry typeException
- Error registering componentpublic void loadDescriptors(String packageName, ClassLoader classLoader)
packageName
- The package nameclassLoader
- The class loaderpublic ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister
in interface MBeanRegistration
Exception
public void postRegister(Boolean registrationDone)
postRegister
in interface MBeanRegistration
public void preDeregister() throws Exception
preDeregister
in interface MBeanRegistration
Exception
public void postDeregister()
postDeregister
in interface MBeanRegistration
@Deprecated public ManagedBean findManagedBean(Class<?> beanClass, String type) throws Exception
Exception
public void setMBeanServer(MBeanServer server)
MBeanServer
to be utilized for our
registered management beans.server
- The new MBeanServer
instancepublic void resetMetadata()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.