com.sun.management.snmp.agent
Class SnmpTableSupport

java.lang.Object
  extended by com.sun.management.snmp.agent.SnmpTableSupport
All Implemented Interfaces:
SnmpTableCallbackHandler, SnmpTableEntryFactory, Serializable
Direct Known Subclasses:
TableUsmUserTable

public abstract class SnmpTableSupport
extends Object
implements SnmpTableEntryFactory, SnmpTableCallbackHandler, Serializable

This class is an abstraction for an SNMP table. It is the base class for implementing SNMP tables in the MBean world.

Its responsibility is to synchronize the MBean view of the table (Table of entries) with the MIB view (array of OID indexes). Each object of this class will be bound to the Metadata object which manages the same SNMP Table within the MIB.

For each table defined in a MIB, mibgen will generate a specific class called TableTableName that will subclass this class, and a corresponding TableNameMeta class extending SnmpMibTable and corresponding to the MIB view of the same table.

Objects of this class are instantiated by MBeans representing the SNMP Group to which the table belong.

Since:
Java DMK 5.1
See Also:
SnmpTableEntryFactory, SnmpMibTable, Serialized Form

Field Summary
protected  List entries
          The list of entries
protected  SnmpMibTable meta
          The associated metadata object
protected  SnmpMib theMib
          The MIB to which this table belongs
 
Constructor Summary
protected SnmpTableSupport(SnmpMib mib)
          Initializes the table.
 
Method Summary
protected  void addEntry(SnmpIndex index, Object entry)
          Add an entry in this table.
protected  void addEntry(SnmpIndex index, ObjectName name, Object entry)
          Add an entry in this table.
 void addEntryCb(int pos, SnmpOid row, ObjectName name, Object entry, SnmpMibTable meta)
          This callback is called by the associated metadata object when a new table entry has been registered in the table metadata.
 void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
          Enables to add an SNMP entry listener to this SnmpMibTable.
protected  List allocateTable()
          Allocates an ArrayList for storing table entries.
protected  void bindWithTableMeta()
          Binds this table with its associated metadata, registering itself as an SnmpTableEntryFactory.
abstract  ObjectName buildNameFromIndex(SnmpIndex index)
          Builds the default ObjectName of an entry from the SnmpIndex identifying this entry.
abstract  SnmpOid buildOidFromIndex(SnmpIndex index)
          Builds an SnmpOid from an SnmpIndex object.
protected abstract  SnmpIndex buildSnmpIndex(long[] oid, int start)
          Builds an SnmpIndex object from the index part of an OID.
 SnmpIndex buildSnmpIndex(SnmpOid rowOid)
          Builds an entry SnmpIndex from its row OID.
abstract  void createNewEntry(SnmpMibSubRequest request, SnmpOid rowOid, int depth, SnmpMibTable meta)
          Creates a new entry in the table.
protected  Object[] getBasicEntries()
          Returns the entries in the table.
 Object getEntry(int pos)
          Returns the entry located at the given position in the table.
 MBeanNotificationInfo[] getNotificationInfo()
          Returns a NotificationInfo object containing the notification class and the notification type sent by the SnmpMibTable.
protected abstract  SnmpMibTable getRegisteredTableMeta(SnmpMib mib)
          Returns the metadata object associated with this table.
 int getSize()
          Returns the number of entries registered in the table.
 boolean isCreationEnabled()
          Tells whether a new entry should be created when a SET operation is received for an entry that does not exist yet.
 boolean isRegistrationRequired()
          Tells whether the metadata object to which this table is linked requires entries to be registered.
protected  void removeEntry(SnmpIndex index, Object entry)
          Remove an entry from this table.
 void removeEntryCb(int pos, SnmpOid row, ObjectName name, Object entry, SnmpMibTable meta)
          This callback is called by the associated metadata object when a new table entry has been removed from the table metadata.
 void removeNotificationListener(NotificationListener listener)
          Enables to remove an SNMP entry listener from this SnmpMibTable.
 void setCreationEnabled(boolean remoteCreationFlag)
          This method lets you dynamically switch the creation policy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entries

protected List entries
The list of entries


meta

protected SnmpMibTable meta
The associated metadata object


theMib

protected SnmpMib theMib
The MIB to which this table belongs

Constructor Detail

SnmpTableSupport

protected SnmpTableSupport(SnmpMib mib)
Initializes the table. The steps are these:

Parameters:
mib - The MIB to which this table belong.
Method Detail

createNewEntry

public abstract void createNewEntry(SnmpMibSubRequest request,
                                    SnmpOid rowOid,
                                    int depth,
                                    SnmpMibTable meta)
                             throws SnmpStatusException
Creates a new entry in the table. This factory method is generated by mibgen and used internally. It is part of the SnmpTableEntryFactory interface. You may subclass this method to implement any specific behavior your application requires.

Specified by:
createNewEntry in interface SnmpTableEntryFactory
Parameters:
request - The SNMP subrequest containing the sublist of varbinds for the new entry.
rowOid - The OID indexing the conceptual row (entry) for which the creation was requested.
depth - The depth reached in the OID tree (the position at which the columnar object ids start in the OIDs included in the varbind).
meta - The metadata object impacted by the subrequest
Throws:
SnmpStatusException - if the entry cannot be created.

getEntry

public Object getEntry(int pos)
Returns the entry located at the given position in the table.

Returns:
The entry located at the given position, null if no entry can be found at this position.

getSize

public int getSize()
Returns the number of entries registered in the table.

Returns:
The number of entries registered in the table.

setCreationEnabled

public void setCreationEnabled(boolean remoteCreationFlag)
This method lets you dynamically switch the creation policy. setCreationEnabled() will switch the policy of remote entry creation via SET operations, by calling setCreationEnabled() on the metadata object associated with this table.
By default remote entry creation via SET operation is disabled.

Parameters:
remoteCreationFlag - Tells whether remote entry creation must be enabled or disabled.
  • setCreationEnabled(true) will enable remote entry creation via SET operations.
  • setCreationEnabled(false) will disable remote entry creation via SET operations.
  • By default remote entry creation via SET operation is disabled.

    See Also:
    SnmpMibTable

    isCreationEnabled

    public boolean isCreationEnabled()
    Tells whether a new entry should be created when a SET operation is received for an entry that does not exist yet. This method calls isCreationEnabled() on the metadata object associated with this table.

    Returns:
    true if a new entry must be created, false otherwise.
    [default: returns false]
    See Also:
    SnmpMibTable

    isRegistrationRequired

    public boolean isRegistrationRequired()
    Tells whether the metadata object to which this table is linked requires entries to be registered. In this case passing an ObjectName when registering entries will be mandatory.

    Returns:
    true if the associated metadata requires entries to be registered (mibgen generated generic metadata).

    buildSnmpIndex

    public SnmpIndex buildSnmpIndex(SnmpOid rowOid)
                             throws SnmpStatusException
    Builds an entry SnmpIndex from its row OID. This method is generated by mibgen and used internally.

    Parameters:
    rowOid - The SnmpOid object identifying a table entry.
    Returns:
    The SnmpIndex of the entry identified by rowOid.
    Throws:
    SnmpStatusException - if the index cannot be built from the given OID.

    buildOidFromIndex

    public abstract SnmpOid buildOidFromIndex(SnmpIndex index)
                                       throws SnmpStatusException
    Builds an SnmpOid from an SnmpIndex object. This method is generated by mibgen and used internally.

    Parameters:
    index - An SnmpIndex object identifying a table entry.
    Returns:
    The SnmpOid form of the given entry index.
    Throws:
    SnmpStatusException - if the given index is not valid.

    buildNameFromIndex

    public abstract ObjectName buildNameFromIndex(SnmpIndex index)
                                           throws SnmpStatusException
    Builds the default ObjectName of an entry from the SnmpIndex identifying this entry. No access is made on the entry itself. This method is generated by mibgen and used internally. You can subclass this method if you want to change the default ObjectName policy. This is only meaningful when entries are registered MBeans.

    Parameters:
    index - The SnmpIndex identifying the entry from which we want to build the default ObjectName.
    Returns:
    The default ObjectName for the entry identified by the given index.
    Throws:
    SnmpStatusException - if the given index is not valid.

    addEntryCb

    public void addEntryCb(int pos,
                           SnmpOid row,
                           ObjectName name,
                           Object entry,
                           SnmpMibTable meta)
                    throws SnmpStatusException
    This callback is called by the associated metadata object when a new table entry has been registered in the table metadata. This method will update the entries list.

    Specified by:
    addEntryCb in interface SnmpTableCallbackHandler
    Parameters:
    pos - The position at which the new entry was inserted in the table.
    row - The row OID of the new entry
    name - The ObjectName of the new entry (as specified by the factory)
    entry - The new entry (as returned by the factory)
    meta - The table metadata object.
    Throws:
    SnmpStatusException

    removeEntryCb

    public void removeEntryCb(int pos,
                              SnmpOid row,
                              ObjectName name,
                              Object entry,
                              SnmpMibTable meta)
                       throws SnmpStatusException
    This callback is called by the associated metadata object when a new table entry has been removed from the table metadata. This method will update the entries list.

    Specified by:
    removeEntryCb in interface SnmpTableCallbackHandler
    Parameters:
    pos - The position from which the entry was deleted
    row - The row OID of the deleted entry
    name - The ObjectName of the deleted entry (may be null if ObjectName's were not required)
    entry - The deleted entry (may be null if only ObjectName's were required)
    meta - The table metadata object.
    Throws:
    SnmpStatusException

    addNotificationListener

    public void addNotificationListener(NotificationListener listener,
                                        NotificationFilter filter,
                                        Object handback)
    Enables to add an SNMP entry listener to this SnmpMibTable.

    Parameters:
    listener - The listener object which will handle the notifications emitted by the registered MBean.
    filter - The filter object. If filter is null, no filtering will be performed before handling notifications.
    handback - The context to be sent to the listener when a notification is emitted.
    Throws:
    IllegalArgumentException - Listener parameter is null.

    removeNotificationListener

    public void removeNotificationListener(NotificationListener listener)
                                    throws ListenerNotFoundException
    Enables to remove an SNMP entry listener from this SnmpMibTable.

    Parameters:
    listener - The listener object which will handle the notifications emitted by the registered MBean. This method will remove all the information related to this listener.
    Throws:
    ListenerNotFoundException - The listener is not registered in the MBean.

    getNotificationInfo

    public MBeanNotificationInfo[] getNotificationInfo()
    Returns a NotificationInfo object containing the notification class and the notification type sent by the SnmpMibTable.


    buildSnmpIndex

    protected abstract SnmpIndex buildSnmpIndex(long[] oid,
                                                int start)
                                         throws SnmpStatusException
    Builds an SnmpIndex object from the index part of an OID. This method is generated by mibgen and used internally.

    Parameters:
    oid - The OID from which to build the index, represented as an array of long.
    start - The position where to start from in the OID array.
    Returns:
    The SnmpOid form of the given entry index.
    Throws:
    SnmpStatusException - if the given index is not valid.

    getRegisteredTableMeta

    protected abstract SnmpMibTable getRegisteredTableMeta(SnmpMib mib)
    Returns the metadata object associated with this table. This method is generated by mibgen and used internally.

    Parameters:
    mib - The SnmpMib object holding the Metadata corresponding to this table.
    Returns:
    The metadata object associated with this table. Returns null if this implementation of the MIB doesn't support this table.

    allocateTable

    protected List allocateTable()
    Allocates an ArrayList for storing table entries. This method is called within the constructor at object creation. Any object implementing the List interface can be used.

    Returns:
    A new list in which to store entries. If null is returned then no entry will be stored in the list and getEntry() will always return null.

    addEntry

    protected void addEntry(SnmpIndex index,
                            Object entry)
                     throws SnmpStatusException
    Add an entry in this table. This method registers an entry in the table and perform synchronization with the associated table metadata object. This method assumes that the given entry will not be registered, or will be registered with its default ObjectName built from the associated SnmpIndex.

    If the entry is going to be registered, then addEntry(SnmpIndex, ObjectName, Object) should be preferred.
    This function is mainly provided for backward compatibility.

    Parameters:
    index - The SnmpIndex built from the given entry.
    entry - The entry that should be added in the table.
    Throws:
    SnmpStatusException - if the entry cannot be registered with the given index.

    addEntry

    protected void addEntry(SnmpIndex index,
                            ObjectName name,
                            Object entry)
                     throws SnmpStatusException
    Add an entry in this table. This method registers an entry in the table and performs synchronization with the associated table metadata object.

    Parameters:
    index - The SnmpIndex built from the given entry.
    name - The ObjectName with which this entry will be registered.
    entry - The entry that should be added in the table.
    Throws:
    SnmpStatusException - if the entry cannot be registered with the given index.

    removeEntry

    protected void removeEntry(SnmpIndex index,
                               Object entry)
                        throws SnmpStatusException
    Remove an entry from this table. This method unregisters an entry from the table and performs synchronization with the associated table metadata object.

    Parameters:
    index - The SnmpIndex identifying the entry.
    entry - The entry that should be removed in the table. This parameter is optional and can be omitted if it doesn't need to be passed along to the removeEntryCb() callback defined in the SnmpTableCallbackHandler interface.
    Throws:
    SnmpStatusException - if the entry cannot be unregistered.

    getBasicEntries

    protected Object[] getBasicEntries()
    Returns the entries in the table.

    Returns:
    An Object[] array containing the entries registered in the table.

    bindWithTableMeta

    protected void bindWithTableMeta()
    Binds this table with its associated metadata, registering itself as an SnmpTableEntryFactory.


    Open Source build 02
    opendmk-1.0-b02 2007.10.01_19:17:46_MEST

    Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.