模块  java.management
软件包  javax.management

Interface Descriptor

  • All Superinterfaces:
    CloneableSerializable
    所有已知实现类:
    DescriptorSupportImmutableDescriptor

    public interface Descriptor
    extends Serializable, Cloneable

    JMX元素的其他元数据。 一个Descriptor与相关MBeanInfoMBeanAttributeInfo ,等等。它由一个字段集合的。 字段是名称和关联值。

    字段名称不区分大小写。 名称descriptorTypedescriptortypeDESCRIPTORTYPE都是等效的。 但是,在首次设置字段时使用的情况将保留在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

    需要注意的是,在价值defaultValuelegalValuesmaxValueminValue领域应该由返回的类型一致getType()方法相关的MBeanAttributeInfoMBeanParameterInfo 对于MXBeans的,这意味着它们应该是在所映射的Java类型,称为将opendata(J)MXBean type mapping rules

    Descriptor Fields 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 MBeanAttributeInfo and MBeanParameterInfo, this is the Open Type of the attribute or parameter. In the case of MBeanOperationInfo, it is the Open Type of the return value. This field is set in the Descriptor for all instances of OpenMBeanAttributeInfoSupport, OpenMBeanOperationInfoSupport, and OpenMBeanParameterInfoSupport. It is also set for attributes, operations, and parameters of MXBeans.

    This field can be set for an MBeanNotificationInfo, in which case it indicates the Open Type that the user data will have.

    originalType String MBeanAttributeInfo
    MBeanOperationInfo
    MBeanParameterInfo

    The original Java type of this element as it appeared in the MXBean interface method that produced this MBeanAttributeInfo (etc). For example, a method
    public MemoryUsage getHeapMemoryUsage();
    in an MXBean interface defines an attribute called HeapMemoryUsage of type CompositeData. The originalType 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 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".

    Model MBean定义了一些其他字段。 请参阅信息 ModelMBeanInfo ModelMBeanAttributeInfo ModelMBeanConstructorInfo ModelMBeanNotificationInfo ModelMBeanOperationInfo ,以及该章的“模型MBean” JMX Specification 下表总结了这些字段。 请注意,当此表中的Type为Number时,也可以使用作为Long的十进制表示的String。

    没有什么可以阻止在不是Model MBean的MBean中使用这些字段。 例如displayName, severityvisibility字段在Model MBean之外是令人感兴趣的。 但只有Model 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
    • 方法摘要

      所有方法  实例方法 抽象方法 
      变量和类型 方法 描述
      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 - 应为其返回值的字段名称的字符串数组。 如果数组为空,则返回一个空数组。 如果数组为null,则返回所有值,就好像参数是getFieldNames()返回的数组一样 如果数组中的字段名称不存在(包括它为null或空字符串的情况),则返回null,以便返回匹配的数组元素。
        结果
        字段值的对象数组。 如果fieldNames的列表为空,您将获得一个空数组。
      • removeField

        void removeField​(String fieldName)
        从描述符中删除字段。
        参数
        fieldName - 要删除的字段的字符串名称。 如果字段名称非法或未找到该字段,则不会引发异常。
        异常
        RuntimeOperationsException - 如果给定名称的字段存在且描述符是不可变的。 包装的例外将是UnsupportedOperationException
      • setFields

        void setFields​(String[] fieldNames,
                       Object[] fieldValues)
                throws RuntimeOperationsException

        将字段名称数组中的所有字段设置为字段值数组中具有相同索引的新值。 数组大小必须匹配。

        字段值将在设置之前进行验证。 如果它无效,则抛出异常。 如果数组为空,则不会发生任何更改。

        参数
        fieldNames - 字段名称的字符串数组。 数组和数组元素不能为null。
        fieldValues - 相应字段值的对象数组。 该数组不能为null。 数组的元素可以为null。
        异常
        RuntimeOperationsException - 如果更改因任何原因失败。 如果fieldNamesfieldValues为空,或者如果数组的长度不同,或者其中一个数组中存在非法值,则包装的异常为IllegalArgumentException 如果描述符是不可变的,则包装的异常是UnsupportedOperationException ,并且调用将更改其内容。
        另请参见:
        getFields()
      • clone

        Object clone()
              throws RuntimeOperationsException

        返回与此描述符相等的描述符。 对返回的描述符的更改将不会对此描述符产生任何影响,反之亦然。 如果此描述符是不可变的,则它可以通过返回自身来满足此条件。

        结果
        描述符等于此描述符。
        异常
        RuntimeOperationsException - 表示字段名称或字段值的非法值。 如果描述符构造因任何原因失败,则抛出此异常。
      • isValid

        boolean isValid()
                 throws RuntimeOperationsException
        如果所有字段都具有给定其名称的合法值,则返回true。
        结果
        如果值是合法的,则为true。
        异常
        RuntimeOperationsException - 如果由于任何原因有效性检查失败,将抛出此异常。 如果描述符无效,则该方法返回false,但如果确定有效性的尝试失败,则抛出此异常。
      • equals

        boolean equals​(Object obj)

        将此描述符与给定对象进行比较。 如果给定对象也是描述符,并且两个描述符具有相同的字段名称(可能在大小写上有所不同)和相同的关联值,则对象是相等的。 如果满足以下条件,则两个描述符中字段的相应值相等:

        • 如果一个值为null,则另一个值也必须为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[])
        • 否则hv.hashCode()
        重写:
        hashCode在类 Object
        结果
        此对象的哈希码值。
        从以下版本开始:
        1.6
        另请参见:
        Object.equals(java.lang.Object)System.identityHashCode(java.lang.Object)