| 
 | JavaTM 2 Platform Ent. Ed. v1.4 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.management.modelmbean.RequiredModelMBean
This class is the implementation of a ModelMBean. An appropriate implementation of a ModelMBean must be shipped with every JMX Agent and the class must be named RequiredModelMBean.
Java resources wishing to be manageable instantiate the RequiredModelMBean using the MBeanServer's createMBean method. The resource then sets the MBeanInfo and Descriptors for the RequiredModelMBean instance. The attributes and operations exposed via the ModelMBeanInfo for the ModelMBean are accessible from MBeans, connectors/adaptors like other MBeans. Through the Descriptors, values and methods in the managed application can be defined and mapped to attributes and operations of the ModelMBean. This mapping can be defined in an XML formatted file or dynamically and programmatically at runtime.
 Every RequiredModelMBean which is instantiated in the MBeanServer 
 becomes manageable:
 
 its attributes and operations become remotely accessible through the
 connectors/adaptors connected to that MBeanServer.
 
A Java object cannot be registered in the MBeanServer unless it is a JMX compliant MBean. By instantiating a RequiredModelMBean, resources are guaranteed that the MBean is valid. MBeanException and RuntimeOperationsException must be thrown on every public method. This allows for wrappering exceptions from distributed communications (RMI, EJB, etc.)
| Constructor Summary | |
| RequiredModelMBean()Constructs an RequiredModelMBeanwith an empty
 ModelMBeanInfo. | |
| RequiredModelMBean(ModelMBeanInfo mbi)Constructs a RequiredModelMBean object using ModelMBeanInfo passed in. | |
| Method Summary | |
|  void | addAttributeChangeNotificationListener(NotificationListener inlistener,
                                       String inAttributeName,
                                       Object inhandback)Registers an object which implements the NotificationListener interface as a listener. | 
|  void | addNotificationListener(NotificationListener listener,
                        NotificationFilter filter,
                        Object handback)Registers an object which implements the NotificationListener interface as a listener. | 
|  Object | getAttribute(String attrName)Returns the value of a specific attribute defined for this ModelMBean. | 
|  AttributeList | getAttributes(String[] attrNames)Returns the values of several attributes in the ModelMBean. | 
| protected  ClassLoaderRepository | getClassLoaderRepository()Return the Class Loader Repository used to perform class loading. | 
|  MBeanInfo | getMBeanInfo()Returns the attributes, operations, constructors and notifications that this RequiredModelMBean exposes for management. | 
|  MBeanNotificationInfo[] | getNotificationInfo()Returns the array of Notifications always generated by the RequiredModelMBean. | 
|  Object | invoke(String opName,
       Object[] opArgs,
       String[] sig)Invokes a method on or through a RequiredModelMBean and returns the result of the method execution. | 
|  void | load()Persistence is not supported by the this Model MBean implementation. | 
|  void | postDeregister()Allows the MBean to perform any operations needed after having been unregistered in the MBean server. | 
|  void | postRegister(Boolean registrationDone)Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed. | 
|  void | preDeregister()Allows the MBean to perform any operations it needs before being unregistered by the MBean server. | 
|  ObjectName | preRegister(MBeanServer server,
            ObjectName name)Allows the MBean to perform any operations it needs before being registered in the MBean server. | 
|  void | removeAttributeChangeNotificationListener(NotificationListener inlistener,
                                          String inAttributeName)Removes a listener for attributeChangeNotifications from the RequiredModelMBean. | 
|  void | removeNotificationListener(NotificationListener listener)Removes a listener for Notifications from the RequiredModelMBean. | 
|  void | removeNotificationListener(NotificationListener listener,
                           NotificationFilter filter,
                           Object handback)Removes a listener from this MBean. | 
|  void | sendAttributeChangeNotification(Attribute inOldVal,
                                Attribute inNewVal)Sends an attributeChangeNotification which contains the old value and new value for the attribute to the registered AttributeChangeNotification listeners on the ModelMBean. | 
|  void | sendAttributeChangeNotification(AttributeChangeNotification ntfyObj)Sends an attributeChangeNotification which is passed in to the registered attributeChangeNotification listeners on the ModelMBean. | 
|  void | sendNotification(Notification ntfyObj)Sends a Notification which is passed in to the registered Notification listeners on the ModelMBean as a jmx.modelmbean.generic notification. | 
|  void | sendNotification(String ntfyText)Sends a Notification which contains the text string that is passed in to the registered Notification listeners on the ModelMBean. | 
|  void | setAttribute(Attribute attribute)Sets the value of a specific attribute of a named ModelMBean. | 
|  AttributeList | setAttributes(AttributeList attributes)Sets the values of an array of attributes of this ModelMBean. | 
|  void | setManagedResource(Object mr,
                   String mr_type)Sets the instance handle of the object against which to execute all methods in this ModelMBean management interface (MBeanInfo and Descriptors). | 
|  void | setModelMBeanInfo(ModelMBeanInfo mbi)Initializes a ModelMBean object using ModelMBeanInfo passed in. | 
|  void | store()Persistence is not supported by the this Model MBean implementation. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
public RequiredModelMBean()
                   throws MBeanException,
                          RuntimeOperationsException
RequiredModelMBean with an empty
 ModelMBeanInfo.
 
 The RequiredModelMBean's MBeanInfo and Descriptors
 can be customized using the setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) method.
 After the RequiredModelMBean's MBeanInfo and Descriptors are 
 customized, the RequiredModelMBean can be registered with 
 the MBeanServer.
MBeanException - Wraps a distributed communication Exception.
RuntimeOperationsException - Wraps a RuntimeException during the construction of the object.public RequiredModelMBean(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) 
 method.
 After the RequiredModelMBean's MBeanInfo and Descriptors are 
 customized, the RequiredModelMBean can be registered with the 
 MBeanServer.
mbi - The ModelMBeanInfo object to be used by the 
            RequiredModelMBean. The given ModelMBeanInfo is cloned 
            and modified as specified by setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo)
MBeanException - Wraps a distributed communication Exception.
RuntimeOperationsException - Wraps an 
    {link java.lang.IllegalArgumentException}:
	        The MBeanInfo passed in parameter is null.| Method Detail | 
public void setModelMBeanInfo(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
 If the ModelMBean is currently registered, this method throws
 a RuntimeOperationsException wrapping an
 IllegalStateException
 
 If the given inModelMBeanInfo does not contain any
 ModelMBeanNotificationInfo for the GENERIC
 or ATTRIBUTE_CHANGE notifications, then the 
 RequiredModelMBean will supply its own default 
 ModelMBeanNotificationInfos for 
 those missing notifications.
setModelMBeanInfo in interface ModelMBeanmbi - The ModelMBeanInfo object to be used 
        by the ModelMBean.
MBeanException - Wraps a distributed communication 
        Exception.
RuntimeOperationsException - IllegalArgumentException if
         the MBeanInfo passed in parameter is null.IllegalStateException if the ModelMBean 
         is currently registered in the MBeanServer.public void setManagedResource(Object mr, String mr_type) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException
setManagedResource in interface ModelMBeanmr - Object that is the managed resourcemr_type - The type of reference for the managed resource.  
     MBeanException - The initializer of the object has
            thrown an exception.
InstanceNotFoundException - The managed resource
            object could not be found
InvalidTargetObjectTypeException - The managed
            resource type should be "ObjectReference".
RuntimeOperationsException - Wraps a RuntimeException when setting the resource.
public void load()
          throws MBeanException,
                 RuntimeOperationsException,
                 InstanceNotFoundException
ServiceNotFoundException 
 is thrown.
load in interface PersistentMBeanMBeanException - Wraps another exception or persistence is not supported
InstanceNotFoundException - Could not find or load this MBean from persistent
                                      storage
RuntimeOperationsException - Wraps exceptions from the persistence mechanism
public void store()
           throws MBeanException,
                  RuntimeOperationsException,
                  InstanceNotFoundException
ServiceNotFoundException is 
 thrown.
store in interface PersistentMBeanInstanceNotFoundException - Could not find/access the persistant store
MBeanException - Wraps another exception or persistence is not supported
RuntimeOperationsException - Wraps exceptions from the persistence mechanismpublic MBeanInfo getMBeanInfo()
getMBeanInfo in interface DynamicMBeanpublic Object invoke(String opName, Object[] opArgs, String[] sig) throws MBeanException, ReflectionException
If the given method to be invoked, together with the provided signature, matches one of RequiredModelMbean accessible methods, this one will be call. Otherwise the call to the given method will be tried on the managed ressource.
The last value returned by an operation may be cached in the operation's descriptor which is in the ModelMBeanOperationInfo's descriptor. The valid value will be in the 'value' field if there is one. If the 'currencyTimeLimit' field in the descriptor is:
invoke in interface DynamicMBeanopName - The name of the method to be invoked. The
     name can be the fully qualified method name including the
     classname, or just the method name if the classname is
     defined in the 'class' field of the operation descriptor.opArgs - An array containing the parameters to be set
     when the operation is invokedsig - An array containing the signature of the
     operation. The class objects will be loaded using the same
     class loader as the one used for loading the MBean on which
     the operation was invoked.
MBeanException - Wraps one of the following Exceptions:
 ServiceNotFoundException: No ModelMBeanOperationInfo or 
      no descriptor defined for the specified operation or the managed 
      resource is null.InvalidTargetObjectTypeException: The 'targetType' 
      field value is not 'objectReference'.ReflectionException - Wraps an Exception
      thrown while trying to invoke the method.
RuntimeOperationsException - Wraps an 
      IllegalArgumentException Method name is null.public Object getAttribute(String attrName) throws AttributeNotFoundException, MBeanException, ReflectionException
getAttribute in interface DynamicMBeanattrName - A String specifying the name of the
 attribute to be retrieved. It must match the name of a
 ModelMBeanAttributeInfo.
AttributeNotFoundException - The specified attribute is
    not accessible in the MBean.
    The following cases may result in an AttributeNotFoundException:
    MBeanException - Wraps one of the following Exceptions:
    InvalidAttributeValueException: A wrong value type 
           was received from the attribute's getter method or 
           no 'getMethod' field defined in the descriptor for 
           the attribute and no default value exists.ServiceNotFoundException: No 
           ModelMBeanOperationInfo defined for the attribute's 
           getter method or no descriptor associated with the 
           ModelMBeanOperationInfo or the managed resource is 
           null.InvalidTargetObjectTypeException The 'targetType'
           field value is not 'objectReference'.ReflectionException - Wraps an Exception
    thrown while trying to invoke the getter.
RuntimeOperationsException - Wraps an 
    IllegalArgumentException: The attribute name in 
    parameter is null.setAttribute(javax.management.Attribute)public AttributeList getAttributes(String[] attrNames)
getAttributes in interface DynamicMBeanattrNames - A String array of names of the attributes
 to be retrieved.
RuntimeOperationsException - Wraps an
 IllegalArgumentException: The object name in parameter is
 null or attributes in parameter is null.setAttributes(javax.management.AttributeList)public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
If currencyTimeLimit is > 0, then the new value for the attribute is cached in the attribute descriptor's 'value' field and the 'lastUpdatedTimeStamp' field is set to the current time stamp.
If the persist field of the attribute's descriptor is not null 
 then Persistance policy from the attribute descriptor is used to 
 guide storing the attribute in a persistent store.
 
Store the MBean if 'persistPolicy' field is:
 
The ModelMBeanInfo of the Model MBean is stored in a file.
setAttribute in interface DynamicMBeanattribute - The Attribute instance containing the name of 
        the attribute to be set and the value it is to be set to.
AttributeNotFoundException - The specified attribute is 
   not accessible in the MBean.
   InvalidAttributeValueException - No descriptor is defined 
   for the specified attribute.
MBeanException - Wraps one of the following Exceptions:
   ServiceNotFoundException if no `setMethod` field
          is defined in the descriptor for the attribute or the 
          managed resource is null.InvalidTargetObjectTypeException The 'targetType'
          field value is not 'objectReference'.ReflectionException - Wraps an Exception
   thrown while trying to invoke the setter.
RuntimeOperationsException - Wraps an 
   IllegalArgumentException: The attribute in parameter is 
   null.getAttribute(java.lang.String)public AttributeList setAttributes(AttributeList attributes)
setAttributes in interface DynamicMBeanattributes - A list of attributes: The identification of the
 attributes to be set and  the values they are to be set to.
RuntimeOperationsException - Wraps an 
   IllegalArgumentException: The object name in parameter 
   is null or attributes in parameter is null.getAttributes(java.lang.String[])public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException
addNotificationListener in interface NotificationBroadcasterlistener - The listener object which will handles 
        notifications emitted by the registered MBean.filter - The filter object. If null, no filtering will be 
        performed before handling notifications.handback - The context to be sent to the listener with 
        the notification when a notification is emitted.
IllegalArgumentException - The listener cannot be null.removeNotificationListener(javax.management.NotificationListener)public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
removeNotificationListener in interface NotificationBroadcasterlistener - The listener name which was handling notifications 
    emitted by the registered MBean.
    This method will remove all information related to this listener.
ListenerNotFoundException - The listener is not registered
    in the MBean or is null.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException
NotificationEmitterRemoves a listener from this MBean.  The MBean must have a
 listener that exactly matches the given listener,
 filter, and handback parameters.  If
 there is more than one such listener, only one is removed.
The filter and handback parameters
 may be null if and only if they are null in a listener to be
 removed.
removeNotificationListener in interface NotificationEmitterlistener - A listener that was previously added to this
 MBean.filter - The filter that was specified when the listener
 was added.handback - The handback that was specified when the listener was
 added.
ListenerNotFoundException - The listener is not
 registered with the MBean, or it is not registered with the
 given filter and handback.public void sendNotification(Notification ntfyObj) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcaster
sendNotification in interface ModelMBeanNotificationBroadcasterntfyObj - The notification which is to be passed to
 the 'handleNotification' method of the listener object.
MBeanException - Wraps a distributed communication Exception.
RuntimeOperationsException - Wraps an IllegalArgumentException: 
       The Notification object passed in parameter is null.public void sendNotification(String ntfyText) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcaster
sendNotification in interface ModelMBeanNotificationBroadcasterntfyText - The text which is to be passed in the Notification to the 'handleNotification'
 method of the listener object.  
 the constructed Notification will be:
   type        "jmx.modelmbean.generic"
   source      this ModelMBean instance
   sequence    1
MBeanException - Wraps a distributed communication Exception.
RuntimeOperationsException - Wraps an IllegalArgumentException: 
       The Notification text string passed in parameter is null.public MBeanNotificationInfo[] getNotificationInfo()
RequiredModelMBean may always send also two additional notifications:
"name=GENERIC,descriptorType=notification,log=T,severity=5,displayName=jmx.modelmbean.generic""name=ATTRIBUTE_CHANGE,descriptorType=notification,log=T,severity=5,displayName=jmx.attribute.change"
getNotificationInfo in interface NotificationBroadcasterpublic void addAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName, Object inhandback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException
ModelMBeanNotificationBroadcaster
addAttributeChangeNotificationListener in interface ModelMBeanNotificationBroadcasterinlistener - The listener object which will handles notifications emitted by the registered MBean.inAttributeName - The name of the ModelMBean attribute for which to receive change notifications.
      If null, then all attribute changes will cause an attributeChangeNotification to be issued.inhandback - The context to be sent to the listener with the notification when a notification is emitted.
IllegalArgumentException - The listener cannot be null.
RuntimeOperationsException - Wraps an IllegalArgumentException The attribute name passed in parameter does not exist.
MBeanException - Wraps a distributed communication Exception.ModelMBeanNotificationBroadcaster.removeAttributeChangeNotificationListener(javax.management.NotificationListener, java.lang.String)public void removeAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException
ModelMBeanNotificationBroadcaster
removeAttributeChangeNotificationListener in interface ModelMBeanNotificationBroadcasterinlistener - The listener name which was handling notifications emitted by the registered MBean.
 This method will remove all information related to this listener.inAttributeName - The attribute for which the listener no longer wants to receive attributeChangeNotifications.
 If null the listener will be removed for all attributeChangeNotifications.
MBeanException - Wraps a distributed communication Exception.
ListenerNotFoundException - The listener is not registered in the MBean or is null.
RuntimeOperationsException - Wraps an IllegalArgumentException If the inAttributeName parameter does not
 correspond to an attribute name.ModelMBeanNotificationBroadcaster.addAttributeChangeNotificationListener(javax.management.NotificationListener, java.lang.String, java.lang.Object)public void sendAttributeChangeNotification(AttributeChangeNotification ntfyObj) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcaster
sendAttributeChangeNotification in interface ModelMBeanNotificationBroadcasterntfyObj - The notification which is to be passed
 to the 'handleNotification' method of the listener object.
RuntimeOperationsException - Wraps an IllegalArgumentException: The AttributeChangeNotification object passed in parameter is null.
MBeanException - Wraps a distributed communication Exception.public void sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcaster
sendAttributeChangeNotification in interface ModelMBeanNotificationBroadcasterinOldVal - The origional value for the AttributeinNewVal - The current value for the Attribute
The constructed attributeChangeNotification will be: type "jmx.attribute.change" source this ModelMBean instance sequence 1 attributeName oldValue.getName() attributeType oldValue's class attributeOldValue oldValue.getValue() attributeNewValue newValue.getValue()
MBeanException - Wraps a distributed communication Exception.
RuntimeOperationsException - Wraps an IllegalArgumentException: An Attribute object passed in parameter is null
 or the names of the two Attribute objects in parameter are not the same.protected ClassLoaderRepository getClassLoaderRepository()
ClassLoaderRepository
 that should be used in this object.
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
 In order to ensure proper run-time semantics of RequireModelMBean,
 Any subclass of RequiredModelMBean overloading or overriding this 
 method should call super.preRegister(server, name) 
 in its own preRegister implementation.
preRegister in interface MBeanRegistrationserver - The MBean server in which the MBean will be registered.name - 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
 parameter is not null, it will usually but not necessarily be
 the returned value.
Exception - This exception will be caught by
 the MBean server and re-thrown as an MBeanRegistrationException
 or a RuntimeMBeanException.public void postRegister(Boolean registrationDone)
 In order to ensure proper run-time semantics of RequireModelMBean,
 Any subclass of RequiredModelMBean overloading or overriding this 
 method should call super.postRegister(registrationDone)
 in its own postRegister implementation.
postRegister in interface MBeanRegistrationregistrationDone - Indicates whether or not the MBean has
 been successfully registered in the MBean server. The value
 false means that the registration phase has failed.
public void preDeregister()
                   throws Exception
 In order to ensure proper run-time semantics of RequireModelMBean,
 Any subclass of RequiredModelMBean overloading or overriding this 
 method should call super.preDeregister() in its own
 preDeregister implementation.
preDeregister in interface MBeanRegistrationException - This exception will be caught by
 the MBean server and re-thrown as an MBeanRegistrationException
 or a RuntimeMBeanException.public void postDeregister()
 In order to ensure proper run-time semantics of RequireModelMBean,
 Any subclass of RequiredModelMBean overloading or overriding this 
 method should call super.postDeregister() in its own
 postDeregister implementation.
postDeregister in interface MBeanRegistration| 
 | JavaTM 2 Platform Ent. Ed. v1.4 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright 2003 Sun Microsystems, Inc. All rights reserved.