public abstract class

SnmpTableSupport

extends Object
implements SnmpTableCallbackHandler SnmpTableEntryFactory Serializable
java.lang.Object
   ↳ com.sun.jmx.snmp.agent.SnmpTableSupport

Class Overview

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.

This API is a Sun Microsystems internal API and is subject to change without notice.

Summary

Fields
protected List<Object> entries The list of entries
protected SnmpMibTable meta The associated metadata object
protected SnmpMib theMib The MIB to which this table belongs
Protected Constructors
SnmpTableSupport(SnmpMib mib)
Initializes the table.
Public Methods
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.
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.
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.
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.
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.
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.
synchronized 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.
Protected Methods
void addEntry(SnmpIndex index, ObjectName name, Object entry)
Add an entry in this table.
void addEntry(SnmpIndex index, Object entry)
Add an entry in this table.
List<Object> allocateTable()
Allocates an ArrayList for storing table entries.
void bindWithTableMeta()
Binds this table with its associated metadata, registering itself as an SnmpTableEntryFactory.
abstract SnmpIndex buildSnmpIndex(long[] oid, int start)
Builds an SnmpIndex object from the index part of an OID.
Object[] getBasicEntries()
Returns the entries in the table.
abstract SnmpMibTable getRegisteredTableMeta(SnmpMib mib)
Returns the metadata object associated with this table.
void removeEntry(SnmpIndex index, Object entry)
Remove an entry from this table.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.sun.jmx.snmp.agent.SnmpTableCallbackHandler
From interface com.sun.jmx.snmp.agent.SnmpTableEntryFactory

Fields

protected List<Object> entries

The list of entries

protected SnmpMibTable meta

The associated metadata object

protected SnmpMib theMib

The MIB to which this table belongs

Protected Constructors

protected SnmpTableSupport (SnmpMib mib)

Initializes the table. The steps are these:

  • allocate an array for storing entry object,
  • retrieve the corresponding metadata object from the MIB,
  • bind this object to the corresponding metadata object from the MIB.

Parameters
mib The MIB to which this table belong.

Public Methods

public 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. This method will update the entries list.

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.

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.

public abstract ObjectName buildNameFromIndex (SnmpIndex index)

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 meaningfull 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.

public abstract SnmpOid buildOidFromIndex (SnmpIndex index)

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.

public SnmpIndex buildSnmpIndex (SnmpOid rowOid)

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.

public abstract void createNewEntry (SnmpMibSubRequest request, SnmpOid rowOid, int depth, SnmpMibTable meta)

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 behaviour your application requires.

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.

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.

public MBeanNotificationInfo[] getNotificationInfo ()

Returns a NotificationInfo object containing the notification class and the notification type sent by the SnmpMibTable.

public int getSize ()

Returns the number of entries registered in the table.

Returns
  • The number of entries registered in the table.

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

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).

public 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. This method will update the entries list.

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.

public synchronized void removeNotificationListener (NotificationListener listener)

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.

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

    Protected Methods

    protected void addEntry (SnmpIndex index, ObjectName name, Object entry)

    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.

    protected void addEntry (SnmpIndex index, Object entry)

    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 prefered.
    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.

    protected List<Object> 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.

    protected void bindWithTableMeta ()

    Binds this table with its associated metadata, registering itself as an SnmpTableEntryFactory.

    protected abstract SnmpIndex buildSnmpIndex (long[] oid, int start)

    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.

    protected Object[] getBasicEntries ()

    Returns the entries in the table.

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

    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.

    protected void removeEntry (SnmpIndex index, Object entry)

    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.