Top Description Fields Constructors Methods
org.apache.tomcat.util.modeler

public Class BaseModelMBean

extends Object
implements DynamicMBean, MBeanRegistration, ModelMBeanNotificationBroadcaster
Class Inheritance
All Implemented Interfaces
javax.management.modelmbean.ModelMBeanNotificationBroadcaster, javax.management.NotificationBroadcaster, javax.management.MBeanRegistration, javax.management.DynamicMBean
Known Direct Subclasses
org.apache.catalina.mbeans.BaseCatalinaMBean, org.apache.catalina.mbeans.DataSourceUserDatabaseMBean, org.apache.catalina.mbeans.GroupMBean, org.apache.catalina.mbeans.NamingResourcesMBean, org.apache.catalina.mbeans.RoleMBean, org.apache.catalina.mbeans.SparseUserDatabaseMBean, org.apache.catalina.mbeans.UserMBean, org.apache.coyote.RequestGroupInfo, org.apache.coyote.http11.upgrade.UpgradeGroupInfo
Imports
java.lang.reflect.InvocationTargetException, .Method, javax.management.Attribute, .AttributeChangeNotification, .AttributeList, .AttributeNotFoundException, .DynamicMBean, .InstanceNotFoundException, .InvalidAttributeValueException, .ListenerNotFoundException, .MBeanException, .MBeanInfo, .MBeanNotificationInfo, .MBeanRegistration, .MBeanServer, .Notification, .NotificationFilter, .NotificationListener, .ObjectName, .ReflectionException, .RuntimeErrorException, .RuntimeOperationsException, javax.management.modelmbean.InvalidTargetObjectTypeException, .ModelMBeanNotificationBroadcaster, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.res.StringManager

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:

Authors
Craig R. McClanahan, Costin Manolache

Field Summary

Modifier and TypeField and Description
protected BaseNotificationBroadcaster
attributeBroadcaster

Notification broadcaster for attribute changes.

protected BaseNotificationBroadcaster
generalBroadcaster

Notification broadcaster for general notifications.

private static final Log
protected ManagedBean
managedBean

Metadata for the mbean instance.

pack-priv static final Object[]
protected ObjectName
protected Object
resource

The managed resource this MBean is associated with (if any).

protected String
private static final StringManager

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addAttributeChangeNotificationListener(NotificationListener
Listener that will receive event notifications
listener
,
String
Name of the attribute of interest, or null to indicate interest in all attributes
name
,
Object
Handback object to be sent along with event notifications
handback
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.addAttributeChangeNotificationListener.

Add an attribute change notification event listener to this MBean.

public void
addNotificationListener(NotificationListener
Listener that will receive event notifications
listener
,
NotificationFilter
Filter object used to filter event notifications actually delivered, or null for no filtering
filter
,
Object
Handback object to be sent along with event notifications
handback
)

Implements javax.management.NotificationBroadcaster.addNotificationListener.

Add a notification event listener to this MBean.

public Object
getAttribute(String
Name of the requested attribute
name
)

Implements javax.management.DynamicMBean.getAttribute.

Obtain and return the value of a specific attribute of this MBean.

pack-priv static Class<?>
public AttributeList
getAttributes(String[]
Names of the requested attributes
names
)

Implements javax.management.DynamicMBean.getAttributes.

Obtain and return the values of several attributes of this MBean.

public String
public ObjectName
public Object

Returns:

the backend managed object
getManagedResource
()

Get the instance handle of the object against which we execute all methods in this ModelMBean management interface.

public MBeanInfo
getMBeanInfo()

Implements javax.management.DynamicMBean.getMBeanInfo.

Return the MBeanInfo object for this MBean.

public String
public MBeanNotificationInfo[]
getNotificationInfo()

Implements javax.management.NotificationBroadcaster.getNotificationInfo.

Return an MBeanNotificationInfo object describing the notifications sent by this MBean.

public String
public Object
invoke(String
Name of the operation to be invoked
name
,
Object[]
Array containing the method parameters of this operation
params
,
String[]
Array containing the class names representing the signature of this operation
signature
)

Implements javax.management.DynamicMBean.invoke.

Invoke a particular method on this MBean, and return any returned value.

public void
postDeregister()

Implements javax.management.MBeanRegistration.postDeregister.

Allows the MBean to perform any operations needed after having been unregistered in the MBean server.

public void
postRegister(Boolean
Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.
registrationDone
)

Implements javax.management.MBeanRegistration.postRegister.

Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

public void
preDeregister()

Implements javax.management.MBeanRegistration.preDeregister.

Allows the MBean to perform any operations it needs before being unregistered by the MBean server.

public ObjectName
preRegister(MBeanServer
The MBean Server in which the MBean will be registered.
server
,
ObjectName
The object name of the MBean. This name is null if the name parameter to one of the createMBean or registerMBean methods in the MBeanServer interface is null. In that case, this method must return a non-null ObjectName for the new MBean.
name
)

Implements javax.management.MBeanRegistration.preRegister.

Allows the MBean to perform any operations it needs before being registered in the MBean Server.

public void
removeAttributeChangeNotificationListener(NotificationListener
The listener to be removed
listener
,
String
The attribute name for which no more events are required
name
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.removeAttributeChangeNotificationListener.

Remove an attribute change notification event listener from this MBean.

public void
removeNotificationListener(NotificationListener
The listener to be removed (any and all registrations for this listener will be eliminated)
listener
)

Implements javax.management.NotificationBroadcaster.removeNotificationListener.

Remove a notification event listener from this MBean.

public void
sendAttributeChangeNotification(AttributeChangeNotification
The AttributeChangeNotification that will be passed
notification
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Send an AttributeChangeNotification to all registered listeners.

public void
sendAttributeChangeNotification(Attribute
The original value of the Attribute
oldValue
,
Attribute
The new value of the Attribute
newValue
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Send an AttributeChangeNotification to all registered listeners.

public void
sendNotification(Notification
The Notification that will be passed
notification
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Send a Notification to all registered listeners as a jmx.modelmbean.general notification.

public void
sendNotification(String
The message string to be passed
message
)

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Send a Notification which contains the specified string as a jmx.modelmbean.generic notification.

public void
setAttribute(Attribute
The identification of the attribute to be set and the new value
attribute
)

Implements javax.management.DynamicMBean.setAttribute.

Set the value of a specific attribute of this MBean.

public AttributeList

Returns:

The list of attributes that were set and their new values
setAttributes
(AttributeList
THe names and values to be set
attributes
)

Implements javax.management.DynamicMBean.setAttributes.

Set the values of several attributes of this MBean.

public void
public void
setManagedResource(Object
The resource object to be managed
resource
,
String
The type of reference for the managed resource ("ObjectReference", "Handle", "IOR", "EJBHandle", or "RMIReference")
type
)

Set the instance handle of the object against which we will execute all methods in this ModelMBean management interface.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attributeBroadcasterback to summary
protected BaseNotificationBroadcaster attributeBroadcaster

Notification broadcaster for attribute changes.

generalBroadcasterback to summary
protected BaseNotificationBroadcaster generalBroadcaster

Notification broadcaster for general notifications.

logback to summary
private static final Log log
managedBeanback to summary
protected ManagedBean managedBean

Metadata for the mbean instance.

NO_ARGS_PARAMback to summary
pack-priv static final Object[] NO_ARGS_PARAM
onameback to summary
protected ObjectName oname
resourceback to summary
protected Object resource

The managed resource this MBean is associated with (if any).

resourceTypeback to summary
protected String resourceType
smback to summary
private static final StringManager sm

Constructor Detail

BaseModelMBeanback to summary
public BaseModelMBean()

Method Detail

addAttributeChangeNotificationListenerback to summary
public void addAttributeChangeNotificationListener(NotificationListener listener, String name, Object handback) throws IllegalArgumentException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.addAttributeChangeNotificationListener.

Add an attribute change notification event listener to this MBean.

Parameters
listener:NotificationListener

Listener that will receive event notifications

name:String

Name of the attribute of interest, or null to indicate interest in all attributes

handback:Object

Handback object to be sent along with event notifications

Annotations
@Override
Exceptions
IllegalArgumentException:
if the listener parameter is null
addNotificationListenerback to summary
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException

Implements javax.management.NotificationBroadcaster.addNotificationListener.

Add a notification event listener to this MBean.

Parameters
listener:NotificationListener

Listener that will receive event notifications

filter:NotificationFilter

Filter object used to filter event notifications actually delivered, or null for no filtering

handback:Object

Handback object to be sent along with event notifications

Annotations
@Override
Exceptions
IllegalArgumentException:
if the listener parameter is null
getAttributeback to summary
public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException

Implements javax.management.DynamicMBean.getAttribute.

Obtain and return the value of a specific attribute of this MBean.

Parameters
name:String

Name of the requested attribute

Returns:Object

Doc from javax.management.DynamicMBean.getAttribute.

The value of the attribute retrieved.

Annotations
@Override
Exceptions
AttributeNotFoundException:
if this attribute is not supported by this MBean
MBeanException:
if the initializer of an object throws an exception
ReflectionException:
if a Java reflection exception occurs when invoking the getter
getAttributeClassback to summary
pack-priv static Class<?> getAttributeClass(String signature) throws ReflectionException
getAttributesback to summary
public AttributeList getAttributes(String[] names)

Implements javax.management.DynamicMBean.getAttributes.

Obtain and return the values of several attributes of this MBean.

Parameters
names:String[]

Names of the requested attributes

Returns:AttributeList

Doc from javax.management.DynamicMBean.getAttributes.

The list of attributes retrieved.

Annotations
@Override
getClassNameback to summary
public String getClassName()
getJmxNameback to summary
public ObjectName getJmxName()
getManagedResourceback to summary
public Object getManagedResource() throws InstanceNotFoundException, InvalidTargetObjectTypeException, MBeanException, RuntimeOperationsException

Get the instance handle of the object against which we execute all methods in this ModelMBean management interface.

Returns:Object

the backend managed object

Exceptions
InstanceNotFoundException:
if the managed resource object cannot be found
InvalidTargetObjectTypeException:
if the managed resource object is of the wrong type
MBeanException:
if the initializer of the object throws an exception
RuntimeOperationsException:
if the managed resource or the resource type is null or invalid
getMBeanInfoback to summary
public MBeanInfo getMBeanInfo()

Implements javax.management.DynamicMBean.getMBeanInfo.

Return the MBeanInfo object for this MBean.

Returns:MBeanInfo

Doc from javax.management.DynamicMBean.getMBeanInfo.

An instance of MBeanInfo allowing all attributes and actions exposed by this Dynamic MBean to be retrieved.

Annotations
@Override
getModelerTypeback to summary
public String getModelerType()
getNotificationInfoback to summary
public MBeanNotificationInfo[] getNotificationInfo()

Implements javax.management.NotificationBroadcaster.getNotificationInfo.

Return an MBeanNotificationInfo object describing the notifications sent by this MBean.

Returns:MBeanNotificationInfo[]

Doc from javax.management.NotificationBroadcaster.getNotificationInfo.

the array of possible notifications.

Annotations
@Override
getObjectNameback to summary
public String getObjectName()
invokeback to summary
public Object invoke(String name, Object[] params, String[] signature) throws MBeanException, ReflectionException

Implements javax.management.DynamicMBean.invoke.

Invoke a particular method on this MBean, and return any returned value.

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.

Parameters
name:String

Name of the operation to be invoked

params:Object[]

Array containing the method parameters of this operation

signature:String[]

Array containing the class names representing the signature of this operation

Returns:Object

Doc from javax.management.DynamicMBean.invoke.

The object returned by the action, which represents the result of invoking the action on the MBean specified.

Annotations
@Override
Exceptions
MBeanException:
if the initializer of an object throws an exception
ReflectionException:
if a Java reflection exception occurs when invoking a method
postDeregisterback to summary
public void postDeregister()

Implements javax.management.MBeanRegistration.postDeregister.

Doc from javax.management.MBeanRegistration.postDeregister.

Allows the MBean to perform any operations needed after having been unregistered in the MBean server.

If the implementation of this method throws a RuntimeException or an Error, the MBean Server will rethrow those inside a RuntimeMBeanException or RuntimeErrorException, respectively. However, throwing an exception in postDeregister will not change the state of the MBean: the MBean was already successfully deregistered and will remain so.

This might be confusing for the code calling unregisterMBean(), as it might assume that MBean deregistration has failed. Therefore it is recommended that implementations of postDeregister do not throw Runtime Exceptions or Errors if it can be avoided.

Annotations
@Override
postRegisterback to summary
public void postRegister(Boolean registrationDone)

Implements javax.management.MBeanRegistration.postRegister.

Doc from javax.management.MBeanRegistration.postRegister.

Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

If the implementation of this method throws a RuntimeException or an Error, the MBean Server will rethrow those inside a RuntimeMBeanException or RuntimeErrorException, respectively. However, throwing an exception in postRegister will not change the state of the MBean: if the MBean was already registered (registrationDone is true), the MBean will remain registered.

This might be confusing for the code calling createMBean() or registerMBean(), as such code might assume that MBean registration has failed when such an exception is raised. Therefore it is recommended that implementations of postRegister do not throw Runtime Exceptions or Errors if it can be avoided.

Parameters
registrationDone:Boolean

Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.

Annotations
@Override
preDeregisterback to summary
public void preDeregister() throws Exception

Implements javax.management.MBeanRegistration.preDeregister.

Doc from javax.management.MBeanRegistration.preDeregister.

Allows the MBean to perform any operations it needs before being unregistered by the MBean server.

Annotations
@Override
Exceptions
Exception:
This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException.
preRegisterback to summary
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception

Implements javax.management.MBeanRegistration.preRegister.

Doc from javax.management.MBeanRegistration.preRegister.

Allows the MBean to perform any operations it needs before being registered in the MBean Server. If the name of the MBean is not specified, the MBean can provide a name for its registration. If any exception is raised, the MBean will not be registered in the MBean Server.

Parameters
server:MBeanServer

The MBean Server in which the MBean will be registered.

name:ObjectName

The object name of the MBean. This name is null if the name parameter to one of the createMBean or registerMBean methods in the MBeanServer interface is null. In that case, this method must return a non-null ObjectName for the new MBean.

Returns:ObjectName

The name under which the MBean is to be registered. This value must not be null. If the name parameter is not null, it will usually but not necessarily be the returned value.

Annotations
@Override
Exceptions
Exception:
This exception will be caught by the MBean Server and re-thrown as an MBeanRegistrationException.
removeAttributeChangeNotificationListenerback to summary
public void removeAttributeChangeNotificationListener(NotificationListener listener, String name) throws ListenerNotFoundException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.removeAttributeChangeNotificationListener.

Remove an attribute change notification event listener from this MBean.

Parameters
listener:NotificationListener

The listener to be removed

name:String

The attribute name for which no more events are required

Annotations
@Override
Exceptions
ListenerNotFoundException:
if this listener is not registered in the MBean
removeNotificationListenerback to summary
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException

Implements javax.management.NotificationBroadcaster.removeNotificationListener.

Remove a notification event listener from this MBean.

Parameters
listener:NotificationListener

The listener to be removed (any and all registrations for this listener will be eliminated)

Annotations
@Override
Exceptions
ListenerNotFoundException:
if this listener is not registered in the MBean
sendAttributeChangeNotificationback to summary
public void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Send an AttributeChangeNotification to all registered listeners.

Parameters
notification:AttributeChangeNotification

The AttributeChangeNotification that will be passed

Annotations
@Override
Exceptions
MBeanException:
if an object initializer throws an exception
RuntimeOperationsException:
wraps IllegalArgumentException when the specified notification is null or invalid
sendAttributeChangeNotificationback to summary
public void sendAttributeChangeNotification(Attribute oldValue, Attribute newValue) throws MBeanException, RuntimeOperationsException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendAttributeChangeNotification.

Send an AttributeChangeNotification to all registered listeners.

Parameters
oldValue:Attribute

The original value of the Attribute

newValue:Attribute

The new value of the Attribute

Annotations
@Override
Exceptions
MBeanException:
if an object initializer throws an exception
RuntimeOperationsException:
wraps IllegalArgumentException when the specified notification is null or invalid
sendNotificationback to summary
public void sendNotification(Notification notification) throws MBeanException, RuntimeOperationsException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Send a Notification to all registered listeners as a jmx.modelmbean.general notification.

Parameters
notification:Notification

The Notification that will be passed

Annotations
@Override
Exceptions
MBeanException:
if an object initializer throws an exception
RuntimeOperationsException:
wraps IllegalArgumentException when the specified notification is null or invalid
sendNotificationback to summary
public void sendNotification(String message) throws MBeanException, RuntimeOperationsException

Implements javax.management.modelmbean.ModelMBeanNotificationBroadcaster.sendNotification.

Send a Notification which contains the specified string as a jmx.modelmbean.generic notification.

Parameters
message:String

The message string to be passed

Annotations
@Override
Exceptions
MBeanException:
if an object initializer throws an exception
RuntimeOperationsException:
wraps IllegalArgumentException when the specified notification is null or invalid
setAttributeback to summary
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException

Implements javax.management.DynamicMBean.setAttribute.

Set the value of a specific attribute of this MBean.

Parameters
attribute:Attribute

The identification of the attribute to be set and the new value

Annotations
@Override
Exceptions
AttributeNotFoundException:
if this attribute is not supported by this MBean
MBeanException:
if the initializer of an object throws an exception
ReflectionException:
if a Java reflection exception occurs when invoking the getter
setAttributesback to summary
public AttributeList setAttributes(AttributeList attributes)

Implements javax.management.DynamicMBean.setAttributes.

Set the values of several attributes of this MBean.

Parameters
attributes:AttributeList

THe names and values to be set

Returns:AttributeList

The list of attributes that were set and their new values

Annotations
@Override
setManagedBeanback to summary
public void setManagedBean(ManagedBean managedBean)
setManagedResourceback to summary
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:Object

The resource object to be managed

type:String

The type of reference for the managed resource ("ObjectReference", "Handle", "IOR", "EJBHandle", or "RMIReference")

Exceptions
InstanceNotFoundException:
if the managed resource object cannot be found
MBeanException:
if the initializer of the object throws an exception
RuntimeOperationsException:
if the managed resource or the resource type is null or invalid
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override