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 Object

Support for access to MBean attributes and attribute fragments.

Author:
danesa

Constructor Summary
JmxUtil()
           
 
Method Summary
static Attribute createNewIndexedAttribute(String contName, String index, Object elemValue)
          Create a new Attribute instance for an indexed element.
static Attribute createNewItemAttribute(String contName, String key, Object itemValue)
          Create a new Attribute instance for a keyed item.
static Attribute getAttributeFragment(String name, Attribute att)
          Return an Attribute object corresponding to the given attribute fragment name.
static List<Attribute> getAttributeFragments(Attribute att)
          Decompose a JMX Attribute having a complex type into a list of Attributes having simple types (the fragments).
static List<String> getMBeanAttNames(MBeanServerConnection cnx, ObjectName on)
          Return a list of attribute names of a given MBean.
static Set<ObjectName> getMBeans(MBeanServerConnection cnx, 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 Set<ObjectName> getMBeans(MBeanServerConnection cnx,
                                        ObjectName on)
                                 throws 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:
IOException - A communication problem occurred when talking to the MBean server.

getMBeanAttNames

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

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

createNewIndexedAttribute

public static Attribute createNewIndexedAttribute(String contName,
                                                  String index,
                                                  Object elemValue)
Create a new Attribute instance for an indexed element. The attribute's value is the value of the element having the given index. The atrtibute's name is generated from the container's name (the name associated to the indexed object) and the index value.

Parameters:
contName - the name associated to the indexed object
index - the element's index
elemValue - the value of the element having the given index
Returns:
the created Attribute instance

createNewItemAttribute

public static Attribute createNewItemAttribute(String contName,
                                               String key,
                                               Object itemValue)
Create a new Attribute instance for a keyed item. The attribute's value is the value of the item having the given key. The atrtibute's name is generated from the container's name and the key value.

Parameters:
contName - the name associated to the composite object (the container)
key - the item's key
itemValue - the value of the item having the given key
Returns:
the created Attribute instance

getAttributeFragment

public static Attribute getAttributeFragment(String name,
                                             Attribute att)
                                      throws FragmentNameException
Return an Attribute object corresponding to the given attribute fragment name.

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

getAttributeFragments

public static List<Attribute> getAttributeFragments(Attribute att)
                                             throws ComplexValuesException
Decompose a JMX Attribute having a complex type into a list of Attributes having simple types (the fragments). The supported complex types are: The supported simple types are:

Parameters:
att - The initial attribute which may have a complex or a simple type. It its value has a simple type, the attribute is returned as it is. If it has a complex type, its value is decomposed in simple elements, the fragments.
Returns:
A list of fragments. A fragment is contained in an Attribute instance. A fragment's value is a simple value obtained by a complex value decomposition. A fragment's name is a name is based on the fragments naming policy. It starts with the initial attribute's name and contains a representation of the path followed by the decomposition process.
Throws:
ComplexValuesException


Copyright © 2012 OW2 Consortium. All Rights Reserved.