Package org.apache.tomcat.util.modeler
Class BaseModelMBean
java.lang.Object
org.apache.tomcat.util.modeler.BaseModelMBean
- All Implemented Interfaces:
DynamicMBean
,MBeanRegistration
,ModelMBeanNotificationBroadcaster
,NotificationBroadcaster
- Direct Known Subclasses:
BaseCatalinaMBean
,DataSourceUserDatabaseMBean
,GroupMBean
,NamingResourcesMBean
,RequestGroupInfo
,RoleMBean
,SparseUserDatabaseMBean
,UpgradeGroupInfo
,UserMBean
public class BaseModelMBean
extends Object
implements DynamicMBean, MBeanRegistration, ModelMBeanNotificationBroadcaster
Basic implementation of the DynamicMBean
interface, which
supports the minimal requirements of the interface contract.
This can be used directly to wrap an existing java bean, or inside an mlet or anywhere an MBean would be used. Limitations:
- Only managed resources of type
objectReference
are supported. - Caching of attribute values and operation results is not supported.
All calls to
invoke()
are immediately executed. - Persistence of MBean attributes and operations is not supported.
- All classes referenced as attribute types, operation parameters, or
operation return values must be one of the following:
- One of the Java primitive types (boolean, byte, char, double, float, integer, long, short). Corresponding value will be wrapped in the appropriate wrapper class automatically.
- Operations that return no value should declare a return type of
void
.
- Attribute caching is not supported
- Author:
- Craig R. McClanahan, Costin Manolache
-
Field Summary
Modifier and TypeFieldDescriptionprotected BaseNotificationBroadcaster
Notification broadcaster for attribute changes.protected BaseNotificationBroadcaster
Notification broadcaster for general notifications.protected ManagedBean
Metadata for the mbean instance.protected ObjectName
protected Object
The managed resource this MBean is associated with (if any).protected String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttributeChangeNotificationListener
(NotificationListener listener, String name, Object handback) void
addNotificationListener
(NotificationListener listener, NotificationFilter filter, Object handback) getAttribute
(String name) getAttributes
(String[] names) Get the instance handle of the object against which we execute all methods in this ModelMBean management interface.Return theMBeanInfo
object for this MBean.void
void
postRegister
(Boolean registrationDone) void
preRegister
(MBeanServer server, ObjectName name) void
removeAttributeChangeNotificationListener
(NotificationListener listener, String name) void
void
sendAttributeChangeNotification
(AttributeChangeNotification notification) void
sendAttributeChangeNotification
(Attribute oldValue, Attribute newValue) void
sendNotification
(String message) void
sendNotification
(Notification notification) void
setAttribute
(Attribute attribute) setAttributes
(AttributeList attributes) void
setManagedBean
(ManagedBean managedBean) void
setManagedResource
(Object resource, String type) Set the instance handle of the object against which we will execute all methods in this ModelMBean management interface.toString()
-
Field Details
-
oname
-
attributeBroadcaster
Notification broadcaster for attribute changes. -
generalBroadcaster
Notification broadcaster for general notifications. -
managedBean
Metadata for the mbean instance. -
resource
The managed resource this MBean is associated with (if any). -
resourceType
-
-
Constructor Details
-
BaseModelMBean
public BaseModelMBean()
-
-
Method Details
-
getAttribute
public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException - Specified by:
getAttribute
in interfaceDynamicMBean
- Throws:
AttributeNotFoundException
MBeanException
ReflectionException
-
getAttributes
- Specified by:
getAttributes
in interfaceDynamicMBean
-
setManagedBean
-
getMBeanInfo
Return theMBeanInfo
object for this MBean.- Specified by:
getMBeanInfo
in interfaceDynamicMBean
-
invoke
public Object invoke(String name, Object[] params, String[] signature) throws MBeanException, ReflectionException IMPLEMENTATION NOTE - This implementation will attempt to invoke this method on the MBean itself, or (if not available) on the managed resource object associated with this MBean.
- Specified by:
invoke
in interfaceDynamicMBean
- Throws:
MBeanException
ReflectionException
-
setAttribute
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException - Specified by:
setAttribute
in interfaceDynamicMBean
- Throws:
AttributeNotFoundException
MBeanException
ReflectionException
-
toString
-
setAttributes
- Specified by:
setAttributes
in interfaceDynamicMBean
-
getManagedResource
public Object getManagedResource() throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsExceptionGet the instance handle of the object against which we execute all methods in this ModelMBean management interface.- Returns:
- the backend managed object
- Throws:
InstanceNotFoundException
- if the managed resource object cannot be foundInvalidTargetObjectTypeException
- if the managed resource object is of the wrong typeMBeanException
- if the initializer of the object throws an exceptionRuntimeOperationsException
- if the managed resource or the resource type isnull
or invalid
-
setManagedResource
public void setManagedResource(Object resource, String type) throws InstanceNotFoundException, MBeanException, RuntimeOperationsException Set the instance handle of the object against which we will execute all methods in this ModelMBean management interface. The caller can provide the mbean instance or the object name to the resource, if needed.- Parameters:
resource
- The resource object to be managedtype
- The type of reference for the managed resource ("ObjectReference", "Handle", "IOR", "EJBHandle", or "RMIReference")- Throws:
InstanceNotFoundException
- if the managed resource object cannot be foundMBeanException
- if the initializer of the object throws an exceptionRuntimeOperationsException
- if the managed resource or the resource type isnull
or invalid
-
addAttributeChangeNotificationListener
public void addAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback) throws IllegalArgumentException - Specified by:
addAttributeChangeNotificationListener
in interfaceModelMBeanNotificationBroadcaster
- Throws:
IllegalArgumentException
-
removeAttributeChangeNotificationListener
public void removeAttributeChangeNotificationListener(NotificationListener listener, String name) throws ListenerNotFoundException - Specified by:
removeAttributeChangeNotificationListener
in interfaceModelMBeanNotificationBroadcaster
- Throws:
ListenerNotFoundException
-
sendAttributeChangeNotification
public void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException - Specified by:
sendAttributeChangeNotification
in interfaceModelMBeanNotificationBroadcaster
- Throws:
MBeanException
RuntimeOperationsException
-
sendAttributeChangeNotification
public void sendAttributeChangeNotification(Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException - Specified by:
sendAttributeChangeNotification
in interfaceModelMBeanNotificationBroadcaster
- Throws:
MBeanException
RuntimeOperationsException
-
sendNotification
public void sendNotification(Notification notification) throws MBeanException, RuntimeOperationsException - Specified by:
sendNotification
in interfaceModelMBeanNotificationBroadcaster
- Throws:
MBeanException
RuntimeOperationsException
-
sendNotification
- Specified by:
sendNotification
in interfaceModelMBeanNotificationBroadcaster
- Throws:
MBeanException
RuntimeOperationsException
-
addNotificationListener
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException - Specified by:
addNotificationListener
in interfaceNotificationBroadcaster
- Throws:
IllegalArgumentException
-
getNotificationInfo
- Specified by:
getNotificationInfo
in interfaceNotificationBroadcaster
-
removeNotificationListener
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException - Specified by:
removeNotificationListener
in interfaceNotificationBroadcaster
- Throws:
ListenerNotFoundException
-
getModelerType
-
getClassName
- Returns:
- the fully qualified Java class name of the managed object for this MBean
-
getJmxName
-
getObjectName
-
preRegister
- Specified by:
preRegister
in interfaceMBeanRegistration
- Throws:
Exception
-
postRegister
- Specified by:
postRegister
in interfaceMBeanRegistration
-
preDeregister
- Specified by:
preDeregister
in interfaceMBeanRegistration
- Throws:
Exception
-
postDeregister
public void postDeregister()- Specified by:
postDeregister
in interfaceMBeanRegistration
-