|
Spec-Zone .ru
спецификации, руководства, описания, API
|
public class RequiredModelMBean extends Object implements ModelMBean, MBeanRegistration, NotificationEmitter
Ресурсы Java, желающие быть управляемыми, инстанцируют RequiredModelMBean, используя createMBean метод MBeanServer. Ресурс тогда устанавливает MBeanInfo и Дескрипторы для экземпляра RequiredModelMBean. Атрибуты и операции, представленные через ModelMBeanInfo для ModelMBean, доступны от MBeans, соединителей/адаптеров как другой MBeans. Через Дескрипторы значения и методы в управляемом приложении могут быть определены и отображены на атрибуты и операции ModelMBean. Это отображение может быть определено в XML отформатированный файл или динамически и программно во времени выполнения.
Каждый RequiredModelMBean, который инстанцируют в MBeanServer, становится управляемым:
его атрибуты и операции становятся удаленно доступными через соединители/адаптеры, соединенные с тем MBeanServer.
Объект Java не может быть зарегистрирован в MBeanServer, если это не совместимый MBean JMX. Инстанцируя RequiredModelMBean, ресурсам гарантируют это, MBean допустим. MBeanException и RuntimeOperationsException должны быть брошены в каждый открытый метод. Это учитывает переносящиеся исключения из распределенной связи (RMI, EJB, и т.д.)
| Конструктор и Описание |
|---|
RequiredModelMBean()
Конструкции
RequiredModelMBean с пустым ModelMBeanInfo. |
RequiredModelMBean(ModelMBeanInfo mbi)
Создает объект RequiredModelMBean использование ModelMBeanInfo, в котором передают.
|
| Модификатор и Тип | Метод и Описание |
|---|---|
void |
addAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName, Object inhandback)
Регистрирует объект, который реализует интерфейс NotificationListener как слушателя.
|
void |
addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
Регистрирует объект, который реализует интерфейс NotificationListener как слушателя.
|
Объект |
getAttribute(String attrName)
Возвращает значение определенного атрибута, определенного для этого ModelMBean.
|
AttributeList |
getAttributes(String[] attrNames)
Возвращает значения нескольких атрибутов в ModelMBean.
|
protected ClassLoaderRepository |
getClassLoaderRepository()
Возвратите Репозитарий Загрузчика Класса, используемый, чтобы выполнить загрузку class.
|
MBeanInfo |
getMBeanInfo()
Возвращает атрибуты, операции, конструкторов и уведомления, что этот RequiredModelMBean представляет для управления.
|
MBeanNotificationInfo[] |
getNotificationInfo()
Возвращает массив Уведомлений, всегда сгенерированных RequiredModelMBean.
|
Объект |
invoke(String opName, Object[] opArgs, String[] sig)
Вызывает метод на или через RequiredModelMBean и возвращает результат выполнения метода.
|
void |
load()
Инстанцирует этого экземпляра MBean с данными, найденными для MBean в персистентном хранилище.
|
void |
postDeregister()
Позволяет MBean выполнять любые операции, необходимые будучи незарегистрированным в сервере MBean.
|
void |
postRegister(Boolean registrationDone)
Позволяет MBean выполнять любые операции, необходимые, будучи зарегистрированным в сервере MBean или после того, как регистрация перестала работать.
|
void |
preDeregister()
Позволяет MBean выполнять любые операции, в которых он нуждается перед стать незарегистрированным сервером MBean.
|
ObjectName |
preRegister(MBeanServer server, ObjectName name)
Позволяет MBean выполнять любые операции, в которых он нуждается прежде, чем быть зарегистрированным в сервере MBean.
|
void |
removeAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName)
Удаляет слушателя для attributeChangeNotifications из RequiredModelMBean.
|
void |
removeNotificationListener(NotificationListener listener)
Удаляет слушателя для Уведомлений из RequiredModelMBean.
|
void |
removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
Удаляет слушателя из этого MBean.
|
void |
sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal)
Отправляет attributeChangeNotification, который содержит старое значение и новое значение для атрибута зарегистрированным слушателям AttributeChangeNotification на ModelMBean.
|
void |
sendAttributeChangeNotification(AttributeChangeNotification ntfyObj)
Отправляет attributeChangeNotification, в котором передают зарегистрированным attributeChangeNotification слушателям на ModelMBean.
|
void |
sendNotification(Notification ntfyObj)
Отправляет Уведомление, в котором передают зарегистрированным слушателям Уведомления на ModelMBean как jmx.modelmbean.generic уведомление.
|
void |
sendNotification(String ntfyText)
Отправляет Уведомление, которое содержит текстовую строку, в которой передают зарегистрированным слушателям Уведомления на ModelMBean.
|
void |
setAttribute(Attribute attribute)
Устанавливает значение определенного атрибута именованного ModelMBean.
|
AttributeList |
setAttributes(AttributeList attributes)
Устанавливает значения массива атрибутов этого ModelMBean.
|
void |
setManagedResource(Object mr, String mr_type)
Устанавливает описатель экземпляра объекта, против которого можно выполнить все методы в этом интерфейсе управления ModelMBean (MBeanInfo и Дескрипторы).
|
void |
setModelMBeanInfo(ModelMBeanInfo mbi)
Инициализирует объект ModelMBean использование ModelMBeanInfo, в котором передают.
|
void |
store()
Получает текущее состояние этого экземпляра MBean и выписывает это к персистентному хранилищу.
|
public RequiredModelMBean()
throws MBeanException,
RuntimeOperationsException
RequiredModelMBean с пустым ModelMBeanInfo. MBeanInfo RequiredModelMBean и Дескрипторы могут быть настроены, используя setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) метод. После того, как MBeanInfo RequiredModelMBean и Дескрипторы настраиваются, RequiredModelMBean может быть зарегистрирован в MBeanServer.
MBeanException - Обертывает распределенное коммуникационное Исключение.RuntimeOperationsException - Обертки a RuntimeException во время конструкции объекта.public RequiredModelMBean(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) метод. После того, как MBeanInfo RequiredModelMBean и Дескрипторы настраиваются, RequiredModelMBean может быть зарегистрирован в MBeanServer.mbi - ModelMBeanInfo возражают, чтобы использоваться RequiredModelMBean. Данный ModelMBeanInfo клонируется и изменяется как определено setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo)MBeanException - Обертывает распределенное коммуникационное Исключение.RuntimeOperationsException - Переносится {соединяют java.lang. IllegalArgumentException}: MBeanInfo, который передают в параметре, является нулем.public void setModelMBeanInfo(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
Если ModelMBean в настоящий момент регистрируется, этот метод бросает a RuntimeOperationsException обертывание IllegalStateException
Если данный inModelMBeanInfo не содержит никого ModelMBeanNotificationInfo для GENERIC или ATTRIBUTE_CHANGE уведомления, тогда RequiredModelMBean предоставит свое собственное значение по умолчанию ModelMBeanNotificationInfos для тех недостающие уведомления.
setModelMBeanInfo в интерфейсе ModelMBeanmbi - ModelMBeanInfo возражают, чтобы использоваться ModelMBean.MBeanException - Обертывает распределенное коммуникационное Исключение.RuntimeOperationsException - IllegalArgumentException если MBeanInfo, который передают в параметре, является нулем.IllegalStateException если ModelMBean в настоящий момент регистрируется в MBeanServer.public void setManagedResource(Object mr, String mr_type) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException
setManagedResource в интерфейсе ModelMBeanmr - Объект, который является управляемым ресурсомmr_type - Тип ссылки для управляемого ресурса. MBeanException - Инициализатор объекта выдал исключение.InstanceNotFoundException - Объект управляемого ресурса не мог быть найденInvalidTargetObjectTypeException - Тип управляемого ресурса должен быть "ObjectReference".RuntimeOperationsException - Обертки a RuntimeException устанавливая ресурс.public void load()
throws MBeanException,
RuntimeOperationsException,
InstanceNotFoundException
Инстанцирует этого экземпляра MBean с данными, найденными для MBean в персистентном хранилище. Загруженные данные могли включать значения работы и атрибут.
Этот метод нужно вызвать во время конструкции или инициализации этого экземпляра, и прежде, чем MBean будет зарегистрирован в MBeanServer.
Если реализация этого class не поддерживает персистентность, MBeanException обертывание a ServiceNotFoundException бросается.
load в интерфейсе PersistentMBeanMBeanException - Обертки другое исключение, или персистентность не поддерживаетсяRuntimeOperationsException - Исключения оберток из механизма персистентностиInstanceNotFoundException - Не мог найти или загрузить этот MBean из персистентного храненияpublic void store()
throws MBeanException,
RuntimeOperationsException,
InstanceNotFoundException
Получает текущее состояние этого экземпляра MBean и выписывает это к персистентному хранилищу. Сохраненное состояние могло включать значения работы и атрибут.
Если реализация этого class не поддерживает персистентность, MBeanException обертывание a ServiceNotFoundException бросается.
Политика персистентности от MBean и дескриптора атрибута используется, чтобы вести выполнение этого метода. MBean должен быть сохранен, если 'persistPolicy' поле:
!= "never" = "always" = "onTimer" and now > 'lastPersistTime' + 'persistPeriod' = "NoMoreOftenThan" and now > 'lastPersistTime' + 'persistPeriod' = "onUnregister"
Не храните MBean, если 'persistPolicy' поле:
= "never"
= "onUpdate"
= "onTimer" && now < 'lastPersistTime' + 'persistPeriod'
store in interface PersistentMBeanMBeanException - Wraps another exception, or
persistence is not supportedRuntimeOperationsException - Wraps exceptions from the
persistence mechanismInstanceNotFoundException - Could not find/access the
persistent storepublic 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 resource.
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:
Note: because of inconsistencies in previous versions of
this specification, it is recommended not to use negative or zero
values for currencyTimeLimit. To indicate that a
cached value is never valid, omit the
currencyTimeLimit field. To indicate that it is
always valid, use a very large number for this field.
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
Note: because of inconsistencies in previous versions of
this specification, it is recommended not to use negative or zero
values for currencyTimeLimit. To indicate that a
cached value is never valid, omit the
currencyTimeLimit field. To indicate that it is
always valid, use a very large number for this field.
If the 'getMethod' field contains the name of a valid operation descriptor, then the method described by the operation descriptor is executed. The response from the method is returned as the value of the attribute. If the operation fails or the returned value is not compatible with the declared type of the attribute, an exception will be thrown.
If no 'getMethod' field is defined then the default value of the attribute is returned. If the returned value is not compatible with the declared type of the attribute, an exception will be thrown.
The declared type of the attribute is the String returned by
MBeanAttributeInfo.getType(). A value is compatible
with this type if one of the following is true:
In this implementation, in every case where the getMethod needs to be called, because the method is invoked through the standard "invoke" method and thus needs operationInfo, an operation must be specified for that getMethod so that the invocation works correctly.
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 Persistence 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 a setMethod field is
defined in the descriptor for the attribute and the managed
resource is null; or if no setMethod field is defined and
caching is not enabled for the attribute.
Note that if there is no getMethod field either, then caching
is automatically enabled.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
ModelMBeanNotificationBroadcastersendNotification 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
ModelMBeanNotificationBroadcastersendNotification 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 1MBeanException - 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=6,displayName=jmx.modelmbean.generic""name=ATTRIBUTE_CHANGE,descriptorType=notification,log=T,severity=6,displayName=jmx.attribute.change"getNotificationInfo in interface NotificationBroadcasterpublic void addAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName, Object inhandback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException
ModelMBeanNotificationBroadcasteraddAttributeChangeNotificationListener 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.MBeanException - Wraps a distributed communication Exception.RuntimeOperationsException - Wraps an IllegalArgumentException The attribute name passed in parameter does not exist.IllegalArgumentException - The listener cannot be null.ModelMBeanNotificationBroadcaster.removeAttributeChangeNotificationListener(javax.management.NotificationListener, java.lang.String)public void removeAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException
ModelMBeanNotificationBroadcasterremoveAttributeChangeNotificationListener 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.RuntimeOperationsException - Wraps an IllegalArgumentException If the inAttributeName parameter does not
correspond to an attribute name.ListenerNotFoundException - The listener is not registered in the MBean or is null.ModelMBeanNotificationBroadcaster.addAttributeChangeNotificationListener(javax.management.NotificationListener, java.lang.String, java.lang.Object)public void sendAttributeChangeNotification(AttributeChangeNotification ntfyObj) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcastersendAttributeChangeNotification 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 AttributeChangeNotification object passed in parameter is null.public void sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcastersendAttributeChangeNotification in interface ModelMBeanNotificationBroadcasterinOldVal - The original 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.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.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
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2013, Oracle and/or its affiliates. All rights reserved.
DRAFT ea-b92