org.snmp4j.agent.mo.jmx
Class MBeanAttributeKeyProvider

java.lang.Object
  extended by org.snmp4j.agent.mo.jmx.MBeanMOInfo
      extended by org.snmp4j.agent.mo.jmx.MBeanAttributeMOInfo
          extended by org.snmp4j.agent.mo.jmx.MBeanAttributeKeyProvider
Direct Known Subclasses:
MBeanArrayIndexKeyProvider, MBeanInvokationKeyProvider

public class MBeanAttributeKeyProvider
extends MBeanAttributeMOInfo

The MBeanAttributeKeyProvider provides the row keys of a conceptual table from a MBean attribute. The keys are returned in the same order as provided by the MBean attribute by default. If the keysNeedSorting is set, keys are returned always in their natural order.

Version:
1.0
Author:
Frank Fock

Field Summary
 
Fields inherited from class org.snmp4j.agent.mo.jmx.MBeanAttributeMOInfo
attribute
 
Constructor Summary
MBeanAttributeKeyProvider(javax.management.ObjectName name, TypedAttribute attribute)
          Creates a key provider with a MBean name and a attribute description.
MBeanAttributeKeyProvider(javax.management.ObjectName name, TypedAttribute attribute, boolean keysNeedSorting)
          Creates a key provider with a MBean name and an attribute description.
MBeanAttributeKeyProvider(javax.management.ObjectName name, TypedAttribute attribute, boolean keysNeedSorting, MBeanAttributeKeyProvider subKeyProvider, java.lang.String[] keyAttributes)
          Creates a key provider with a MBean name and an attribute description.
 
Method Summary
static java.util.List<java.lang.Integer> asList(int[] a)
           
static java.util.List<java.lang.Long> asList(long[] a)
           
protected  java.lang.Object combineKeys(java.lang.Object key, java.lang.Object subKey)
           
protected  java.util.Iterator createTailIterator(java.util.Iterator it, int indexPos)
           
protected  java.lang.Object getKey(javax.management.MBeanServerConnection server, javax.management.ObjectName row)
           
 int getKeyCount(javax.management.MBeanServerConnection server)
          Returns the number of row keys available.
protected  java.util.List getKeys(javax.management.MBeanServerConnection server, javax.management.ObjectName keyProviderInstance)
           
 java.lang.Object getRowValues(javax.management.MBeanServerConnection server, java.lang.Object indexObject)
           
protected  javax.management.ObjectName getSubKeyProviderObjectName(java.lang.Object key)
          Determine the object name for the MBean instance that provides sub key elements through the subKeyProvider.
 java.util.Iterator keyIterator(javax.management.MBeanServerConnection server)
          Returns an iterator on the keys provided by this MBean attribute.
 java.util.Iterator keyTailIterator(javax.management.MBeanServerConnection server, java.lang.Object firstRowId)
          Returns an iterator on the keys provided by this MBean attribute starting from the supplied row key.
 
Methods inherited from class org.snmp4j.agent.mo.jmx.MBeanAttributeMOInfo
getAttribute, getAttribute, getAttribute, getAttributeName, getAttributeType, setAttribute, setAttribute
 
Methods inherited from class org.snmp4j.agent.mo.jmx.MBeanMOInfo
getMBeanNames, getObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBeanAttributeKeyProvider

public MBeanAttributeKeyProvider(javax.management.ObjectName name,
                                 TypedAttribute attribute)
Creates a key provider with a MBean name and a attribute description.

Parameters:
name - a MBean's ObjectName.
attribute - the description of an attribute of the MBean identified by name.

MBeanAttributeKeyProvider

public MBeanAttributeKeyProvider(javax.management.ObjectName name,
                                 TypedAttribute attribute,
                                 boolean keysNeedSorting)
Creates a key provider with a MBean name and an attribute description.

Parameters:
name - a MBean's ObjectName.
attribute - the description of an attribute of the MBean identified by name.
keysNeedSorting - if true keys will be sorted by their natural order.

MBeanAttributeKeyProvider

public MBeanAttributeKeyProvider(javax.management.ObjectName name,
                                 TypedAttribute attribute,
                                 boolean keysNeedSorting,
                                 MBeanAttributeKeyProvider subKeyProvider,
                                 java.lang.String[] keyAttributes)
Creates a key provider with a MBean name and an attribute description.

Parameters:
name - a MBean's ObjectName.
attribute - the description of an attribute of the MBean identified by name.
keysNeedSorting - if true keys will be sorted by their natural order.
subKeyProvider - if not null, this key provider is called per key provided by this provider in order to form a combined key.
keyAttributes - if attribute is null this parameter has to be specified to identify the key attributes that build the key object for the MBean instances under name.
Method Detail

keyIterator

public java.util.Iterator keyIterator(javax.management.MBeanServerConnection server)
                               throws java.io.IOException,
                                      javax.management.MBeanException,
                                      javax.management.AttributeNotFoundException,
                                      javax.management.InstanceNotFoundException,
                                      javax.management.ReflectionException
Returns an iterator on the keys provided by this MBean attribute.

Parameters:
server - the MBeanServerConnection to be used to access the MBean.
Returns:
Iterator an iterator providing the keys returned by the key provider attribute.
Throws:
java.io.IOException
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.InstanceNotFoundException
javax.management.ReflectionException

getSubKeyProviderObjectName

protected javax.management.ObjectName getSubKeyProviderObjectName(java.lang.Object key)
                                                           throws javax.management.MalformedObjectNameException
Determine the object name for the MBean instance that provides sub key elements through the subKeyProvider. The subKeyProvider's object name will be

Parameters:
key - Object
Returns:
ObjectName
Throws:
javax.management.MalformedObjectNameException

asList

public static java.util.List<java.lang.Integer> asList(int[] a)

asList

public static java.util.List<java.lang.Long> asList(long[] a)

keyTailIterator

public java.util.Iterator keyTailIterator(javax.management.MBeanServerConnection server,
                                          java.lang.Object firstRowId)
                                   throws java.io.IOException,
                                          javax.management.MBeanException,
                                          javax.management.AttributeNotFoundException,
                                          javax.management.InstanceNotFoundException,
                                          javax.management.ReflectionException
Returns an iterator on the keys provided by this MBean attribute starting from the supplied row key.

Parameters:
server - the MBeanServerConnection to be used to access the MBean.
firstRowId - the lower bound (including) row key for the iterator.
Returns:
Iterator an iterator providing the keys returned by the key provider attribute.
Throws:
java.io.IOException
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.InstanceNotFoundException
javax.management.ReflectionException

createTailIterator

protected java.util.Iterator createTailIterator(java.util.Iterator it,
                                                int indexPos)

getKeyCount

public int getKeyCount(javax.management.MBeanServerConnection server)
                throws java.io.IOException,
                       javax.management.MBeanException,
                       javax.management.AttributeNotFoundException,
                       javax.management.InstanceNotFoundException,
                       javax.management.ReflectionException
Returns the number of row keys available.

Parameters:
server - the MBeanServerConnection to be used to access the MBean.
Returns:
the number of keys.
Throws:
java.io.IOException
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.InstanceNotFoundException
javax.management.ReflectionException

getRowValues

public java.lang.Object getRowValues(javax.management.MBeanServerConnection server,
                                     java.lang.Object indexObject)
                              throws java.io.IOException,
                                     javax.management.MBeanException,
                                     javax.management.AttributeNotFoundException,
                                     javax.management.InstanceNotFoundException,
                                     javax.management.ReflectionException
Throws:
java.io.IOException
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.InstanceNotFoundException
javax.management.ReflectionException

getKeys

protected java.util.List getKeys(javax.management.MBeanServerConnection server,
                                 javax.management.ObjectName keyProviderInstance)
                          throws java.io.IOException,
                                 javax.management.MBeanException,
                                 javax.management.AttributeNotFoundException,
                                 javax.management.InstanceNotFoundException,
                                 javax.management.ReflectionException
Throws:
java.io.IOException
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.InstanceNotFoundException
javax.management.ReflectionException

combineKeys

protected java.lang.Object combineKeys(java.lang.Object key,
                                       java.lang.Object subKey)

getKey

protected java.lang.Object getKey(javax.management.MBeanServerConnection server,
                                  javax.management.ObjectName row)
                           throws java.io.IOException,
                                  javax.management.ReflectionException,
                                  javax.management.InstanceNotFoundException
Throws:
java.io.IOException
javax.management.ReflectionException
javax.management.InstanceNotFoundException

Copyright 2006-2007 Frank Fock (SNMP4J.org)