uTools-Manuals/docs/java/javax/management/DescriptorKey.html

120 lines
7.4 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="header">
<div class="subTitle">
javax.management
</div>
<h2 class="title" title="Annotation Type DescriptorKey">Annotation Type DescriptorKey</h2>
</div><div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr/> <br/> <pre><a href="../../java/lang/annotation/Documented.html" title="annotation in java.lang.annotation">@Documented</a>
<a href="../../java/lang/annotation/Retention.html" title="annotation in java.lang.annotation">@Retention</a>(<a href="../../java/lang/annotation/Retention.html#value--">value</a>=<a href="../../java/lang/annotation/RetentionPolicy.html#RUNTIME">RUNTIME</a>)
<a href="../../java/lang/annotation/Target.html" title="annotation in java.lang.annotation">@Target</a>(<a href="../../java/lang/annotation/Target.html#value--">value</a>=<a href="../../java/lang/annotation/ElementType.html#METHOD">METHOD</a>)
public @interface <span class="memberNameLabel">DescriptorKey</span></pre>
<div class="block">
<p> <span>描述注释元素如何与<code>Descriptor</code>中的字段相关的<a href="../../javax/management/Descriptor.html" title="javax.management中的接口">元注释</a></span> <span>这可以是MBean的描述符也可以是MBean中的属性操作或构造函数也可以是操作或构造函数的参数。</span> </p>
<p> <span>考虑这个注释,例如:</span> </p>
<pre> <span>@Documented
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Units {
<b>@DescriptorKey("units")</b>
String value();
}</span> </pre>
<p> <span>而这个使用注释:</span> </p>
<pre> <span>public interface CacheControlMBean {
<b>@Units("bytes")</b>
public long getCacheSize();
}</span> </pre>
<p> <span>当标准MBean由<code>CacheControlMBean</code>时,通常的规则意味着它将具有一个名为<code>CacheSize</code>的属性类型为<code>long</code></span> <span><code>@Units</code>注释,考虑到上述定义,将确保<a href="../../javax/management/MBeanAttributeInfo.html" title="javax.management中的类"><code>MBeanAttributeInfo</code></a>该属性将具有<code>Descriptor</code> ,其具有所谓的场<code>units</code>与对应值<code>bytes</code></span> </p>
<p> <span>类似地,如果注释如下所示:</span> </p>
<pre> <span>@Documented
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Units {
<b>@DescriptorKey("units")</b>
String value();
<b>@DescriptorKey("descriptionResourceKey")</b>
String resourceKey() default "";
<b>@DescriptorKey("descriptionResourceBundleBaseName")</b>
String resourceBundleBaseName() default "";
}</span> </pre>
<p> <span>它是这样使用的:</span> </p>
<pre> <span>public interface CacheControlMBean {
<b>@Units("bytes", resourceKey="bytes.key", resourceBundleBaseName="com.example.foo.MBeanResources")</b>
public long getCacheSize();
}</span> </pre>
<p> <span>那么结果<code>Descriptor</code>将包含以下字段:</span> </p>
<span> Name Value units "bytes" descriptionResourceKey "bytes.key" descriptionResourceBundleBaseName "com.example.foo.MBeanResources" </span>
<table border="2" summary="Descriptor Fields">
</table>
<p> <span>诸如<code>@Units</code>可以应用于:</span> </p>
<ul>
<li> <span>标准MBean或MXBean接口;</span> </li>
<li> <span>这种接口中的一种方法;</span> </li>
<li> <span>当该方法是一个操作而不是属性的getter或setter标准MBean或MXBean接口中的方法的参数;</span> </li>
<li> <span>该类中的公共构造函数实现标准MBean或MXBean;</span> </li>
<li> <span>这样的构造函数中的一个参数。</span> </li>
</ul>
<p> <span>忽略注释的其他用途。</span> </p>
<p> <span>仅在定义标准MBean或MXBean的管理界面的准确界面上检查接口注释而不是其父接口。</span> <span>仅在方法出现的最具体的界面中检查方法注释;</span> <span>换句话说,如果一个孩子界面覆盖从父接口的方法,只有<code>@DescriptorKey</code>在子接口中的方法注释考虑。</span> </p>
<p> <span>在同一程序元素上通过不同注释以这种方式贡献的描述符字段必须是一致的。</span> <span>也就是说,两个不同的注释或相同注释的两个成员不能为同一个描述符字段定义不同的值。</span> <span>在getter方法上注释的字段也必须与相应setter方法上注释的字段一致。</span> </p>
<p> <span>由这些注释生成的描述符将与实现提供的任何描述符字段合并例如MBean的<a href="Descriptor.html#immutableInfo"><code>immutableInfo</code></a>字段。</span> <span>注释中的字段必须与实现提供的这些字段一致。</span> </p>
<p> <span>要转换为描述符字段的注释元素可以是Java语言允许的任何类型除了注释或注释数组。</span> <span>该字段的值从注释元素的值派生如下:</span> </p>
<span> Annotation element Descriptor field Primitive value (<code>5</code>, <code>false</code>, etc) Wrapped value (<code>Integer.valueOf(5)</code>, <code>Boolean.FALSE</code>, etc) Class constant (e.g. <code>Thread.class</code>) Class name from <a href="../../java/lang/Class.html#getName--"><code>Class.getName()</code></a> (e.g. <code>"java.lang.Thread"</code>) Enum constant (e.g. <a href="../../java/lang/annotation/ElementType.html#FIELD"><code>ElementType.FIELD</code></a>) Constant name from <a href="../../java/lang/Enum.html#name--"><code>Enum.name()</code></a> (e.g. <code>"FIELD"</code>) Array of class constants or enum constants String array derived by applying these rules to each element Value of any other type<br/> (<code>String</code>, <code>String[]</code>, <code>int[]</code>, etc) The same value </span>
<table border="2" summary="Descriptor Field Types">
</table>
</div>
<dl>
<dt>
<span class="simpleTagLabel">从以下版本开始:</span>
</dt>
<dd>
1.6
</dd>
</dl> </li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation.type.required.element.summary">
<!-- --> </a> <h3>Required Element Summary</h3>
<table border="0" cellpadding="3" cellspacing="0" class="memberSummary" summary="Required Element Summary table, listing required elements, and an explanation">
<caption>
<span>Required Elements</span>
<span class="tabEnd"> </span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Required Element and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../java/lang/String.html" title="class in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/management/DescriptorKey.html#value--">value</a></span></code> </td>
</tr>
</tbody>
</table> </li>
</ul> </li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation.type.element.detail">
<!-- --> </a> <h3>Element Detail</h3> <a name="value--">
<!-- --> </a>
<ul class="blockListLast">
<li class="blockList"> <h4>value</h4> <pre>public abstract <a href="../../java/lang/String.html" title="class in java.lang">String</a> value</pre> </li>
</ul> </li>
</ul> </li>
</ul>
</div>
</div>