public interface Descriptor extends Serializable, Cloneable
对于一个JMX元额外的元数据。一个Descriptor
与MBeanInfo
,MBeanAttributeInfo
有关,等组成的集合场。字段是一个名称和关联的值。
字段名称是不区分大小写的。名称descriptorType
,descriptortype
,和DESCRIPTORTYPE
都是等价的。然而,案件时使用的领域是第一组保存的getFields()
和getFieldNames()
方法的结果。
并不是所有的字段名称和值都是预定义的。可以通过任何程序定义和添加新字段。
一个描述符可以是可变的或不可变的。一个不可变的描述符,一旦创建,永远不会改变。的Descriptor
方法可以修改描述符的内容将为一个不变的描述符的一个例外。不变的描述符通常是ImmutableDescriptor
或子类的实例。可变参数通常是DescriptorSupport
或子类的实例。
某些字段由JMX实现。这意味着该领域的存在可以改变行为的JMX API或该领域中可设置返回的描述符的JMX API。这些字段出现在下表中斜体字,和每一个在JMX
类相应的常数。例如,现场defaultValue
由恒JMX.DEFAULT_VALUE_FIELD
代表。
某些其他领域有传统意义下表中描述,但他们不需要被理解或通过JMX实现。
字段名称在JMX规范和所有未来的版本定义不包含句点(。)。用户可以创建自己的领域包括在名称期并确保这些名字不会撞上任何未来版本的JMX API。建议遵循java包的命名约定来避免不同来源之间的字段名称冲突。例如,一场由example.com
可能的名字com.example.interestLevel
。
值得注意的是defaultValue
,值legalValues
,maxValue
,和minValue
领域应符合类型返回的getType()
方法相关的MBeanAttributeInfo
或MBeanParameterInfo
。对于mxbeans,这意味着他们应该映射到java类型,称为开放数据(J)在MXBean type mapping rules。
Name | Type | Used in | Meaning |
---|---|---|---|
defaultValue | Object | MBeanAttributeInfo MBeanParameterInfo |
Default value for an attribute or parameter. See javax.management.openmbean . |
deprecated | String | Any | An indication that this element of the information model is no longer recommended for use. A set of MBeans defined by an application is collectively called an information model. The convention is for the value of this field to contain a string that is the version of the model in which the element was first deprecated, followed by a space, followed by an explanation of the deprecation, for example "1.3 Replaced by the Capacity attribute" . |
descriptionResource BundleBaseName |
String | Any | The base name for the ResourceBundle in which the key given in the descriptionResourceKey field can be found, for example "com.example.myapp.MBeanResources" . The meaning of this field is defined by this specification but the field is not set or used by the JMX API itself. |
descriptionResourceKey | String | Any | A resource key for the description of this element. In conjunction with the descriptionResourceBundleBaseName , this can be used to find a localized version of the description. The meaning of this field is defined by this specification but the field is not set or used by the JMX API itself. |
enabled | String | MBeanAttributeInfo MBeanNotificationInfo MBeanOperationInfo |
The string "true" or "false" according as this item is enabled. When an attribute or operation is not enabled, it exists but cannot currently be accessed. A user interface might present it as a greyed-out item. For example, an attribute might only be meaningful after the start() method of an MBean has been called, and is otherwise disabled. Likewise, a notification might be disabled if it cannot currently be emitted but could be in other circumstances. |
exceptions | String[] | MBeanAttributeInfo, MBeanConstructorInfo, MBeanOperationInfo | The class names of the exceptions that can be thrown when invoking a constructor or operation, or getting an attribute. The meaning of this field is defined by this specification but the field is not set or used by the JMX API itself. Exceptions thrown when setting an attribute are specified by the field setExceptions . |
immutableInfo | String | MBeanInfo | The string "true" or "false" according as this MBean's MBeanInfo is immutable. When this field is true, the MBeanInfo for the given MBean is guaranteed not to change over the lifetime of the MBean. Hence, a client can read it once and cache the read value. When this field is false or absent, there is no such guarantee, although that does not mean that the MBeanInfo will necessarily change. See also the "jmx.mbean.info.changed" notification. |
infoTimeout | String Long |
MBeanInfo | The time in milli-seconds that the MBeanInfo can reasonably be expected to be unchanged. The value can be a Long or a decimal string. This provides a hint from a DynamicMBean or any MBean that does not define immutableInfo as true that the MBeanInfo is not likely to change within this period and therefore can be cached. When this field is missing or has the value zero, it is not recommended to cache the MBeanInfo unless it has the immutableInfo set to true or it has "jmx.mbean.info.changed" in its MBeanNotificationInfo array. |
interfaceClassName | String | MBeanInfo | The Java interface name for a Standard MBean or MXBean, as returned by Class.getName() . A Standard MBean or MXBean registered directly in the MBean Server or created using the StandardMBean class will have this field in its MBeanInfo Descriptor. |
legalValues | Set<?> | MBeanAttributeInfo MBeanParameterInfo |
Legal values for an attribute or parameter. See javax.management.openmbean . |
locale | String | Any | The locale of the description in this MBeanInfo , MBeanAttributeInfo , etc, as returned by Locale.toString() . |
maxValue | Object | MBeanAttributeInfo MBeanParameterInfo |
Maximum legal value for an attribute or parameter. See javax.management.openmbean . |
metricType | String | MBeanAttributeInfo MBeanOperationInfo |
The type of a metric, one of the strings "counter" or "gauge". A metric is a measurement exported by an MBean, usually an attribute but sometimes the result of an operation. A metric that is a counter has a value that never decreases except by being reset to a starting value. Counter metrics are almost always non-negative integers. An example might be the number of requests received. A metric that is a gauge has a numeric value that can increase or decrease. Examples might be the number of open connections or a cache hit rate or a temperature reading. |
minValue | Object | MBeanAttributeInfo MBeanParameterInfo |
Minimum legal value for an attribute or parameter. See javax.management.openmbean . |
mxbean | String | MBeanInfo | The string "true" or "false" according as this MBean is an MXBean . A Standard MBean or MXBean registered directly with the MBean Server or created using the StandardMBean class will have this field in its MBeanInfo Descriptor. |
openType | OpenType |
MBeanAttributeInfo MBeanOperationInfo MBeanParameterInfo |
The Open Type of this element. In the case of This field can be set for an |
originalType | String | MBeanAttributeInfo MBeanOperationInfo MBeanParameterInfo |
The original Java type of this element as it appeared in the The format of this string is described in the section Type Names of the MXBean specification. |
setExceptions | String[] | MBeanAttributeInfo | The class names of the exceptions that can be thrown when setting an attribute. The meaning of this field is defined by this specification but the field is not set or used by the JMX API itself. Exceptions thrown when getting an attribute are specified by the field exceptions . |
severity | String Integer |
MBeanNotificationInfo | The severity of this notification. It can be 0 to mean unknown severity or a value from 1 to 6 representing decreasing levels of severity. It can be represented as a decimal string or an Integer . |
since | String | Any | The version of the information model in which this element was introduced. A set of MBeans defined by an application is collectively called an information model. The application may also define versions of this model, and use the "since" field to record the version in which an element first appeared. |
units | String | MBeanAttributeInfo MBeanParameterInfo MBeanOperationInfo |
The units in which an attribute, parameter, or operation return value is measured, for example "bytes" or "seconds" . |
一些额外的字段由MBean定义模型。看到
ModelMBeanInfo
,
ModelMBeanAttributeInfo
,
ModelMBeanConstructorInfo
,
ModelMBeanNotificationInfo
,和
ModelMBeanOperationInfo
信息,以及各章的“模型MBeans”的JMX Specification。下表总结了这些领域。请注意,当此表中的类型是数字时,也可以使用一个长的十进制表示形式的字符串。
没有什么可以阻止在MBeans不是模型MBeans这些领域的使用。的displayName, severity,和visibility字段是外部模型MBean的兴趣,例如。但只有模型MBean有这些领域的预定义的行为。
Name | Type | Used in | Meaning |
---|---|---|---|
class | String | ModelMBeanOperationInfo | Class where method is defined (fully qualified). |
currencyTimeLimit | Number | ModelMBeanInfo ModelMBeanAttributeInfo ModelMBeanOperationInfo |
How long cached value is valid: <0 never, =0 always, >0 seconds. |
default | Object | ModelMBeanAttributeInfo | Default value for attribute. |
descriptorType | String | Any | Type of descriptor, "mbean", "attribute", "constructor", "operation", or "notification". |
displayName | String | Any | Human readable name of this item. |
export | String | ModelMBeanInfo | Name to be used to export/expose this MBean so that it is findable by other JMX Agents. |
getMethod | String | ModelMBeanAttributeInfo | Name of operation descriptor for get method. |
lastUpdatedTimeStamp | Number | ModelMBeanAttributeInfo ModelMBeanOperationInfo |
When value was set. |
log | String | ModelMBeanInfo ModelMBeanNotificationInfo |
t or T: log all notifications, f or F: log no notifications. |
logFile | String | ModelMBeanInfo ModelMBeanNotificationInfo |
Fully qualified filename to log events to. |
messageID | String | ModelMBeanNotificationInfo | Unique key for message text (to allow translation, analysis). |
messageText | String | ModelMBeanNotificationInfo | Text of notification. |
name | String | Any | Name of this item. |
persistFile | String | ModelMBeanInfo | File name into which the MBean should be persisted. |
persistLocation | String | ModelMBeanInfo | The fully qualified directory name where the MBean should be persisted (if appropriate). |
persistPeriod | Number | ModelMBeanInfo ModelMBeanAttributeInfo |
Frequency of persist cycle in seconds. Used when persistPolicy is "OnTimer" or "NoMoreOftenThan". |
persistPolicy | String | ModelMBeanInfo ModelMBeanAttributeInfo |
One of: OnUpdate|OnTimer|NoMoreOftenThan|OnUnregister|Always|Never. See the section "MBean Descriptor Fields" in the JMX specification document. |
presentationString | String | Any | XML formatted string to allow presentation of data. |
protocolMap | Descriptor | ModelMBeanAttributeInfo | See the section "Protocol Map Support" in the JMX specification document. Mappings must be appropriate for the attribute and entries can be updated or augmented at runtime. |
role | String | ModelMBeanConstructorInfo ModelMBeanOperationInfo |
One of "constructor", "operation", "getter", or "setter". |
setMethod | String | ModelMBeanAttributeInfo | Name of operation descriptor for set method. |
severity | Number | ModelMBeanNotificationInfo | 0-6 where 0: unknown; 1: non-recoverable; 2: critical, failure; 3: major, severe; 4: minor, marginal, error; 5: warning; 6: normal, cleared, informative |
targetObject | Object | ModelMBeanOperationInfo | Object on which to execute this method. |
targetType | String | ModelMBeanOperationInfo | type of object reference for targetObject. Can be: ObjectReference | Handle | EJBHandle | IOR | RMIReference. |
value | Object | ModelMBeanAttributeInfo ModelMBeanOperationInfo |
Current (cached) value for attribute or operation. |
visibility | Number | Any | 1-4 where 1: always visible, 4: rarely visible. |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
返回一个与此描述符相等的描述符。
|
boolean |
equals(Object obj)
将此描述符与给定对象进行比较。
|
String[] |
getFieldNames()
返回描述符中的所有字段名称。
|
String[] |
getFields()
返回包含在该描述符中的字段数组中的所有字段。
|
Object |
getFieldValue(String fieldName)
返回一个特定字段名的值,如果没有该名称的值,则为。
|
Object[] |
getFieldValues(String... fieldNames)
返回在描述符中的所有字段值作为一个对象数组。
|
int |
hashCode()
返回此描述符的哈希代码值。
|
boolean |
isValid()
如果所有字段都具有给定名称的合法值,则返回真值。
|
void |
removeField(String fieldName)
从描述符中移除字段。
|
void |
setField(String fieldName, Object fieldValue)
为特定字段名称设置值。
|
void |
setFields(String[] fieldNames, Object[] fieldValues)
将字段名称数组中的所有字段设置为字段值数组中的相同索引的新值。
|
Object getFieldValue(String fieldName) throws RuntimeOperationsException
fieldName
的字段名称。
RuntimeOperationsException
如果字段名称是非法的。
void setField(String fieldName, Object fieldValue) throws RuntimeOperationsException
为特定字段名称设置值。这将修改一个现有的字段或添加一个新字段。
字段值在它被设置之前将被验证。如果它无效,则将抛出一个异常。有效性的意义是依赖于描述符的实现。
fieldName
-字段名称是。不能为空或空。
fieldValue
-被设置为字段名字段值。可以为空,如果这是一个字段的有效值。
RuntimeOperationsException
如果字段名或字段的值是非法的(包裹的例外是
IllegalArgumentException
);或者如果描述符是不变的(包裹的例外是
UnsupportedOperationException
)。
String[] getFields()
setFields(java.lang.String[], java.lang.Object[])
String[] getFieldNames()
Object[] getFieldValues(String... fieldNames)
fieldNames
字符串数组参数。
fieldNames
-字段的名称,该值应返回的字符串数组。如果数组是空的,那么将返回一个空数组。如果数组为空然后所有值将返回,如果参数是由
getFieldNames()
返回的数组。如果数组中的字段名不存在,包括它为空或空字符串的情况,则返回匹配数组元素返回的空值。
fieldNames
列表是空的,你会得到一个空数组。
void removeField(String fieldName)
fieldName
-场的字符串被删除。如果字段名称是非法的或未找到字段,则将不会引发异常。
RuntimeOperationsException
-如果一个字段的名字存在和描述符是不变的。包装的异常将
UnsupportedOperationException
。
void setFields(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException
将字段名称数组中的所有字段设置为字段值数组中的相同索引的新值。数组大小必须匹配。
字段值在它被设置之前将被验证。如果它无效,则将抛出一个异常。如果数组是空的,那么没有更改将生效。
fieldNames
-字段名称的字符串数组。数组和数组元素不能为空。
fieldValues
-相应字段对象的数组。数组不能为空。数组的元素可以为空。
RuntimeOperationsException
-如果变化没有以任何理由。包裹的例外是
IllegalArgumentException
如果
fieldNames
或
fieldValues
是无效的,或者如果数组是不同的长度,或如果有其中一个非法值。包裹的例外是
UnsupportedOperationException
如果描述符是不可变的,并能改变它的内容。
getFields()
Object clone() throws RuntimeOperationsException
返回一个与此描述符相等的描述符。返回的描述符的更改将不会对这个描述符产生影响,反之亦然。如果这个描述符是不可变的,它可以通过返回自己完成这个条件。
RuntimeOperationsException
-非法值的字段名或字段值。如果描述符建设失败,任何原因,这个异常将被抛出。
boolean isValid() throws RuntimeOperationsException
RuntimeOperationsException
如果有效性检查的任何原因而失败,这将引发异常。如果描述符无效,则返回错误,但如果试图确定有效性失败,则抛出此异常。
boolean equals(Object obj)
将此描述符与给定对象进行比较。对象是相等的,如果给定的对象也是一个描述符,如果两个描述符有相同的字段名称(可能是不同的情况下)和相同的关联值。在以下条件保持时,两个描述符中的字段的各自的值是相等的:
Arrays.deepEquals(Object[],Object[])
必须返回true。Object.equals(Object)
必须返回true。equals
方法重写,继承类
Object
obj
-比较对象。
true
如果对象是相同的;
false
否则。
Object.hashCode()
,
HashMap
int hashCode()
返回此描述符的哈希代码值。散列码被计算为描述符中的每个字段的哈希代码的总和。名称n
和价值v
字段的哈希代码n.toLowerCase().hashCode() ^ h
。这里h
是v
哈希代码,计算如下:
v
空然后h
0。v
是原始数组然后h
是使用适当的超载java.util.Arrays.hashCode
计算。v
是对象数组然后h
计算使用Arrays.deepHashCode(Object[])
。h
是v.hashCode()
。hashCode
方法重写,继承类
Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
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.