org.ow2.jasmine.probe.collectors.jmx.internal
Class JmxUtil

java.lang.Object
  extended by org.ow2.jasmine.probe.collectors.jmx.internal.JmxUtil

public class JmxUtil
extends java.lang.Object

Support for access to MBean attributes and attribute fragments.

Author:
danesa

Constructor Summary
JmxUtil()
           
 
Method Summary
static javax.management.Attribute genElemAttribute(javax.management.MBeanServerConnection cnx, javax.management.ObjectName objname, java.lang.String attName, java.lang.String elemName)
          Construct an Attribute corresponding to an indexed attribute's element.
static javax.management.Attribute genItemAttribute(javax.management.MBeanServerConnection cnx, javax.management.ObjectName objname, java.lang.String attName, java.lang.String key)
          Construct an Attribute corresponding to an attribute's item.
static javax.management.Attribute getAttributeFragment(javax.management.MBeanServerConnection cnx, javax.management.ObjectName objname, java.lang.String name)
          Return an Attribute object corresponding to the given attribute fragment name.
static java.util.List<java.lang.String> getMBeanAttNames(javax.management.MBeanServerConnection cnx, javax.management.ObjectName on)
          Return a list of attribute names of a given MBean.
static java.util.Set<javax.management.ObjectName> getMBeans(javax.management.MBeanServerConnection cnx, javax.management.ObjectName on)
          Get all the MBeans corresponding to an ObjectName pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JmxUtil

public JmxUtil()
Method Detail

getMBeans

public static java.util.Set<javax.management.ObjectName> getMBeans(javax.management.MBeanServerConnection cnx,
                                                                   javax.management.ObjectName on)
                                                            throws java.io.IOException
Get all the MBeans corresponding to an ObjectName pattern. When the pattern is null or no domain and key properties are specified, all objects are selected (and filtered if a query is specified). It returns the set of ObjectNames for the MBeans selected.

Parameters:
cnx - Connection to the MBean server
on - ObjectName pattern
Returns:
the set of ObjectNames corresponding to the pattern
Throws:
java.io.IOException - A communication problem occurred when talking to the MBean server.

getMBeanAttNames

public static java.util.List<java.lang.String> getMBeanAttNames(javax.management.MBeanServerConnection cnx,
                                                                javax.management.ObjectName on)
                                                         throws java.io.IOException,
                                                                javax.management.JMException
Return a list of attribute names of a given MBean.

Parameters:
cnx - MBeanServer connection
on - The MBean's name.
Throws:
java.io.IOException - A communication problem occurred when talking to the MBean server.
javax.management.JMException - A JMX exception occurred when using the MBean.

getAttributeFragment

public static javax.management.Attribute getAttributeFragment(javax.management.MBeanServerConnection cnx,
                                                              javax.management.ObjectName objname,
                                                              java.lang.String name)
                                                       throws java.io.IOException,
                                                              javax.management.JMException,
                                                              FragmentNameException
Return an Attribute object corresponding to the given attribute fragment name.

Parameters:
cnx - Connection to the MBean server
objname - MBean to poll
name - fragment name
Returns:
the Attribute object containing the fragment's value. The returned Attribute object's name, is the given name.
Throws:
java.io.IOException - A communication problem occurred when talking to the MBean server.
javax.management.JMException - Problem with the JMX code.
FragmentNameException - exception related to the fragment naming policy

genItemAttribute

public static javax.management.Attribute genItemAttribute(javax.management.MBeanServerConnection cnx,
                                                          javax.management.ObjectName objname,
                                                          java.lang.String attName,
                                                          java.lang.String key)
                                                   throws java.io.IOException,
                                                          javax.management.JMException,
                                                          FragmentNameException
Construct an Attribute corresponding to an attribute's item.

Parameters:
cnx - Connection to the MBean server
objname - MBean to poll
attName - the attribute's name
key - the item's key
Returns:
the created Attribute instance
Throws:
java.io.IOException - A communication problem occurred when talking to the MBean server.
javax.management.JMException - Problem with the JMX code.
FragmentNameException - exception related to the fragment naming policy

genElemAttribute

public static javax.management.Attribute genElemAttribute(javax.management.MBeanServerConnection cnx,
                                                          javax.management.ObjectName objname,
                                                          java.lang.String attName,
                                                          java.lang.String elemName)
                                                   throws java.io.IOException,
                                                          javax.management.JMException,
                                                          FragmentNameException
Construct an Attribute corresponding to an indexed attribute's element.

Parameters:
cnx - Connection to the MBean server
objname - MBean to poll
attName - the attribute's name
elemName - indexed elemen's name (expected format is name[indexes])
key - the item's key
Returns:
the created Attribute instance
Throws:
java.io.IOException - A communication problem occurred when talking to the MBean server.
javax.management.JMException - Problem with the JMX code.
FragmentNameException - exception related to the fragment naming policy


Copyright © 2011 OW2 Consortium. All Rights Reserved.