public class JMX extends Object
修飾子と型 | フィールド | 説明 |
---|---|---|
static String |
DEFAULT_VALUE_FIELD |
defaultValue フィールドの名前。 |
static String |
IMMUTABLE_INFO_FIELD |
immutableInfo フィールドの名前。 |
static String |
INTERFACE_CLASS_NAME_FIELD |
interfaceClassName フィールドの名前。 |
static String |
LEGAL_VALUES_FIELD |
legalValues フィールドの名前。 |
static String |
MAX_VALUE_FIELD |
maxValue フィールドの名前。 |
static String |
MIN_VALUE_FIELD |
minValue フィールドの名前。 |
static String |
MXBEAN_FIELD |
mxbean フィールドの名前。 |
static String |
OPEN_TYPE_FIELD |
openType フィールドの名前。 |
static String |
ORIGINAL_TYPE_FIELD |
originalType フィールドの名前。 |
修飾子と型 | メソッド | 説明 |
---|---|---|
static boolean |
isMXBeanInterface(Class<?> interfaceClass) |
インタフェースがMXBeanインタフェースかどうかをテストします。
|
static <T> T |
newMBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass) |
ローカルまたはリモートのMBean Server内にStandard MBeanのプロキシを作成します。
|
static <T> T |
newMBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass, boolean notificationEmitter) |
ローカルまたはリモートのMBean Server内にStandard MBean用のプロキシを作成します。これは、
NotificationEmitter のメソッドもサポートする場合があります。 |
static <T> T |
newMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass) |
ローカルまたはリモートのMBean Server内にMXBeanのプロキシを作成します。
|
static <T> T |
newMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass, boolean notificationEmitter) |
ローカルまたはリモートのMBean Server内にMXBean用のプロキシを作成します。これは、
NotificationEmitter のメソッドもサポートする場合があります。 |
public static final String DEFAULT_VALUE_FIELD
defaultValue
フィールドの名前。public static final String IMMUTABLE_INFO_FIELD
immutableInfo
フィールドの名前。public static final String INTERFACE_CLASS_NAME_FIELD
interfaceClassName
フィールドの名前。public static final String LEGAL_VALUES_FIELD
legalValues
フィールドの名前。public static final String ORIGINAL_TYPE_FIELD
originalType
フィールドの名前。public static <T> T newMBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass)
ローカルまたはリモートのMBean Server内にStandard MBeanのプロキシを作成します。
MBean Server mbs
にObjectName
name
を持つMBeanが含まれていて、MBeanの管理インタフェースがJavaインタフェースMyMBean
によって記述されている場合は、次のようにしてMBeanのプロキシを構築できます。
MyMBean proxy = JMX.newMBeanProxy(mbs, name, MyMBean.class);
MyMBean
は、次のようになります。
public interface MyMBean { public String getSomeAttribute(); public void setSomeAttribute(String value); public void someOperation(String param1, int param2); }
これで、次の内容を実行できます。
proxy.getSomeAttribute()
。これにより、mbs.
getAttribute
(name, "SomeAttribute")
への呼出しが行われます。
proxy.setSomeAttribute("whatever")
。これにより、mbs.
setAttribute
(name, new Attribute("SomeAttribute", "whatever"))
への呼出しが行われます。
proxy.someOperation("param1", 2)
。これが、mbs.
invoke
(name, "someOperation",<etc>)
への呼出しに変換されます。
このメソッドにより返されるオブジェクトは、Proxy
です。このオブジェクトのInvocationHandler
はMBeanServerInvocationHandler
です。
このメソッドは、newMBeanProxy(connection, objectName, interfaceClass, false)
と同等です。
T
- たとえば、interfaceClass
パラメータがMyMBean.class
であれば、戻り値の型はMyMBean
になることをコンパイラに知らせる。connection
- 送信先のMBeanサーバー。objectName
- connection
内で渡されるMBeanの名前。interfaceClass
- MBeanがエクスポートする管理インタフェース。これも返されるプロキシにより実装される。IllegalArgumentException
- interfaceClass
が準拠するMBeanインタフェースでない場合public static <T> T newMBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass, boolean notificationEmitter)
ローカルまたはリモートのMBean Server内にStandard MBean用のプロキシを作成します。これは、NotificationEmitter
のメソッドもサポートする場合があります。
このメソッドの動作はnewMBeanProxy(MBeanServerConnection, ObjectName, Class)
と同じですが、加えてnotificationEmitter
がtrue
の場合、MBeanはNotificationBroadcaster
またはNotificationEmitter
であると見なされ、返されるプロキシはNotificationEmitter
およびinterfaceClass
を実装します。 このプロキシ上でNotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
を呼び出すと、MBeanServerConnection.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)
が呼び出される。NotificationBroadcaster
およびNotificationEmitter
のその他のメソッドの場合も同様。
T
- たとえば、interfaceClass
パラメータがMyMBean.class
であれば、戻り値の型はMyMBean
になることをコンパイラに知らせる。connection
- 送信先のMBeanサーバー。objectName
- connection
内で渡されるMBeanの名前。interfaceClass
- MBeanがエクスポートする管理インタフェース。これも返されるプロキシにより実装される。notificationEmitter
- connection
経由でメソッドを渡すことにより、返されたプロキシにNotificationEmitter
を実装させる。IllegalArgumentException
- interfaceClass
が準拠するMBeanインタフェースでない場合public static <T> T newMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass)
MBean Server mbs
にObjectName
name
を持つMXBeanが含まれていて、MXBeanの管理インタフェースがJavaインタフェースMyMXBean
によって記述されている場合は、次のようにしてMXBeanのプロキシを構築できます。
MyMXBean proxy = JMX.newMXBeanProxy(mbs, name, MyMXBean.class);
MyMXBean
は、次のようになります。
public interface MyMXBean {
public String getSimpleAttribute();
public void setSimpleAttribute(String value);
public MemoryUsage
getMappedAttribute();
public void setMappedAttribute(MemoryUsage memoryUsage);
public MemoryUsage someOperation(String param1, MemoryUsage param2);
}
次のようになります。
proxy.getSimpleAttribute()
により、mbs.
getAttribute
(name, "SimpleAttribute")
への呼出しが行われます。
proxy.setSimpleAttribute("whatever")
により、mbs.
setAttribute
(name, new Attribute("SimpleAttribute", "whatever"))
への呼出しが行われます。
String
は、SimpleType
の意味ではSimple Typeであるため、MXBeanのコンテキスト内で変更されることはありません。 属性SimpleAttribute
に対するMXBeanプロキシの動作はStandard MBeanプロキシと同じです(newMBeanProxy
を参照)。
proxy.getMappedAttribute()
により、mbs.getAttribute("MappedAttribute")
への呼出しが行われます。 MXBeanマッピング・ルールに従うと、属性MappedAttribute
の実際の型はCompositeData
であり、これがmbs.getAttribute
の呼出しで返されます。 次に、プロキシは、MXBeanマッピング・ルールを使って、CompositeData
を予期される型MemoryUsage
に変換して戻します。
同様に、proxy.setMappedAttribute(memoryUsage)
は、MemoryUsage
引数をCompositeData
に変換してからmbs.setAttribute
を呼び出します。
proxy.someOperation("whatever", memoryUsage)
は、MemoryUsage
引数をCompositeData
に変換して、mbs.invoke
を呼び出します。 mbs.invoke
により返される値もCompositeData
になります。プロキシは、MXBeanマッピング・ルールを使って、これを予期される型MemoryUsage
に変換します。
このメソッドにより返されるオブジェクトは、Proxy
です。このオブジェクトのInvocationHandler
はMBeanServerInvocationHandler
です。
このメソッドは、newMXBeanProxy(connection, objectName, interfaceClass, false)
と同等です。
T
- たとえば、interfaceClass
パラメータがMyMXBean.class
であれば、戻り値の型はMyMXBean
になることをコンパイラに知らせる。connection
- 送信先のMBeanサーバー。objectName
- connection
内で渡されるMBeanの名前。interfaceClass
- MXBeanインタフェース。これも返されるプロキシにより実装される。IllegalArgumentException
- interfaceClass
が準拠するMXBeanインタフェースでない場合
public static <T> T newMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass, boolean notificationEmitter)
ローカルまたはリモートのMBean Server内にMXBean用のプロキシを作成します。これは、NotificationEmitter
のメソッドもサポートする場合があります。
このメソッドの動作はnewMXBeanProxy(MBeanServerConnection, ObjectName, Class)
と同じですが、加えてnotificationEmitter
がtrue
の場合、MXBeanはNotificationBroadcaster
またはNotificationEmitter
であると見なされ、返されるプロキシはNotificationEmitter
およびinterfaceClass
を実装します。 このプロキシ上でNotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
を呼び出すと、MBeanServerConnection.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)
が呼び出される。NotificationBroadcaster
およびNotificationEmitter
のその他のメソッドの場合も同様。
T
- たとえば、interfaceClass
パラメータがMyMXBean.class
であれば、戻り値の型はMyMXBean
になることをコンパイラに知らせる。connection
- 送信先のMBeanサーバー。objectName
- connection
内で渡されるMBeanの名前。interfaceClass
- MXBeanインタフェース。これも返されるプロキシにより実装される。notificationEmitter
- connection
経由でメソッドを渡すことにより、返されたプロキシにNotificationEmitter
を実装させる。IllegalArgumentException
- interfaceClass
が準拠するMXBeanインタフェースでない場合
public static boolean isMXBeanInterface(Class<?> interfaceClass)
インタフェースがMXBeanインタフェースかどうかをテストします。 インタフェースがpublicで、@MXBean
または@MXBean(true)
が注釈として付加されているか、@MXBean
の注釈がなく、名前が「MXBean
」で終わる場合は、MXBeanインタフェースです。
interfaceClass
- 候補のインタフェース。interfaceClass
が準拠するMXBeanインタフェース
である場合はtrueNullPointerException
- interfaceClass
がnullである場合。 バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。