|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 前のパッケージ 次のパッケージ | フレームあり フレームなし | |||||||||
参照先:
説明
| インタフェースの概要 | |
|---|---|
| ModelMBean | ModelMBean は、このインタフェースを実装する必要があります。 |
| ModelMBeanInfo | ModelMBeanInfo は、ModelMBean ごとにこのインタフェースを実装する必要があります。 |
| ModelMBeanNotificationBroadcaster | ModelMBean は、このインタフェースを実装する必要があります。 |
| クラスの概要 | |
|---|---|
| DescriptorSupport | このクラスは、ModelMBean 要素のメタデータセットを表します。 |
| ModelMBeanAttributeInfo | ModelMBeanAttributeInfo オブジェクトは、ModelMBean の属性を説明します。 |
| ModelMBeanConstructorInfo | ModelMBeanConstructorInfo オブジェクトは、ModelMBean のコンストラクタを説明します。 |
| ModelMBeanInfoSupport | このクラスは、ModelMBean のメタデータを表します。 |
| ModelMBeanNotificationInfo | ModelMBeanNotificationInfo オブジェクトは、ModelMBean が発行する通知を説明します。 |
| ModelMBeanOperationInfo | ModelMBeanOperationInfo オブジェクトは、ModelMBean の管理オペレーションを説明します。 |
| RequiredModelMBean | このクラスは、ModelMBean の実装です。 |
| 例外の概要 | |
|---|---|
| InvalidTargetObjectTypeException | 指定されたターゲットオブジェクト型が無効な場合にスローされる例外です。 |
| XMLParseException | この例外は、XML 形式の文字列が ModelMBean オブジェクトに解析される場合、または XML 形式の文字列が ModelMBean オブジェクトから作成される場合にスローされます。 |
ModelMBean クラスの定義を提供します。Model MBean は、管理インタフェースと配下の管理対象リソースのブリッジとして機能する MBean です。管理インタフェースと管理対象リソースは、どちらも Java オブジェクトとして指定されます。複数の異なった管理インタフェースおよび管理対象リソースで、同じ Model MBean 実装を繰り返し利用できます。また、Model MBean 実装は、持続性機能、キャッシング機能などの共通機能を提供できます。
Model MBean は、ModelMBean インタフェースを実装します。Model MBean は、DynamicMBean であり、ModelMBeanInfo を実装するオブジェクトを返す getMBeanInfo メソッドを持っています。
各 MBean は、MBean 自体に関する情報が付属した MBeanInfo と、その属性、オペレーション、コンストラクタ、および通知を持っています。Model MBean は、この MBeanInfo に、(key,value) のペア形式の追加情報をエンコードする Descriptor を追加します。通常、Descriptor は、DescriptorSupport のインスタンスです。
RequiredModelMBean クラスは、標準 Model MBean 実装を提供します。
以下に、MBean サーバから HashMap の get メソッドを管理できるようにするための Model MBean の例を示します。MBean サーバからは、これ以外のメソッドは利用できません。この例では、HashMap に関する特別な情報はありません。同様にして、任意の public クラスの public メソッドを管理用に公開できます。
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 MBeanMethod 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 resourceModelMBean mmb = new RequiredModelMBean(mmbi);mmb.setManagedResource(map, "ObjectReference");
// Register the Model MBean in the MBean ServerObjectName mapName = new ObjectName(":type=Map,name=whatever");mbs.registerMBean(mmb, mapName);
// Resource can evolve independently of the MBeanmap.put("key", "value");
// Can access the "get" method through the MBean Servermbs.invoke(mapName, "get", new Object[] {"key"}, new String[] {Object.class.getName()});// returns "value"
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 前のパッケージ 次のパッケージ | フレームあり フレームなし | |||||||||
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。