[SNMP4J] MOTable

Frank Fock fock at agentpp.com
Mon Oct 16 22:43:01 CEST 2006


Hi Jose,

Please carefully reread my postings! If you want to
implement a virtual table DO NOT extend the
DefaultMOMutableTableModel and DO NOT extend the
DefaultMOTableModel.
Instead IMPLEMENT the MOTableModel interface with
your own class.

Best regards,
Frank

Jose Ignacio wrote:
> Yes, I was using DefaultMOMutableTableModel. Now I'm extending 
> DefaultMOMutableTableModel.
> 
> My question is, where does DefaultMOMutableTableModel checks if a cell 
> in a getNext request exists? I have traced it and only 3 methods are 
> invoked (iterator, tailIterator and getRowCount). Do I have to rewrite 
> iterator method returning a Iterator with MOTableRows ?
> 
> Initially I thought I had to rewrite covers(oid) method.
> 
> PS: I'm trying to develop a facade to snmp4j that abstract the coders of 
> snmp4j.
> 
> On 10/11/06, *Frank Fock* <fock at agentpp.com <mailto:fock at agentpp.com>> 
> wrote:
> 
>     Are you sure that you are implementing your own
>     MOTableModel? It seems to me (because you are
>     registering real rows) that you are using the
>     DefaultMOMutableTableModel.
> 
>     I meant to implement a class that only creates
>     TableRow instances when required (thus on-the-fly).
> 
>     Best regards,
>     Frank
> 
>     Jose Ignacio wrote:
>      > Thanks, but I was already using MOMutableTableModel. I have:
>      >
>      > public class TiSnmpTableVar extends DefaultMOTable{
>      >    private Object    mObject;
>      >    private Method    mMethod;
>      >
>      >    public TiSnmpTableVar(OID oid, MOTableIndex moTableIndex,
>     MOColumn[]
>      > moColumn)
>      >    {
>      >        super(oid, moTableIndex, moColumn);
>      >        ....
>      >    }
>      >
>      >    public Variable getValue (OID oid, int row)
>      >    {
>      >        try{
>      >            return (Variable) mMethod.invoke(mObject, new Object[]
>     { new
>      > Integer(oid), new Integer(row) });
>      >        } ....
>      >
>      >        return null;
>      >    }
>      > }
>      >
>      > And I use it with:
>      >
>      >        MOTableSubIndex[] subIndexes = new MOTableSubIndex[] { new
>      > MOTableSubIndex(SMIConstants.SYNTAX_INTEGER) };
>      >        MOTableIndex indexDef = new MOTableIndex(subIndexes, false);
>      >
>      >        MOColumn[] columns = new MOColumn[2];
>      >        int c = 0;
>      >        columns[c++] = new MOColumn(c,
>     SMIConstants.SYNTAX_OCTET_STRING,
>      > MOAccessImpl.ACCESS_READ_ONLY); // ifIndex
>      >        columns[c++] = new MOMutableColumn(c,
>     SMIConstants.SYNTAX_INTEGER32 ,
>      > MOAccessImpl.ACCESS_READ_WRITE, null); // ifAdminStatuls
>      >
>      >        DefaultMOTable myTable = new TiSnmpTableVar(new OID("
>      > 1.3.6.1.4.1.4444.2.9"), indexDef, columns);
>      >        MOMutableTableModel model = (MOMutableTableModel)
>     myTable.getModel
>      > ();
>      >        Variable[] rowValues1 = new Variable[] { new
>     OctetString("TiSac"),
>      > new Integer32(45) };
>      >        Variable[] rowValues2 = new Variable[] { new
>     OctetString("TiKnows"),
>      > new Integer32(2) };
>      >        Variable[] rowValues3 = new Variable[] { new
>     OctetString("TiFlows"),
>      > new Integer32(5) };
>      >        model.addRow(new DefaultMOMutableRow2PC(new OID("1"),
>     rowValues1));
>      >        model.addRow(new DefaultMOMutableRow2PC(new OID("2"),
>     rowValues2));
>      >        model.addRow(new DefaultMOMutableRow2PC(new OID("3"),
>     rowValues3));
>      >
>      > // (DefaultMOServer) mServer
>      > mServer.register(myTable , null);
>      >
>      >
>      > Then, I need to register all the rows in the table, but I can't
>     do that
>      > because I don't know any value. What I need is that when the server
>      > receives
>      > a 1.3.6.1.4.1.4444.2.9.*.* GET request the server asks the value
>     to the
>      > TiSnmpTable object.
>      >
>      >
>      >
>      > On 10/10/06, Frank Fock <fock at agentpp.com
>     <mailto:fock at agentpp.com> > wrote:
>      >>
>      >> Hello Jose,
>      >>
>      >> For virtual table instrumentation implement the MOTableModel and
>      >> use a DefaultMOTable instance with that model. This is by far
>      >> better and a lot easier than implementing your own command
>     processor
>      >> (even better than doing that, would be implementing a sub-class
>      >> of ManagedObject).
>      >>
>      >> Best regards,
>      >> Frank
>      >>
>      >> Jose Ignacio wrote:
>      >> > Hello, now I have a more interesting problem.I think it's
>     better to
>      >> explain
>      >> > with an example:
>      >> >
>      >> > I need to send 'user id' with 'users last loggin'. I do it with
>      >> MyMOTable
>      >> > (that extends DefaultTable). getValue method calls
>     getCell(row,col)
>      >> method
>      >> > from class Users and that one returns the Variable result.
>      >> >
>      >> > The problem is that the number of users is unknown so I can't
>     register
>      >> all
>      >> > rows on the table (I can't use a listener because now the
>     values are in
>      >> a
>      >> > table, but later they can be in memory, ...). I have thought
>     to write a
>      >> > commandProcessor wich sends all requests that begins with the
>     table OID
>      >> to
>      >> > class Users.
>      >> >
>      >> > For exameple: If we have oid 1.2.3 for the table, then all
>     request for
>      >> > 1.2.3.* are sent to Users class.
>      >> >
>      >> >
>      >> > Thanks
>      >> > --
>      >> > Jose Ignacio
>      >> > _______________________________________________
>      >> > SNMP4J mailing list
>      >> > SNMP4J at agentpp.org <mailto:SNMP4J at agentpp.org>
>      >> > http://lists.agentpp.org/mailman/listinfo/snmp4j
>      >>
>      >> --
>      >> AGENT++
>      >> http://www.agentpp.com <http://www.agentpp.com>
>      >> http://www.mibexplorer.com
>      >> http://www.mibdesigner.com
>      >>
>      >>
>      > _______________________________________________
>      > SNMP4J mailing list
>      > SNMP4J at agentpp.org <mailto:SNMP4J at agentpp.org>
>      > http://lists.agentpp.org/mailman/listinfo/snmp4j
> 
>     --
>     AGENT++
>     http://www.agentpp.com
>     http://www.mibexplorer.com
>     http://www.mibdesigner.com
> 
> 

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list