-
- All Superinterfaces:
-
Cloneable
,Serializable
- 所有已知实现类:
-
DescriptorSupport
,ImmutableDescriptor
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
创建的example.com
可能具有名称com.example.interestLevel
。需要注意的是,在值
Descriptor Fields Name Type Used in Meaning defaultValue Object MBeanAttributeInfodefaultValue
,legalValues
,maxValue
,并minValue
领域应该由返回的类型一致getType()
方法相关MBeanAttributeInfo
或者MBeanParameterInfo
。 对于MXBeans的,这意味着它们应该是在所映射的Java类型,称为将opendata(J)的MXBean type mapping rules 。
MBeanParameterInfo Default value for an attribute or parameter. Seejavax.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 theResourceBundle
in which the key given in thedescriptionResourceKey
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 thedescriptionResourceBundleBaseName
, 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 thestart()
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 fieldsetExceptions
. 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 aLong
or a decimal string. This provides a hint from a DynamicMBean or any MBean that does not defineimmutableInfo
astrue
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 theimmutableInfo
set totrue
or it has"jmx.mbean.info.changed"
in itsMBeanNotificationInfo
array. interfaceClassName String MBeanInfo The Java interface name for a Standard MBean or MXBean, as returned byClass.getName()
. A Standard MBean or MXBean registered directly in the MBean Server or created using theStandardMBean
class will have this field in its MBeanInfo Descriptor. legalValues Set<?> MBeanAttributeInfo
MBeanParameterInfo Legal values for an attribute or parameter. Seejavax.management.openmbean
. locale String Any The locale of the description in thisMBeanInfo
,MBeanAttributeInfo
, etc, as returned byLocale.toString()
. maxValue Object MBeanAttributeInfo
MBeanParameterInfo Maximum legal value for an attribute or parameter. Seejavax.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. Seejavax.management.openmbean
. mxbean String MBeanInfo The string"true"
or"false"
according as this MBean is anMXBean
. A Standard MBean or MXBean registered directly with the MBean Server or created using theStandardMBean
class will have this field in its MBeanInfo Descriptor. openTypeOpenType
MBeanAttributeInfo
MBeanOperationInfo
MBeanParameterInfoThe Open Type of this element. In the case of
MBeanAttributeInfo
andMBeanParameterInfo
, this is the Open Type of the attribute or parameter. In the case ofMBeanOperationInfo
, it is the Open Type of the return value. This field is set in the Descriptor for all instances ofOpenMBeanAttributeInfoSupport
,OpenMBeanOperationInfoSupport
, andOpenMBeanParameterInfoSupport
. It is also set for attributes, operations, and parameters of MXBeans.This field can be set for an
originalType String MBeanAttributeInfoMBeanNotificationInfo
, in which case it indicates the Open Type that theuser data
will have.
MBeanOperationInfo
MBeanParameterInfoThe original Java type of this element as it appeared in the
MXBean
interface method that produced thisMBeanAttributeInfo
(etc). For example, a method
public
MemoryUsage
getHeapMemoryUsage();
in an MXBean interface defines an attribute calledHeapMemoryUsage
of typeCompositeData
. TheoriginalType
field in the Descriptor for this attribute will have the value"java.lang.management.MemoryUsage"
.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 fieldexceptions
. 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 anInteger
. 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
,以及该章的“模型MBean” JMX Specification 。 下表总结了这些字段。 请注意,当该表中的Type为Number时,也可以使用Long的十进制表示形式的String。没有什么可以阻止在不是MBean的MBean中使用这些字段。 例如 , displayName, severity和visibility字段在Model MBean之外感兴趣。 但是,只有模型MBean具有这些字段的预定义行为。
ModelMBean Fields 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.- 从以下版本开始:
- 1.5
-
-
方法摘要
所有方法 接口方法 抽象方法 Modifier and Type 方法 描述 Object
clone()
返回一个等于该描述符的描述符。boolean
equals(Object obj)
将此描述符与给定对象进行比较。String[]
getFieldNames()
返回描述符中的所有字段名。String[]
getFields()
以字符串数组的形式返回此描述符中包含的所有字段。Object
getFieldValue(String fieldName)
返回特定字段名称的值,如果该名称没有值,则返回null。Object[]
getFieldValues(String... fieldNames)
将描述符中的所有字段值作为对象数组返回。int
hashCode()
返回此描述符的哈希码值。boolean
isValid()
如果所有字段都具有给定名称的合法值,则返回true。void
removeField(String fieldName)
从描述符中删除一个字段。void
setField(String fieldName, Object fieldValue)
设置特定字段名称的值。void
setFields(String[] fieldNames, Object[] fieldValues)
将字段名称数组中的所有字段设置为字段值数组中具有相同索引的新值。
-
-
-
方法详细信息
-
getFieldValue
Object getFieldValue(String fieldName) throws RuntimeOperationsException
返回特定字段名称的值,如果该名称没有值,则返回null。- 参数
-
fieldName
- 字段名称。 - 结果
- 相应的值,如果该字段不存在,则返回null。
- 异常
-
RuntimeOperationsException
- 如果字段名称是非法的。
-
setField
void setField(String fieldName, Object fieldValue) throws RuntimeOperationsException
设置特定字段名称的值。 这将修改现有字段或添加新字段。
字段值在设置之前将被验证。 如果它无效,那么将抛出异常。 有效性的含义取决于描述符的实现。
- 参数
-
fieldName
- 要设置的字段名称。 不能为null或为空。 -
fieldValue
- 要为字段名称设置的字段值。 如果该值是该字段的有效值,则可以为null。 - 异常
-
RuntimeOperationsException
- 如果字段名称或字段值是非法的(包装异常是IllegalArgumentException
); 或者描述符是不可变的(包装异常是UnsupportedOperationException
)。
-
getFields
String[] getFields()
以字符串数组的形式返回此描述符中包含的所有字段。- 结果
-
字符串数组的字段格式为fieldName = fieldValue
如果字段的值不是String,那么将调用toString()方法,并将包含在括号中的返回值用作返回数组中字段的值。 如果一个字段的值为null,那么返回的数组中的字段的值将为空。 如果描述符为空,您将获得一个空数组。 - 另请参见:
-
setFields(java.lang.String[], java.lang.Object[])
-
getFieldNames
String[] getFieldNames()
返回描述符中的所有字段名。- 结果
- 字符串数组字段名称。 如果描述符为空,您将获得一个空数组。
-
getFieldValues
Object[] getFieldValues(String... fieldNames)
将描述符中的所有字段值作为对象数组返回。 返回的值与fieldNames
String数组参数的顺序相同。- 参数
-
fieldNames
- 应返回值的字段名称的字符串数组。 如果数组为空,那么将返回一个空数组。 如果数组为空,那么将返回所有值,就像该参数是由getFieldNames()
返回的数组一样 。 如果数组中的字段名称不存在,包括其为空或空字符串的情况,那么返回的匹配数组元素将返回null。 - 结果
-
字段值的对象数组。
如果
fieldNames
的列表为空,您将获得一个空数组。
-
removeField
void removeField(String fieldName)
从描述符中删除一个字段。- 参数
-
fieldName
- 要删除的字段的字符串名称。 如果字段名称是非法的或没有找到该字段,则不会抛出异常。 - 异常
-
RuntimeOperationsException
- 如果给定名称的字段存在且描述符是不可变的。 包装的例外将是一个UnsupportedOperationException
。
-
setFields
void setFields(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException
将字段名称数组中的所有字段设置为字段值数组中具有相同索引的新值。 阵列大小必须匹配。
字段值在设置之前将被验证。 如果它无效,那么将抛出异常。 如果数组为空,那么没有更改将生效。
- 参数
-
fieldNames
- 字段名称的字符串数组。 数组和数组元素不能为空。 -
fieldValues
- 相应字段值的对象数组。 数组不能为null。 数组的元素可以为空。 - 异常
-
RuntimeOperationsException
- 如果由于任何原因更改失败。 如果fieldNames
或fieldValues
为空,或者如果数组的长度不同,或者其中一个中存在非法值,则包装的异常为IllegalArgumentException
。 如果描述符是不可变的,则包装的异常是UnsupportedOperationException
,并且调用将改变其内容。 - 另请参见:
-
getFields()
-
clone
Object clone() throws RuntimeOperationsException
返回一个等于该描述符的描述符。 返回的描述符的更改对此描述符没有影响,反之亦然。 如果这个描述符是不可变的,它可以通过返回自己来实现这个条件。
- 结果
- 与该描述符相等的描述符。
- 异常
-
RuntimeOperationsException
- 用于字段名称或字段值的非法值。 如果由于任何原因描述符构造失败,将抛出此异常。
-
isValid
boolean isValid() throws RuntimeOperationsException
如果所有字段都具有给定名称的合法值,则返回true。- 结果
- 如果值合法,则为真。
- 异常
-
RuntimeOperationsException
- 如果由于任何原因有效性检查失败,将抛出此异常。 如果描述符无效,该方法返回false,但如果尝试确定有效性失败,则返回此异常。
-
equals
boolean equals(Object obj)
将此描述符与给定对象进行比较。 如果给定的对象也是描述符,并且两个描述符具有相同的字段名称(可能在不同情况下)和相同的关联值,则对象是相等的。 如果满足以下条件,两个描述符中的字段的相应值相等:
- 如果一个值为null,那么另一个值也是。
- 如果一个值是原始数组,则另一个值必须是具有相同元素的相同类型的原始数组。
- 如果一个值是一个对象数组,那么另一个值必须也是,并且
Arrays.deepEquals(Object[],Object[])
必须返回true。 - 否则
Object.equals(Object)
必须返回true。
- 重写:
-
equals
在Object
- 参数
-
obj
- 要比较的对象。 - 结果
-
true
如果对象相同; 否则为false
。 - 从以下版本开始:
- 1.6
- 另请参见:
-
Object.hashCode()
,HashMap
-
hashCode
int hashCode()
返回此描述符的哈希码值。 哈希码被计算为描述符中每个字段的哈希码的和。 名称为
n
,值为v
的字段的哈希码为n.toLowerCase().hashCode() ^ h
。 这里h
是哈希码为v
,计算如下:- 如果
v
为null,则h
为0。 - 如果
v
是原始数组,则使用h
的适当重载计算java.util.Arrays.hashCode
。 - 如果
v
是一个对象数组然后h
使用计算Arrays.deepHashCode(Object[])
。 - 否则
h
是v.hashCode()
。
- 重写:
-
hashCode
在Object
- 结果
- 此对象的哈希码值。
- 从以下版本开始:
- 1.6
- 另请参见:
-
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
- 如果
-
-