public class RequiredModelMBean extends Object implements ModelMBean, MBeanRegistration, NotificationEmitter
java资源希望能够实例化个MBeanServer creatembean方法的使用。资源再设置mbeaninfo和描述符个实例。属性和操作通过ModelMBean ModelMBeanInfo暴露可从MBean,连接器/适配器像其他MBeans。通过描述,在托管的应用价值和方法可以被定义和映射到的ModelMBean属性和操作。这个映射可以在XML格式的文件或程序在运行时动态定义和。
一个是容易管理:
MBeanServer实例化它的属性和操作成为远程访问连接,通过MBeanServer连接器/适配器。
一个java对象不能注册MBeanServer除非是JMX兼容MBean。通过实例化一个,资源是保证MBean是有效的。mbeanexception和runtimeoperationsexception必须扔在每个公共方法。这使得包装从分布式通信异常(RMI、EJB、等)
Constructor and Description |
---|
RequiredModelMBean()
构建一个空的
RequiredModelMBean ModelMBeanInfo。
|
RequiredModelMBean(ModelMBeanInfo mbi)
构建一个使用了个ModelMBeanInfo对象。
|
Modifier and Type | Method and Description |
---|---|
void |
addAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName, Object inhandback)
寄存器实现了notificationlistener接口作为一个侦听器的对象。
|
void |
addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
寄存器实现了notificationlistener接口作为一个侦听器的对象。
|
Object |
getAttribute(String attrName)
返回此ModelMBean定义特定属性的值。
|
AttributeList |
getAttributes(String[] attrNames)
返回在ModelMBean几个属性的值。
|
protected ClassLoaderRepository |
getClassLoaderRepository()
返回用于执行类加载的类加载程序库。
|
MBeanInfo |
getMBeanInfo()
返回属性、操作、建设者和通知,RequiredModelMBean公开管理。
|
MBeanNotificationInfo[] |
getNotificationInfo()
返回数组的通知总是个生成。
|
Object |
invoke(String opName, Object[] opArgs, String[] sig)
调用或通过一个方法,返回执行结果的方法。
|
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从听众。
|
void |
removeNotificationListener(NotificationListener listener)
删除一个监听器的通知。
|
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)
初始化使用ModelMBeanInfo ModelMBean对象了。
|
void |
store()
抓住了这个MBean实例的当前状态,并将它写入到持久性存储。
|
public RequiredModelMBean() throws MBeanException, RuntimeOperationsException
RequiredModelMBean
ModelMBeanInfo。
个的mbeaninfo和描述符可以使用setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo)
方法定制。个的mbeaninfo和描述符是个定制后,可以注册MBeanServer。
MBeanException
套分布式通信异常。
RuntimeOperationsException
-包装
RuntimeException
对象的施工。
public RequiredModelMBean(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo)
方法定制。个的mbeaninfo和描述符是个定制后,可以注册MBeanServer。
mbi
- ModelMBeanInfo对象是个习惯。克隆和修饰所指定的
setModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo)
给定ModelMBeanInfo
MBeanException
套分布式通信异常。
RuntimeOperationsException
-包装{链接java。IllegalArgumentException }:的mbeaninfo传入参数为空。
public void setModelMBeanInfo(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
如果ModelMBean现在注册,该方法抛出一个RuntimeOperationsException
包装IllegalStateException
如果给定的inmodelmbeaninfo不包含对GENERIC
或ATTRIBUTE_CHANGE
通知任何ModelMBeanNotificationInfo
,然后将那些个失踪通知供应自己的默认ModelMBeanNotificationInfo
s。
setModelMBeanInfo
接口
ModelMBean
mbi
- ModelMBeanInfo对象由ModelMBean使用。
MBeanException
套分布式通信异常。
RuntimeOperationsException
-
IllegalArgumentException
如果mbeaninfo传入参数为空。IllegalStateException
如果ModelMBean目前注册MBeanServer。public void setManagedResource(Object mr, String mr_type) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException
setManagedResource
接口
ModelMBean
mr
对象是托管资源
mr_type
-托管资源参考类型。
MBeanException
-对象初始化了一个例外。
InstanceNotFoundException
非托管资源的对象不能被发现
InvalidTargetObjectTypeException
-托管资源类型应该是“对象引用”。
RuntimeOperationsException
-包装
RuntimeException
设置资源时。
public void load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
实例化这个MBean实例与数据发现在持久存储的MBean。加载的数据可以包括属性和操作值。
这种方法应该是这个实例创建或初始化期间调用,和之前的MBean是注册MBeanServer。
如果这个类的实现不支持持久化,一个MBeanException
包ServiceNotFoundException
抛出。
load
接口
PersistentMBean
MBeanException
包另一个例外,或坚持不支持
RuntimeOperationsException
包从持久性机制的例外
InstanceNotFoundException
-找不到或者从持久性存储区加载这个MBean
public void store() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException
抓住了这个MBean实例的当前状态,并将它写入到持久性存储。存储的状态可以包括属性和操作值。
如果这个类的实现不支持持久化,一个MBeanException
包ServiceNotFoundException
抛出。
从MBean属性描述符的持久性策略用于指导本法执行。MBean应该如果persistpolicy”字段存储:
!“永远”“总是”=“>”lastpersisttime OnTimer”和现在的“+”persistperiod”=“nomoreoftenthan”和现在的“+”> lastpersisttime persistperiod”=“onunregister”
不要存储MBean如果persistpolicy场:
“永远”=“更新”=“OnTimer”和现在的“+”<< lastpersisttime persistperiod”
store
接口
PersistentMBean
MBeanException
包另一个例外,或坚持不支持
RuntimeOperationsException
包从持久性机制的例外
InstanceNotFoundException
-找不到/访问持久性存储
public MBeanInfo getMBeanInfo()
getMBeanInfo
接口
DynamicMBean
public Object invoke(String opName, Object[] opArgs, String[] sig) throws MBeanException, ReflectionException
如果该方法被调用,连同提供签名,符合其中一个方便的方法,这将是一个电话。否则,将对所给方法的调用将在托管资源上进行尝试。
最后通过一个操作返回的值可以被缓存在操作的描述符,在modelmbeanoperationinfo的描述符。如果有一个有效值,则将在“值”字段中。如果在描述“currencyTimeLimit场:
注:由于在本规范的早期版本不一致,建议不要使用负数或零值currencyTimeLimit
。显示缓存的值是永远有效,省略currencyTimeLimit
场。为了表示它始终是有效的,为这个字段使用一个非常大的数字。
invoke
接口
DynamicMBean
opName
-名称的方法被调用。该名称可以是完全限定的类名或方法名等,只是方法名称如果类名是在操作的描述符的“班级”字段定义。
opArgs
-一个数组包含的参数设置操作时调用
sig
-一个数组包含的操作签名。该类的对象将使用相同的类装载器是用于装载MBean操作的调用加载。
MBeanException
包下面的一个例外:
ServiceNotFoundException
:没有modelmbeanoperationinfo或没有描述符定义为指定的操作或管理的资源是空的。InvalidTargetObjectTypeException
:“TargetType”字段的值是不是“对象引用”。ReflectionException
-包装
异常
扔在试图调用的方法。
RuntimeOperationsException
-包装
IllegalArgumentException
方法名称为空。
public Object getAttribute(String attrName) throws AttributeNotFoundException, MBeanException, ReflectionException
注:由于在本规范的早期版本不一致,建议不要使用负数或零值currencyTimeLimit
。显示缓存的值是永远有效,省略currencyTimeLimit
场。为了表示它始终是有效的,为这个字段使用一个非常大的数字。
如果“方法”字段包含一个有效的操作描述的名字,然后由描述符描述方法操作执行。返回该方法的响应作为属性的值。如果操作失败或返回的值与所声明的属性类型不兼容,将引发一个异常。
如果没有'中的字段定义的属性的默认值。如果返回的值与所声明的属性类型不兼容,将引发一个异常。
声明的类型属性返回的字符串MBeanAttributeInfo.getType()
。如果下面是真值与此类型兼容:
在这个实现中,在每一个情况中需要被调用,因为调用的方法是通过标准的“引用”的方法,因此需要operationinfo,操作必须被指定,所以调用的正确工作方法。
getAttribute
接口
DynamicMBean
attrName
-指定要检索的属性的名称。它必须有modelmbeanattributeinfo匹配的名字。
AttributeNotFoundException
-指定属性的MBean无法访问。以下情况可能会导致attributenotfoundexception:
MBeanException
包下面的一个例外:
InvalidAttributeValueException
:错误的值类型是从属性的getter方法或没有“中”字段描述符中的属性没有默认值定义了存在。ServiceNotFoundException
:为属性的getter方法没有与modelmbeanoperationinfo或托管资源相关的描述符定义没有modelmbeanoperationinfo是空的。InvalidTargetObjectTypeException
“TargetType”字段的值是不是“对象引用”。ReflectionException
-包装
异常
扔在试图调用getter。
RuntimeOperationsException
-包装
IllegalArgumentException
:参数属性名称是空的。
setAttribute(javax.management.Attribute)
public AttributeList getAttributes(String[] attrNames)
getAttributes
接口
DynamicMBean
attrNames
-字符串数组的属性名称进行检索。
RuntimeOperationsException
-包装
IllegalArgumentException
:参数对象名称参数为空或属性为空。
setAttributes(javax.management.AttributeList)
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
如果currencyTimeLimit>0,那么新的价值属性中缓存的属性描述符的值”字段和“lastupdatedtimestamp”字段设置为当前时间戳。
如果属性描述符的持久字段不为空,则使用属性描述符的持久性策略来引导存储在持久存储中的属性。
store MBean如果persistpolicy场:
该模型MBean ModelMBeanInfo是存储在一个文件中。
setAttribute
接口
DynamicMBean
attribute
包含要设置的属性的名称的属性的实例,它是被设定的价值。
AttributeNotFoundException
-指定属性的MBean无法访问。
InvalidAttributeValueException
没有描述为指定的属性定义。
MBeanException
包下面的一个例外:
ServiceNotFoundException
如果setMethod场在描述符的属性和管理资源是无效的定义;如果没有setMethod定义字段和属性缓存不启用。请注意,如果没有中场,然后缓存自动启用。InvalidTargetObjectTypeException
“TargetType”字段的值是不是“对象引用”。ReflectionException
-包装
异常
扔在试图调用setter。
RuntimeOperationsException
-包装
IllegalArgumentException
:参数的属性为空。
getAttribute(java.lang.String)
public AttributeList setAttributes(AttributeList attributes)
setAttributes
接口
DynamicMBean
attributes
-目录属性:属性的识别是集和它们的值被设置为。
RuntimeOperationsException
-包装
IllegalArgumentException
:参数对象名称参数为空或属性为空。
getAttributes(java.lang.String[])
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException
addNotificationListener
接口
NotificationBroadcaster
listener
-监听器对象将处理由注册MBean发出通知。
filter
-滤波对象。如果为空,则在处理通知之前不执行任何过滤。
handback
的语境中被发送到通知的侦听器的通知时发出的。
IllegalArgumentException
-听者不能为空。
removeNotificationListener(javax.management.NotificationListener)
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
removeNotificationListener
接口
NotificationBroadcaster
listener
听众的名字是处理由注册MBean发出通知。此方法将删除与此侦听器相关的所有信息。
ListenerNotFoundException
-听者不在MBean注册或空。
addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException
NotificationEmitter
从这个MBean移除侦听器。MBean必须完全匹配listener
听众了,filter
,和handback
参数。如果有多于一个这样的侦听器,只有一个被删除。
的filter
和handback
参数可以为null,如果他们在听众被删除是空的。
removeNotificationListener
接口
NotificationEmitter
listener
-听者以前添加到这个MBean。
filter
-过滤器,当你添加指定的。
handback
-盖印,指定当听众加入。
ListenerNotFoundException
-听者不是MBean注册,或不与给定的滤波器和盖印注册。
public void sendNotification(Notification ntfyObj) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcaster
sendNotification
接口
ModelMBeanNotificationBroadcaster
ntfyObj
的通知是通过对监听对象的handlenotification法。
MBeanException
套分布式通信异常。
RuntimeOperationsException
包IllegalArgumentException:通过参数的通知对象是无效的。
public void sendNotification(String ntfyText) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcaster
sendNotification
接口
ModelMBeanNotificationBroadcaster
ntfyText
-这是在通知的侦听器对象的handlenotification法通过文本。构建的通知将:键入“JMX。ModelMBean。通用的“源本ModelMBean实例序列1
MBeanException
套分布式通信异常。
RuntimeOperationsException
包IllegalArgumentException:通知文本传入的字符串参数为空。
public MBeanNotificationInfo[] getNotificationInfo()
个可能总是给另外两个通知:
"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
接口
NotificationBroadcaster
public void addAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName, Object inhandback) throws MBeanException, RuntimeOperationsException, IllegalArgumentException
ModelMBeanNotificationBroadcaster
addAttributeChangeNotificationListener
接口
ModelMBeanNotificationBroadcaster
inlistener
-监听器对象将处理由注册MBean发出通知。
inAttributeName
-为ModelMBean属性名称接收更改通知。如果为空,那么所有的属性的变化会引起attributechangenotification签发。
inhandback
的语境中被发送到通知的侦听器的通知时发出的。
MBeanException
套分布式通信异常。
RuntimeOperationsException
-包装传入参数的属性名称不存在时。
IllegalArgumentException
-听者不能为空。
ModelMBeanNotificationBroadcaster.removeAttributeChangeNotificationListener(javax.management.NotificationListener, java.lang.String)
public void removeAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException
ModelMBeanNotificationBroadcaster
removeAttributeChangeNotificationListener
接口
ModelMBeanNotificationBroadcaster
inlistener
听众的名字是处理由注册MBean发出通知。此方法将删除与此侦听器相关的所有信息。
inAttributeName
-属性,听众不再愿意接受attributechangenotifications。如果为空,听者将删除所有attributechangenotifications。
MBeanException
套分布式通信异常。
RuntimeOperationsException
包IllegalArgumentException如果inattributename参数不对应的属性名称。
ListenerNotFoundException
-听者不在MBean注册或空。
ModelMBeanNotificationBroadcaster.addAttributeChangeNotificationListener(javax.management.NotificationListener, java.lang.String, java.lang.Object)
public void sendAttributeChangeNotification(AttributeChangeNotification ntfyObj) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcaster
sendAttributeChangeNotification
接口
ModelMBeanNotificationBroadcaster
ntfyObj
的通知是通过对监听对象的handlenotification法。
MBeanException
套分布式通信异常。
RuntimeOperationsException
包IllegalArgumentException:通过参数的attributechangenotification对象为空。
public void sendAttributeChangeNotification(Attribute inOldVal, Attribute inNewVal) throws MBeanException, RuntimeOperationsException
ModelMBeanNotificationBroadcaster
sendAttributeChangeNotification
接口
ModelMBeanNotificationBroadcaster
inOldVal
-属性的原始值
inNewVal
-属性的当前值
构建attributechangenotification将:型“JMX。属性。”源此ModelMBean实例序列1getname()属性属性的旧值。AttributeType属性的旧值的类attributeoldvalue getvalue()属性的旧值。attributenewvalue getvalue()价值。
MBeanException
套分布式通信异常。
RuntimeOperationsException
包IllegalArgumentException:属性对象传递参数为空或两属性对象的名称的参数是不一样的。
protected ClassLoaderRepository getClassLoaderRepository()
ClassLoaderRepository
应使用此对象。
public ObjectName preRegister(MBeanServer server, ObjectName name) throws 异常
为了确保RequireModelMBean的正确运行时语义的任何子类个超载或重写此方法应该叫super.preRegister(server, name)
在自己的preRegister
实施。
preRegister
接口
MBeanRegistration
server
的MBean服务器中,MBean将注册。
name
- MBean对象名称。如果Name参数中的一个
MBeanServer
接口
createMBean
或
registerMBean
方法是零这个名字是空的。在这种情况下,该方法必须返回一个非空的新的MBean对象。
name
参数不为空,它通常但不返回值。
异常
这个例外将被重新抛出的MBean服务器作为一个
MBeanRegistrationException
。
public void postRegister(Boolean registrationDone)
为了确保RequireModelMBean的正确运行时语义的任何子类个超载或重写此方法,应该在自己的postRegister
实现呼叫super.postRegister(registrationDone)
。
postRegister
接口
MBeanRegistration
registrationDone
-指示是否MBean已在MBean服务器注册成功。价值错误意味着注册阶段已经失败。
public void preDeregister() throws 异常
为了确保RequireModelMBean的正确运行时语义的任何子类个超载或重写此方法,应该在自己的preDeregister
实现呼叫super.preDeregister()
。
preDeregister
接口
MBeanRegistration
异常
这个例外将被重新抛出的MBean服务器作为一个
MBeanRegistrationException
。
public void postDeregister()
为了确保RequireModelMBean的正确运行时语义的任何子类个超载或重写此方法,应该在自己的postDeregister
实现呼叫super.postDeregister()
。
postDeregister
接口
MBeanRegistration
Submit a bug or feature
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, 2014, Oracle and/or its affiliates. All rights reserved.