202 lines
9.6 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">
<h1 class="title" title="Package">Package javax.management.modelmbean</h1>
<div class="docSummary">
<div class="block">
提供ModelMBean类的定义。
</div>
</div>
<p>See: <a href="#package.description">描述</a></p>
</div><div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" class="typeSummary" summary="Interface Summary table, listing interfaces, and an explanation">
<caption>
<span>接口摘要</span>
<span class="tabEnd"> </span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col">接口</th>
<th class="colLast" scope="col">描述</th>
</tr>
</tbody>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/ModelMBean.html" title="interface in javax.management.modelmbean">ModelMBean</a></td>
<td class="colLast">
<div class="block">
该接口必须由ModelMBeans实现。
</div> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/ModelMBeanInfo.html" title="interface in javax.management.modelmbean">ModelMBeanInfo</a></td>
<td class="colLast">
<div class="block">
该接口由ModelMBeanInfo为每个ModelMBean实现。
</div> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/ModelMBeanNotificationBroadcaster.html" title="interface in javax.management.modelmbean">ModelMBeanNotificationBroadcaster</a></td>
<td class="colLast">
<div class="block">
该接口必须由ModelMBeans实现。
</div> </td>
</tr>
</tbody>
</table> </li>
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" class="typeSummary" summary="Class Summary table, listing classes, and an explanation">
<caption>
<span>类摘要</span>
<span class="tabEnd"> </span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col"></th>
<th class="colLast" scope="col">描述</th>
</tr>
</tbody>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/DescriptorSupport.html" title="class in javax.management.modelmbean">DescriptorSupport</a></td>
<td class="colLast">
<div class="block">
此类表示一个ModelMBean元素的元数据集。
</div> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/ModelMBeanAttributeInfo.html" title="class in javax.management.modelmbean">ModelMBeanAttributeInfo</a></td>
<td class="colLast">
<div class="block">
ModelMBeanAttributeInfo对象描述了ModelMBean的属性。
</div> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/ModelMBeanConstructorInfo.html" title="class in javax.management.modelmbean">ModelMBeanConstructorInfo</a></td>
<td class="colLast">
<div class="block">
ModelMBeanConstructorInfo对象描述了ModelMBean的构造函数。
</div> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/ModelMBeanInfoSupport.html" title="class in javax.management.modelmbean">ModelMBeanInfoSupport</a></td>
<td class="colLast">
<div class="block">
此类表示ModelMBeans的元数据。
</div> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/ModelMBeanNotificationInfo.html" title="class in javax.management.modelmbean">ModelMBeanNotificationInfo</a></td>
<td class="colLast">
<div class="block">
ModelMBeanNotificationInfo对象描述了由ModelMBean发出的通知。
</div> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/ModelMBeanOperationInfo.html" title="class in javax.management.modelmbean">ModelMBeanOperationInfo</a></td>
<td class="colLast">
<div class="block">
ModelMBeanOperationInfo对象描述了ModelMBean的管理操作。
</div> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/RequiredModelMBean.html" title="class in javax.management.modelmbean">RequiredModelMBean</a></td>
<td class="colLast">
<div class="block">
这个类是一个ModelMBean的实现。
</div> </td>
</tr>
</tbody>
</table> </li>
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" class="typeSummary" summary="Exception Summary table, listing exceptions, and an explanation">
<caption>
<span>异常摘要</span>
<span class="tabEnd"> </span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col">异常</th>
<th class="colLast" scope="col">描述</th>
</tr>
</tbody>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/InvalidTargetObjectTypeException.html" title="class in javax.management.modelmbean">InvalidTargetObjectTypeException</a></td>
<td class="colLast">
<div class="block">
指定无效目标对象类型时抛出异常。
</div> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../javax/management/modelmbean/XMLParseException.html" title="class in javax.management.modelmbean">XMLParseException</a></td>
<td class="colLast">
<div class="block">
当将XML格式化的字符串解析为ModelMBean对象或从ModelMBean对象创建XML格式的字符串时将抛出此异常。
</div> </td>
</tr>
</tbody>
</table> </li>
</ul>
<a name="package.description">
<!-- --> </a>
<h2 title="Package javax.management.modelmbean Description">Package javax.management.modelmbean Description</h2>
<div class="block">
<p> <span>提供ModelMBean类的定义。</span> <span>MBean模型是一个MBean用作管理界面和底层托管资源之间的桥梁。</span> <span>管理界面和被管理资源都被指定为Java对象。</span> <span>相同的Model MBean实现可以通过不同的管理接口和托管资源重复使用多次并且可以提供常见的功能如持久性和缓存。</span> </p>
<p> <span>MBean模型实现了<a href="../../../javax/management/modelmbean/ModelMBean.html" title="javax.management.modelmbean中的接口"><code>ModelMBean</code></a>接口。</span> <span>它是一个<a href="../../../javax/management/DynamicMBean.html" title="javax.management中的接口"><code>DynamicMBean</code></a> ,其<a href="../../../javax/management/DynamicMBean.html#getMBeanInfo--"><code>getMBeanInfo</code></a>方法返回一个实现<a href="../../../javax/management/modelmbean/ModelMBeanInfo.html" title="javax.management.modelmbean中的接口"><code>ModelMBeanInfo</code></a>的对象。</span> </p>
<p> <span>每个MBean都有一个<a href="../../../javax/management/MBeanInfo.html" title="javax.management中的类"><code>MBeanInfo</code></a> 其中包含有关MBean本身及其属性操作构造函数和通知的信息。</span> <span>一个模型MBean增加了<code>MBeanInfo</code><a href="../../../javax/management/Descriptor.html" title="javax.management中的接口"><code>Descriptor</code></a> s编码附加信息的形式对。</span> <span>通常, <code>Descriptor</code><code>DescriptorSupport</code><a href="../../../javax/management/modelmbean/DescriptorSupport.html" title="javax.management.modelmbean中的类">实例</a></span> </p>
<p> <span><a href="../../../javax/management/modelmbean/RequiredModelMBean.html" title="javax.management.modelmbean中的类"><code>RequiredModelMBean</code>课程</a>提供了一个标准的MBean模型实现。</span> </p>
<p> <span>下面的示例示出了正在使用模型Mbean使<code>get</code>一个的方法<code>HashMap</code>通过MBean服务器可管理。</span> <span>没有其他方法可以通过MBean服务器。</span> <span>这里没有什么特别的关于<code>HashMap</code></span> <span>任何公共类的公共方法都可以以相同的方式进行管理。</span> </p>
<pre> <span>import java.lang.reflect.Method;
import java.util.HashMap;
import javax.management.*;
import javax.management.modelmbean.*;
// ...
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
// The MBean Server
HashMap map = new HashMap();
// The resource that will be managed
// Construct the management interface for the Model MBean
Method getMethod = HashMap.class.getMethod("get", new Class[] {Object.class});
ModelMBeanOperationInfo getInfo =
new ModelMBeanOperationInfo("Get value for key", getMethod);
ModelMBeanInfo mmbi =
new ModelMBeanInfoSupport(HashMap.class.getName(),
"Map of keys and values",
null, // no attributes
null, // no constructors
new ModelMBeanOperationInfo[] {getInfo},
null); // no notifications
// Make the Model MBean and link it to the resource
ModelMBean mmb = new RequiredModelMBean(mmbi);
mmb.setManagedResource(map, "ObjectReference");
// Register the Model MBean in the MBean Server
ObjectName mapName = new ObjectName(":type=Map,name=whatever");
mbs.registerMBean(mmb, mapName);
// Resource can evolve independently of the MBean
map.put("key", "value");
// Can access the "get" method through the MBean Server
mbs.invoke(mapName, "get", new Object[] {"key"}, new String[] {Object.class.getName()});
// returns "value"</span> </pre>
<h2> <span><a name="spec">Package Specification</a></span> </h2>
<ul>
<li> <span>请参阅可从该<i>JMX 1.4规范</i> PDF文档<a href="../../../../technotes/guides/jmx/">Java Platform documentation on JMX technology</a></span> </li>
</ul>
</div>
<dl>
<dt>
<span class="simpleTagLabel">从以下版本开始:</span>
</dt>
<dd>
1.5
</dd>
</dl>
</div>