|
13.1 JMXTableModelListener : An Overview
13.2 Methods Present in JMXTableModelListener Interface
The AdventNet Multi-Protocol agent supports storage of tabular data in text files, XML files, databases, and RAM. In some cases, tabular data may be held in some other form or stored externally in a different place. The JmxTableModelListener Interface is implemented to handle this type of user storage models.
13.1 JMXTableModelListener : An Overview
To use the JmxTableModelListener, the XXXTable.java has to implement the com.adventnet.utils.jmx.JmxTableModelListener interface. This interface is used for handling tables in JMX when user needs the choice of handling the table entries rather than the Multi-Protocol agent holding them in memory.
To implement this interface, follow the steps given below :
Select Project -> Settings option. In the Settings tree structure, select Source Code Generation -> Storage Model. This displays the dialog for the Storage Model on the right side.
Select the storage option for the all or any of the table as User Defined
For example, if Storage option is specified as User Defined for the adiskTable of the AGENT-SAMPLE-MIB, the following code is generated in the AdiskTable.java file.
|
public class AdiskTable implements JmxTableModelListener |
With this, the Agent gets initialized with User Storage Model and thus any request from the manager for that particular table is forwarded to the Interface implemented for this purpose. Data is retrieved from the table only when the request reaches the Agent. The interface, when initialized, calls the respective methods present in the interface. These methods will be exposed to the MBeanServer through the xxxTable.xml file. Users have to instrument these methods according to their requirement, so that it returns the required information. The xml files are generated in ./jmxprojects/<projectname>/agent/bin/conf/xml/mbeans directory.
13.2 Methods Present in JMXTableModelListener Interface
The interface has the following methods defined in it.
To Get the Entry for
the Given Row (Identified by the Instance)
The getEntry() method is used to get the entry for the given
row, identified by the instance. This method will be called when
a GET is done on a Table specifying the instance.
It takes an Object array with index objects, which identify the row
, as the parameter. It returns the CompositeData object of that instance.
Each row in the table is a CompositeData object.
|
public CompositeData getEntry(Object[] indexObjects) |
To Get the Next Entry
for the Given Row (Identified by the Instance)
The getNextEntry() method is used to get the next entry of the
given row, identified by the instance. This method will be called
while doing a walk on the Table, after calling the getFirstEntry(). It
takes an Object array with index objects, which identify the row as the
parameter. It returns the CompositeData object of that instance.
|
public CompositeData getNextEntry(Object[] indexObjects); |
To
Get the First Entry in the Table
The getFirstEntry() method is used to get the first entry in
the table. This method will be called when a walk is done on a table.
After calling the getFirstEntry(), the getNextEntry() will be called while
doing a walk on a Table.
The return type of this method is a CompositeData entry object.
|
public CompositeData getFirstEntry(); |
|
|
Note: The methods getEntry(), getNextEntry(), and getFirstEntry() will be called only through SnmpAdaptor |
To
Add a Row to the Table
The addRow() method is used to add a row to the table. This
method will be called when the manager is trying to add a row in the table.
This method takes the following parameters: The Object array with index
objects, which identify the row, and the Composite data entry.
|
public void addRow(Object[] indexObjects, CompositeData
entry) |
To Delete a Row from
the Table
The deleteRow() method is used a delete a row from the table.
This method will be called when the manager is trying to delete a row
from the table.
This method takes the object array with index objects, which identifies
the row, as its parameter.
|
public void deleteRow(Object[] indexObjects) throws Exception; |
To Modify an Existing
Row in the Table
The modifyRow() method is used to modify the values of a row
in the table. This metod will be called when the manager is trying
to modify a row in the table.
This method takes the following parameters : The Object array with
index objects, which identify the row, and the Composite data entry.
|
public void modifyRow(Object[] indexObjects, CompositeData
entry) |
|
|
Note: The methods addRow(), deleteRow(), and modifyRow() will be called from all the threeadaptors - SNMP, HTML, and TL1. |
To Return the Total
Number of Rows in the Table
The totalRows() method is used to give the total number of rows
in the table as an integer.
|
public int totalRows(); |
To Get All the Entries
in the Table
The getEntries() method is used to get all the entries in the
table . It takes the startIndex and endIndex (both as int datatype) as
the parameters and returns a List of CompositeData instances in the table.
The HTML adaptor calls this method while viewing the entries in the
table. The TL1Adaptor calls this method while doing a GETALL on the Table.
|
public java.util.List getEntries(int startIndex,int endIndex) |
For example, if the first five rows need to be retrieved from the table, the adaptors will invoke this method by passing 1, 5 as the parameters to this method. For getting the first row alone, the parameters passed would be 1, 1. Because this returns an ArrayList of CompositeData instances, the getEntry() method will be invoked after this to get the actual entries.
|
|
Note: The methods totalRows() and getEntries() will be used by the HTML and TL1 adaptors. Users who wish to have only SNMP interface need not implement this method |
|