2011-12-12 7 views
0

MBeanInfo.getAttributes()を使用してリニア検索を行うのではなく、追加のライブラリなしで特定の属性のMBeanAttributeInfoを直接取得する方法はありますか?JMXでは、特定のMBeanAttributeInfoを直接取得できますか?

例のシナリオ:指定された属性(例ではjboss:service=Mail.State)が書き込み可能かどうかを確認します。私が見つけることを期待しています何

MBeanServer server; // Assume this is initialized somewhere else 

MBeanAttributeInfo[] infos = server.getMBeanInfo(new ObjectName("jboss:service=Mail")); 
for(MBeanAttributeInfo info : infos) { 
    if(info.getName().equals("State")) { 
     if(info.isWritable()) { 
      //do something 
     } 
     break; 
    } 
} 

MBeanServergetAttributeInfo(ObjectName name, String attribute)法のようなものです。

答えて

1

あなたはそれをすることによって得ることができます:サーバーがMBeanServerConnectionをし、「国家」である

server.getAttribute(new ObjectName("jboss:service=Mail"), "State") 

は、属性名です。

+0

ありがとうございますが、私が必要とするのは、属性の値ではなく、 'MBeanAttributeInfo'です。 –

関連する問題