/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class is the base class for SNMP table metadata.
* <p>
* Its responsibility is to manage a sorted array of OID indexes
* according to the SNMP indexing scheme over the "real" table.
* Each object of this class can be bound to an
* {@link com.sun.jmx.snmp.agent.SnmpTableEntryFactory} to which it will
* forward remote entry creation requests, and invoke callbacks
* when an entry has been successfully added to / removed from
* the OID index array.
* </p>
*
* <p>
* For each table defined in the MIB, mibgen will generate a specific
* class called Table<i>TableName</i> that will implement the
* SnmpTableEntryFactory interface, and a corresponding
* <i>TableName</i>Meta class that will extend this class. <br>
* The Table<i>TableName</i> class corresponds to the MBean view of the
* table while the <i>TableName</i>Meta class corresponds to the
* MIB metadata view of the same table.
* </p>
*
* <p>
* Objects of this class are instantiated by the generated
* whole MIB class extending {@link com.sun.jmx.snmp.agent.SnmpMib}
* You should never need to instantiate this class directly.
* </p>
*
* <p><b>This API is a Sun Microsystems internal API and is subject
* to change without notice.</b></p>
* @see com.sun.jmx.snmp.agent.SnmpMib
* @see com.sun.jmx.snmp.agent.SnmpMibEntry
* @see com.sun.jmx.snmp.agent.SnmpTableEntryFactory
* @see com.sun.jmx.snmp.agent.SnmpTableSupport
*
*/
implements NotificationBroadcaster, Serializable {
/**
* Create a new <CODE>SnmpMibTable</CODE> metadata node.
*
* <p>
* @param mib The SNMP MIB to which the metadata will be linked.
*/
setCreationEnabled(false);
}
// -------------------------------------------------------------------
// PUBLIC METHODS
// -------------------------------------------------------------------
/**
* This method is invoked when the creation of a new entry is requested
* by a remote SNMP manager.
* <br>By default, remote entry creation is disabled - and this method
* will not be called. You can dynamically switch the entry creation
* policy by calling <code>setCreationEnabled(true)</code> and <code>
* setCreationEnabled(false)</code> on this object.
* <p><b><i>
* This method is called internally by the SNMP runtime and you
* should never need to call it directly. </b></i>However you might want
* to extend it in order to implement your own specific application
* behaviour, should the default behaviour not be at your convenience.
* </p>
* <p>
* @param req The SNMP subrequest requesting this creation
* @param rowOid The OID indexing the conceptual row (entry) for which
* the creation was requested.
* @param depth The position of the columnar object arc in the OIDs
* from the varbind list.
*
* @exception SnmpStatusException if the entry cannot be created.
*/
int depth)
throws SnmpStatusException;
/**
* Tell whether the specific version of this metadata generated
* by <code>mibgen</code> requires entries to be registered with
* the MBeanServer. In this case an ObjectName will have to be
* passed to addEntry() in order for the table to behave correctly
* (case of the generic metadata).
* <p>
* If that version of the metadata does not require entry to be
* registered, then passing an ObjectName becomes optional (null
* can be passed instead).
*
* @return <code>true</code> if registration is required by this
* version of the metadata.
*/
public abstract boolean isRegistrationRequired();
/**
* Tell whether a new entry should be created when a SET operation
* is received for an entry that does not exist yet.
*
* @return true if a new entry must be created, false otherwise.<br>
* [default: returns <CODE>false</CODE>]
**/
public boolean isCreationEnabled() {
return creationEnabled;
}
/**
* This method lets you dynamically switch the creation policy.
*
* <p>
* @param remoteCreationFlag Tells whether remote entry creation must
* be enabled or disabled.
* <ul><li>
* <CODE>setCreationEnabled(true)</CODE> will enable remote entry
* creation via SET operations.</li>
* <li>
* <CODE>setCreationEnabled(false)</CODE> will disable remote entry
* creation via SET operations.</li>
* <p> By default remote entry creation via SET operation is disabled.
* </p>
* </ul>
**/
}
/**
* Return <code>true</code> if the conceptual row contains a columnar
* <p>
* This columnar object can be either a variable with RowStatus
* syntax as defined by RFC 2579, or a plain variable whose
* semantics is table specific.
* <p>
* By default, this function returns <code>false</code>, and it is
* assumed that the table has no such control variable.<br>
* When <code>mibgen</code> is used over SMIv2 MIBs, it will generate
* an <code>hasRowStatus()</code> method returning <code>true</code>
* for each table containing an object with RowStatus syntax.
* <p>
* When this method returns <code>false</code> the default mechanism
* for remote entry creation is used.
* by the control variable (see getRowAction() for more details).
* <p>
* This method is called internally when a SET request involving
* this table is processed.
* <p>
* If you need to implement a control variable which do not use
* the RowStatus convention as defined by RFC 2579, you should
* subclass the generated table metadata class in order to redefine
* this method and make it returns <code>true</code>.<br>
* You will then have to redefine the isRowStatus(), mapRowStatus(),
* isRowReady(), and setRowStatus() methods to suit your specific
* implementation.
* <p>
* @return <li><code>true</code> if this table contains a control
* variable (eg: a variable with RFC 2579 RowStatus syntax),
* </li>
* <li><code>false</code> if this table does not contain
* any control variable.</li>
*
**/
public boolean hasRowStatus() {
return false;
}
// ---------------------------------------------------------------------
//
// Implements the method defined in SnmpMibNode.
//
// ---------------------------------------------------------------------
/**
* Generic handling of the <CODE>get</CODE> operation.
* <p> The default implementation of this method is to
* <ul>
* <li> check whether the entry exists, and if not register an
* exception for each varbind in the list.
* <li> call the generated
* <CODE>get(req,oid,depth+1)</CODE> method. </li>
* </ul>
* <p>
* <pre>
* public void get(SnmpMibSubRequest req, int depth)
* throws SnmpStatusException {
* boolean isnew = req.isNewEntry();
*
* // if the entry does not exists, then registers an error for
* // each varbind involved (nb: this should not happen, since
* // the error should already have been detected earlier)
* //
* if (isnew) {
* SnmpVarBind var = null;
* for (Enumeration e= req.getElements(); e.hasMoreElements();) {
* var = (SnmpVarBind) e.nextElement();
* req.registerGetException(var,noSuchNameException);
* }
* }
*
* final SnmpOid oid = req.getEntryOid();
* get(req,oid,depth+1);
* }
* </pre>
* <p> You should not need to override this method in any cases, because
* it will eventually call
* <CODE>get(SnmpMibSubRequest req, int depth)</CODE> on the generated
* derivative of <CODE>SnmpMibEntry</CODE>. If you need to implement
* specific policies for minimizing the accesses made to some remote
* underlying resources, or if you need to implement some consistency
* checks between the different values provided in the varbind list,
* you should then rather override
* <CODE>get(SnmpMibSubRequest req, int depth)</CODE> on the generated
* derivative of <CODE>SnmpMibEntry</CODE>.
* <p>
*
*/
throws SnmpStatusException {
final SnmpMibSubRequest r = req;
// if the entry does not exists, then registers an error for
// each varbind involved (nb: should not happen, the error
// should have been registered earlier)
if (isnew) {
}
}
// SnmpIndex index = buildSnmpIndex(oid.longValue(false), 0);
// get(req,index,depth+1);
//
}
// ---------------------------------------------------------------------
//
// Implements the method defined in SnmpMibNode.
//
// ---------------------------------------------------------------------
/**
* Generic handling of the <CODE>check</CODE> operation.
* <p> The default implementation of this method is to
* <ul>
* <li> check whether a new entry must be created, and if remote
* creation of entries is enabled, create it. </li>
* <li> call the generated
* <CODE>check(req,oid,depth+1)</CODE> method. </li>
* </ul>
* <p>
* <pre>
* public void check(SnmpMibSubRequest req, int depth)
* throws SnmpStatusException {
* final SnmpOid oid = req.getEntryOid();
* final int action = getRowAction(req,oid,depth+1);
*
* beginRowAction(req,oid,depth+1,action);
* check(req,oid,depth+1);
* }
* </pre>
* <p> You should not need to override this method in any cases, because
* it will eventually call
* <CODE>check(SnmpMibSubRequest req, int depth)</CODE> on the generated
* derivative of <CODE>SnmpMibEntry</CODE>. If you need to implement
* specific policies for minimizing the accesses made to some remote
* underlying resources, or if you need to implement some consistency
* checks between the different values provided in the varbind list,
* you should then rather override
* <CODE>check(SnmpMibSubRequest req, int depth)</CODE> on the generated
* derivative of <CODE>SnmpMibEntry</CODE>.
* <p>
*
*/
throws SnmpStatusException {
"check", "Calling beginRowAction");
}
"check",
}
"check", "check finished");
}
}
// ---------------------------------------------------------------------
//
// Implements the method defined in SnmpMibNode.
//
// ---------------------------------------------------------------------
/**
* Generic handling of the <CODE>set</CODE> operation.
* <p> The default implementation of this method is to
* call the generated
* <CODE>set(req,oid,depth+1)</CODE> method.
* <p>
* <pre>
* public void set(SnmpMibSubRequest req, int depth)
* throws SnmpStatusException {
* final SnmpOid oid = req.getEntryOid();
* final int action = getRowAction(req,oid,depth+1);
*
* set(req,oid,depth+1);
* endRowAction(req,oid,depth+1,action);
* }
* </pre>
* <p> You should not need to override this method in any cases, because
* it will eventually call
* <CODE>set(SnmpMibSubRequest req, int depth)</CODE> on the generated
* derivative of <CODE>SnmpMibEntry</CODE>. If you need to implement
* specific policies for minimizing the accesses made to some remote
* underlying resources, or if you need to implement some consistency
* checks between the different values provided in the varbind list,
* you should then rather override
* <CODE>set(SnmpMibSubRequest req, int depth)</CODE> on the generated
* derivative of <CODE>SnmpMibEntry</CODE>.
* <p>
*
*/
throws SnmpStatusException {
"set", "Entering set");
}
}
"set", "Calling endRowAction");
}
"set", "RowAction finished");
}
}
/**
* Add a new entry in this <CODE>SnmpMibTable</CODE>.
* Also triggers the addEntryCB() callback of the
* {@link com.sun.jmx.snmp.agent.SnmpTableEntryFactory} interface
* if this node is bound to a factory.
*
* This method assumes that the given entry will not be registered.
* If the entry is going to be registered, or if ObjectName's are
* required, then
* {@link com.sun.jmx.snmp.agent.SnmpMibTable#addEntry(SnmpOid,
* ObjectName, Object)} should be prefered.
* <br> This function is mainly provided for backward compatibility.
*
* <p>
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row to be added.
* @param entry The entry to add.
*
* @exception SnmpStatusException The entry couldn't be added
* at the position identified by the given
* <code>rowOid</code>, or this version of the metadata
* requires ObjectName's.
*/
// public void addEntry(SnmpIndex index, Object entry)
throws SnmpStatusException {
}
/**
* Add a new entry in this <CODE>SnmpMibTable</CODE>.
* Also triggers the addEntryCB() callback of the
* {@link com.sun.jmx.snmp.agent.SnmpTableEntryFactory} interface
* if this node is bound to a factory.
*
* <p>
* @param oid The <CODE>SnmpOid</CODE> identifying the table
* row to be added.
*
* @param name The ObjectName with which this entry is registered.
* This parameter can be omitted if isRegistrationRequired()
* return false.
*
* @param entry The entry to add.
*
* @exception SnmpStatusException The entry couldn't be added
* at the position identified by the given
* <code>rowOid</code>, or if this version of the metadata
* requires ObjectName's, and the given name is null.
*/
// protected synchronized void addEntry(SnmpIndex index, ObjectName name,
// Object entry)
throws SnmpStatusException {
if (size == 0) {
// indexes.addElement(index);
// XX oids.addElement(oid);
if (entrynames != null)
size++;
// triggers callbacks on the entry factory
//
try {
} catch (SnmpStatusException x) {
removeOid(0);
if (entrynames != null)
throw x;
}
}
// sends the notifications
//
return;
}
// Get the insertion position ...
//
int pos= 0;
// bug jaw.00356.B : use oid rather than index to get the
// insertion point.
//
// Add a new element in the vectors ...
//
// indexes.addElement(index);
// XX oids.addElement(oid);
if (entrynames != null)
size++;
} else {
// Insert new element ...
//
try {
// indexes.insertElementAt(index, pos);
// XX oids.insertElementAt(oid, pos);
if (entrynames != null)
size++;
} catch(ArrayIndexOutOfBoundsException e) {
}
}
// triggers callbacks on the entry factory
//
try {
} catch (SnmpStatusException x) {
if (entrynames != null)
throw x;
}
}
// sends the notifications
//
}
/**
* Remove the specified entry from the table.
* Also triggers the removeEntryCB() callback of the
* {@link com.sun.jmx.snmp.agent.SnmpTableEntryFactory} interface
* if this node is bound to a factory.
*
* <p>
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row to remove.
*
* @param entry The entry to be removed. This parameter is not used
* internally, it is simply passed along to the
* removeEntryCB() callback.
*
* @exception SnmpStatusException if the specified entry couldn't
* be removed (if the given <code>rowOid</code> is not
* valid for instance).
*/
throws SnmpStatusException {
if (pos == -1)
return;
}
/**
* Remove the specified entry from the table.
* Also triggers the removeEntryCB() callback of the
* {@link com.sun.jmx.snmp.agent.SnmpTableEntryFactory} interface
* if this node is bound to a factory.
*
* <p>
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row to remove.
*
* @exception SnmpStatusException if the specified entry couldn't
* be removed (if the given <code>rowOid</code> is not
* valid for instance).
*/
throws SnmpStatusException {
if (pos == -1)
return;
}
/**
* Remove the specified entry from the table.
* Also triggers the removeEntryCB() callback of the
* {@link com.sun.jmx.snmp.agent.SnmpTableEntryFactory} interface
* if this node is bound to a factory.
*
* <p>
* @param pos The position of the entry in the table.
*
* @param entry The entry to be removed. This parameter is not used
* internally, it is simply passed along to the
* removeEntryCB() callback.
*
* @exception SnmpStatusException if the specified entry couldn't
* be removed.
*/
throws SnmpStatusException {
if (pos == -1)
return;
}
}
size --;
}
/**
* Get the entry corresponding to the specified rowOid.
*
* <p>
* @param rowOid The <CODE>SnmpOid</CODE> identifying the
* row to be retrieved.
*
* @return The entry.
*
* @exception SnmpStatusException There is no entry with the specified
* <code>rowOid</code> in the table.
*/
throws SnmpStatusException {
if (pos == -1)
}
/**
* Get the ObjectName of the entry corresponding to the
* specified rowOid.
* The result of this method is only meaningful if
* isRegistrationRequired() yields true.
*
* <p>
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row whose ObjectName we want to retrieve.
*
* @return The object name of the entry.
*
* @exception SnmpStatusException There is no entry with the specified
* <code>rowOid</code> in the table.
*/
throws SnmpStatusException {
}
/**
* Return the entries stored in this table <CODE>SnmpMibTable</CODE>.
* <p>
* If the subclass generated by mibgen uses the generic way to access
* the entries (i.e. if it goes through the MBeanServer) then some of
* the entries may be <code>null</code>. It all depends whether a non
* <code>null</code> entry was passed to addEntry().<br>
* Otherwise, if it uses the standard way (access the entry directly
* through their standard MBean interface) this array will contain all
* the entries.
* <p>
* @return The entries array.
*/
return array;
}
/**
* Get the size of the table.
*
* @return The number of entries currently registered in this table.
*/
public int getSize() {
return size;
}
// EVENT STUFF
//------------
/**
* Enable to add an SNMP entry listener to this
* <CODE>SnmpMibTable</CODE>.
*
* <p>
* @param listener The listener object which will handle the
* notifications emitted by the registered MBean.
*
* @param filter The filter object. If filter is null, no filtering
* will be performed before handling notifications.
*
* @param handback The context to be sent to the listener when a
* notification is emitted.
*
* @exception IllegalArgumentException Listener parameter is null.
*/
public synchronized void
// Check listener
//
("Listener can't be null") ;
}
// looking for listener in handbackTable
//
if ( handbackList == null ) {
}
// Add the handback and the filter
//
}
/**
* Enable to remove an SNMP entry listener from this
* <CODE>SnmpMibTable</CODE>.
*
* @param 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.
*
* @exception ListenerNotFoundException The listener is not registered
* in the MBean.
*/
public synchronized void
throws ListenerNotFoundException {
// looking for listener in handbackTable
//
if ( handbackList == null ) {
throw new ListenerNotFoundException("listener");
}
// If handback is null, remove the listener entry
//
}
/**
* Return a <CODE>NotificationInfo</CODE> object containing the
* notification class and the notification type sent by the
* <CODE>SnmpMibTable</CODE>.
*/
(types, "com.sun.jmx.snmp.agent.SnmpTableEntryNotification",
"Notifications sent by the SnmpMibTable")
};
return notifsInfo;
}
/**
* Register the factory through which table entries should
* be created when remote entry creation is enabled.
*
* <p>
* @param factory The
* {@link com.sun.jmx.snmp.agent.SnmpTableEntryFactory} through
* which entries will be created when a remote SNMP manager
* request the creation of a new entry via an SNMP SET request.
*/
}
// ----------------------------------------------------------------------
// PROTECTED METHODS - RowStatus
// ----------------------------------------------------------------------
/**
* Return true if the columnar object identified by <code>var</code>
*
* <p>
* By default, this method assumes that there is no control variable
* and always return <code>false</code>
* <p>
* If this table was defined using SMIv2, and if it contains a
* control variable with RowStatus syntax, <code>mibgen</code>
* will generate a non default implementation for this method
* that will identify the RowStatus control variable.
* <p>
* You will have to redefine this method if you need to implement
* control variables that do not conform to RFC 2579 RowStatus
* TEXTUAL-CONVENTION.
* <p>
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param var The OID arc identifying the involved columnar object.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
**/
return false;
}
/**
* Return the RowStatus code value specified in this request.
* <p>
* The RowStatus code value should be one of the values defined
* by {@link com.sun.jmx.snmp.EnumRowStatus}. These codes correspond
* to RowStatus codes as defined in RFC 2579, plus the <i>unspecified</i>
* value which is SNMP Runtime specific.
* <p>
*
* @param req The sub-request that must be handled by this node.
*
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param depth The depth reached in the OID tree.
*
* @return The RowStatus code specified in this request, if any:
* <ul>
* <li>If the specified row does not exist and this table do
* rows, then default creation mechanism is assumed and
* <i>createAndGo</i> is returned</li>
* <li>Otherwise, if the row exists and this table do not use any
* <i>unspecified</i> is returned.</li>
* <li>Otherwise, if the request does not contain the control variable,
* <i>unspecified</i> is returned.</li>
* <li>Otherwise, mapRowStatus() is called to extract the RowStatus
* code from the SnmpVarBind that contains the control variable.</li>
* </ul>
*
* @exception SnmpStatusException if the value of the control variable
* could not be mapped to a RowStatus code.
*
* @see com.sun.jmx.snmp.EnumRowStatus
**/
int depth)
throws SnmpStatusException {
if (isnew && ! hasRowStatus())
return EnumRowStatus.createAndGo;
else return EnumRowStatus.unspecified;
}
try {
} catch( SnmpStatusException x) {
}
return EnumRowStatus.unspecified;
}
/**
* Map the value of the <code>vbstatus</code> varbind to the
* corresponding RowStatus code defined in
* {@link com.sun.jmx.snmp.EnumRowStatus}.
* These codes correspond to RowStatus codes as defined in RFC 2579,
* plus the <i>unspecified</i> value which is SNMP Runtime specific.
* <p>
* By default, this method assumes that the control variable is
* an Integer, and it simply returns its value without further
* analysis.
* <p>
* If this table was defined using SMIv2, and if it contains a
* control variable with RowStatus syntax, <code>mibgen</code>
* will generate a non default implementation for this method.
* <p>
* You will have to redefine this method if you need to implement
* control variables that do not conform to RFC 2579 RowStatus
* TEXTUAL-CONVENTION.
*
* <p>
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param vbstatus The SnmpVarBind containing the value of the control
* variable, as identified by the isRowStatus() method.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @return The RowStatus code mapped from the value contained
* in <code>vbstatus</code>.
*
* @exception SnmpStatusException if the value of the control variable
* could not be mapped to a RowStatus code.
*
* @see com.sun.jmx.snmp.EnumRowStatus
**/
throws SnmpStatusException {
else
throw new SnmpStatusException(
}
/**
* Set the control variable to the specified <code>newStatus</code>
* value.
*
* <p>
* This method maps the given <code>newStatus</code> to the appropriate
* value for the control variable, then sets the control variable in
* the entry identified by <code>rowOid</code>. It returns the new
* value of the control variable.
* <p>
* By default, it is assumed that there is no control variable so this
* method does nothing and simply returns <code>null</code>.
* <p>
* If this table was defined using SMIv2, and if it contains a
* control variable with RowStatus syntax, <code>mibgen</code>
* will generate a non default implementation for this method.
* <p>
* You will have to redefine this method if you need to implement
* control variables that do not conform to RFC 2579 RowStatus
* TEXTUAL-CONVENTION.
*
* <p>
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param newStatus The new status for the row: one of the
* RowStatus code defined in
* {@link com.sun.jmx.snmp.EnumRowStatus}. These codes
* correspond to RowStatus codes as defined in RFC 2579,
* plus the <i>unspecified</i> value which is SNMP Runtime specific.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @return The new value of the control variable (usually
* <code>new SnmpInt(newStatus)</code>) or <code>null</code>
* if the table do not have any control variable.
*
* @exception SnmpStatusException If the given <code>newStatus</code>
* could not be set on the specified entry, or if the
* given <code>newStatus</code> is not valid.
*
* @see com.sun.jmx.snmp.EnumRowStatus
**/
throws SnmpStatusException {
return null;
}
/**
* Tell whether the specified row is ready and can be put in the
* <i>notInService</i> state.
* <p>
* This method is called only once, after all the varbind have been
* set on a new entry for which <i>createAndWait</i> was specified.
* <p>
* If the entry is not yet ready, this method should return false.
* It will then be the responsibility of the entry to switch its
* own state to <i>notInService</i> when it becomes ready.
* No further call to <code>isRowReady()</code> will be made.
* <p>
* By default, this method always return true. <br>
* <code>mibgen</code> will not generate any specific implementation
* for this method - meaning that by default, a row created using
* <i>createAndWait</i> will always be placed in <i>notInService</i>
* state at the end of the request.
* <p>
* If this table was defined using SMIv2, and if it contains a
* control variable with RowStatus syntax, <code>mibgen</code>
* will generate an implementation for this method that will
* delegate the work to the metadata class modelling the conceptual
* row, so that you can override the default behaviour by subclassing
* that metadata class.
* <p>
* You will have to redefine this method if this default mechanism
* does not suit your needs.
*
* <p>
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @return <code>true</code> if the row can be placed in
* <i>notInService</i> state.
*
* @exception SnmpStatusException An error occured while trying
* to retrieve the row status, and the operation should
* be aborted.
*
* @see com.sun.jmx.snmp.EnumRowStatus
**/
throws SnmpStatusException {
return true;
}
/**
* Check whether the control variable of the given row can be
* switched to the new specified <code>newStatus</code>.
* <p>
* This method is called during the <i>check</i> phase of a SET
* request when the control variable specifies <i>active</i> or
* <i>notInService</i>.
* <p>
* By default it is assumed that nothing prevents putting the
* row in the requested state, and this method does nothing.
* It is simply provided as a hook so that specific checks can
* be implemented.
* <p>
* Note that if the actual row deletion fails afterward, the
* atomicity of the request is no longer guaranteed.
*
* <p>
* @param req The sub-request that must be handled by this node.
*
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param depth The depth reached in the OID tree.
*
* @param newStatus The new status for the row: one of the
* RowStatus code defined in
* {@link com.sun.jmx.snmp.EnumRowStatus}. These codes
* correspond to RowStatus codes as defined in RFC 2579,
* plus the <i>unspecified</i> value which is SNMP Runtime specific.
*
* @exception SnmpStatusException if switching to this new state
* would fail.
*
**/
int newStatus)
throws SnmpStatusException {
}
/**
* Check whether the specified row can be removed from the table.
* <p>
* This method is called during the <i>check</i> phase of a SET
* request when the control variable specifies <i>destroy</i>
* <p>
* By default it is assumed that nothing prevents row deletion
* and this method does nothing. It is simply provided as a hook
* so that specific checks can be implemented.
* <p>
* Note that if the actual row deletion fails afterward, the
* atomicity of the request is no longer guaranteed.
*
* <p>
* @param req The sub-request that must be handled by this node.
*
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param depth The depth reached in the OID tree.
*
* @exception SnmpStatusException if the row deletion must be
* rejected.
**/
int depth)
throws SnmpStatusException {
}
/**
* Remove a table row upon a remote manager request.
*
* This method is called internally when <code>getRowAction()</code>
* yields <i>destroy</i> - i.e.: it is only called when a remote
* manager requests the removal of a table row.<br>
* You should never need to call this function directly.
* <p>
* By default, this method simply calls <code>removeEntry(rowOid)
* </code>.
* <p>
* You can redefine this method if you need to implement some
* specific behaviour when a remote row deletion is invoked.
* <p>
* Note that specific checks should not be implemented in this
* method, but rather in <code>checkRemoveTableRow()</code>.
* If <code>checkRemoveTableRow()</code> succeeds and this method
* fails afterward, the atomicity of the original SET request can no
* longer be guaranteed.
* <p>
*
* @param req The sub-request that must be handled by this node.
*
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param depth The depth reached in the OID tree.
*
* @exception SnmpStatusException if the actual row deletion fails.
* This should not happen since it would break the
* atomicity of the SET request. Specific checks should
* be implemented in <code>checkRemoveTableRow()</code>
* if needed. If the entry does not exists, no exception
* is generated and the method simply returns.
*
**/
int depth)
throws SnmpStatusException {
}
/**
* This method takes care of initial RowStatus handling during the
* check() phase of a SET request.
*
* In particular it will:
* <ul><li>check that the given <code>rowAction</code> returned by
* <code>getRowAction()</code> is valid.</li>
* <li>Then depending on the <code>rowAction</code> specified it will:
* <ul><li>either call <code>createNewEntry()</code> (<code>
* rowAction = <i>createAndGo</i> or <i>createAndWait</i>
* </code>),</li>
* <li>or call <code>checkRemoveTableRow()</code> (<code>
* rowAction = <i>destroy</i></code>),</li>
* <li>or call <code>checkRowStatusChange()</code> (<code>
* rowAction = <i>active</i> or <i>notInService</i></code>),</li>
* <li>or generate a SnmpStatusException if the passed <code>
* rowAction</code> is not correct.</li>
* </ul></li></ul>
* <p>
* In principle, you should not need to redefine this method.
* <p>
* <code>beginRowAction()</code> is called during the check phase
* of a SET request, before actual checking on the varbind list
* is performed.
*
* <p>
* @param req The sub-request that must be handled by this node.
*
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param depth The depth reached in the OID tree.
*
* @param rowAction The requested action as returned by <code>
* getRowAction()</code>: one of the RowStatus codes defined in
* {@link com.sun.jmx.snmp.EnumRowStatus}. These codes
* correspond to RowStatus codes as defined in RFC 2579,
* plus the <i>unspecified</i> value which is SNMP Runtime specific.
*
* @exception SnmpStatusException if the specified <code>rowAction</code>
* is not valid or cannot be executed.
* This should not happen since it would break the
* atomicity of the SET request. Specific checks should
* be implemented in <code>beginRowAction()</code> if needed.
*
* @see com.sun.jmx.snmp.EnumRowStatus
**/
throws SnmpStatusException {
switch (action) {
case EnumRowStatus.unspecified:
if (isnew) {
SnmpMibTable.class.getName(),
"beginRowAction", "Failed to create row[" +
rowOid + "] : RowStatus = unspecified");
}
}
break;
case EnumRowStatus.createAndGo:
case EnumRowStatus.createAndWait:
if (isnew) {
if (isCreationEnabled()) {
SnmpMibTable.class.getName(),
"] : RowStatus = createAndGo | createAndWait");
}
} else {
SnmpMibTable.class.getName(),
"] : RowStatus = createAndGo | createAndWait " +
"but creation is disabled");
}
}
} else {
SnmpMibTable.class.getName(),
"] : RowStatus = createAndGo | createAndWait " +
"but row already exists");
}
}
break;
case EnumRowStatus.destroy:
if (isnew) {
SnmpMibTable.class.getName(),
"beginRowAction",
"Warning: can't destroy row[" + rowOid +
"] : RowStatus = destroy but row does not exist");
}
} else if (!isCreationEnabled()) {
SnmpMibTable.class.getName(),
"beginRowAction",
"RowStatus = destroy but creation is disabled");
}
}
break;
case EnumRowStatus.active:
case EnumRowStatus.notInService:
if (isnew) {
SnmpMibTable.class.getName(),
"beginRowAction", "Can't switch state of row[" +
rowOid + "] : specified RowStatus = active | " +
"notInService but row does not exist");
}
}
break;
case EnumRowStatus.notReady:
default:
SnmpMibTable.class.getName(),
"beginRowAction", "Invalid RowStatus value for row[" +
}
}
}
/**
* This method takes care of final RowStatus handling during the
* set() phase of a SET request.
*
* In particular it will:
* <ul><li>either call <code>setRowStatus(<i>active</i>)</code>
* (<code> rowAction = <i>createAndGo</i> or <i>active</i>
* </code>),</li>
* <li>or call <code>setRowStatus(<i>notInService</i> or <i>
* notReady</i>)</code> depending on the result of <code>
* isRowReady()</code> (<code>rowAction = <i>createAndWait</i>
* </code>),</li>
* <li>or call <code>setRowStatus(<i>notInService</i>)</code>
* (<code> rowAction = <i>notInService</i></code>),
* <li>or call <code>removeTableRow()</code> (<code>
* rowAction = <i>destroy</i></code>),</li>
* <li>or generate a SnmpStatusException if the passed <code>
* rowAction</code> is not correct. This should be avoided
* since it would break SET request atomicity</li>
* </ul>
* <p>
* In principle, you should not need to redefine this method.
* <p>
* <code>endRowAction()</code> is called during the set() phase
* of a SET request, after the actual set() on the varbind list
* has been performed. The varbind containing the control variable
* is updated with the value returned by setRowStatus() (if it is
* not <code>null</code>).
*
* <p>
* @param req The sub-request that must be handled by this node.
*
* @param rowOid The <CODE>SnmpOid</CODE> identifying the table
* row involved in the operation.
*
* @param depth The depth reached in the OID tree.
*
* @param rowAction The requested action as returned by <code>
* getRowAction()</code>: one of the RowStatus codes defined in
* {@link com.sun.jmx.snmp.EnumRowStatus}. These codes
* correspond to RowStatus codes as defined in RFC 2579,
* plus the <i>unspecified</i> value which is SNMP Runtime specific.
*
* @exception SnmpStatusException if the specified <code>rowAction</code>
* is not valid.
*
* @see com.sun.jmx.snmp.EnumRowStatus
**/
throws SnmpStatusException {
switch (action) {
case EnumRowStatus.unspecified:
break;
case EnumRowStatus.createAndGo:
SnmpMibTable.class.getName(),
"endRowAction", "Setting RowStatus to 'active' " +
"createAndGo");
}
break;
case EnumRowStatus.createAndWait:
SnmpMibTable.class.getName(),
"endRowAction",
"Setting RowStatus to 'notInService' for row[" +
rowOid + "] : requested RowStatus = createAndWait");
}
} else {
SnmpMibTable.class.getName(),
"endRowAction", "Setting RowStatus to 'notReady' " +
"createAndWait");
}
}
break;
case EnumRowStatus.destroy:
if (isnew) {
SnmpMibTable.class.getName(),
"endRowAction",
"Warning: requested RowStatus = destroy, " +
}
} else {
SnmpMibTable.class.getName(),
"] : requested RowStatus = destroy");
}
}
break;
case EnumRowStatus.active:
SnmpMibTable.class.getName(),
"endRowAction",
"Setting RowStatus to 'active' for row[" +
rowOid + "] : requested RowStatus = active");
}
break;
case EnumRowStatus.notInService:
SnmpMibTable.class.getName(),
"endRowAction",
"Setting RowStatus to 'notInService' for row[" +
rowOid + "] : requested RowStatus = notInService");
}
break;
case EnumRowStatus.notReady:
default:
SnmpMibTable.class.getName(),
"endRowAction", "Invalid RowStatus value for row[" +
}
}
}
}
// -------------------------------------------------------------------
// PROTECTED METHODS - get next
// -------------------------------------------------------------------
/**
* Return the next OID arc corresponding to a readable columnar
* object in the underlying entry OBJECT-TYPE, possibly skipping over
* those objects that must not or cannot be returned.
* Calls {@link
* #getNextVarEntryId(com.sun.jmx.snmp.SnmpOid,long,java.lang.Object)},
* until
* {@link #skipEntryVariable(com.sun.jmx.snmp.SnmpOid,long,
* java.lang.Object,int)} returns false.
*
*
* @param rowOid The OID index of the row involved in the operation.
*
* @param var Id of the variable we start from, looking for the next.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @param pduVersion Protocol version of the original request PDU.
*
* @return The next columnar object id which can be returned using
* the given PDU's protocol version.
*
* @exception SnmpStatusException If no id is found after the given id.
*
**/
long var,
int pduVersion)
throws SnmpStatusException {
do {
return varid;
}
/**
* Hook for subclasses.
* The default implementation of this method is to always return
* false. Subclasses should redefine this method so that it returns
* true when:
* <ul><li>the variable is a leaf that is not instantiated,</li>
* <li>or the variable is a leaf whose type cannot be returned by that
* version of the protocol (e.g. an Counter64 with SNMPv1).</li>
* </ul>
*
* @param rowOid The OID index of the row involved in the operation.
*
* @param var Id of the variable we start from, looking for the next.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @param pduVersion Protocol version of the original request PDU.
*
* @return true if the variable must be skipped by the get-next
* algorithm.
*/
long var,
int pduVersion) {
return false;
}
/**
* Get the <CODE>SnmpOid</CODE> index of the row that follows
* the given <CODE>oid</CODE> in the table. The given <CODE>
* oid</CODE> does not need to be a valid row OID index.
*
* <p>
* @param oid The OID from which the search will begin.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @return The next <CODE>SnmpOid</CODE> index.
*
* @exception SnmpStatusException There is no index following the
* specified <CODE>oid</CODE> in the table.
*/
throws SnmpStatusException {
if (size == 0)
throw noSuchInstanceException;
// Just a simple check to speed up retrieval of last element ...
//
// XX SnmpOid last= (SnmpOid) oids.lastElement();
// Last element of the table ...
//
throw noSuchInstanceException;
}
// First find the oid. This will allow to speed up retrieval process
// during smart discovery of table (using the getNext) as the
// management station will use the valid index returned during a
// previous getNext ...
//
// Returns the position following the position at which resOid
// is found, or the position at which resOid should be inserted.
//
// If the position returned is not out of bound, we will find
// the next element in the array.
//
try {
// XX last = (SnmpOid) oids.elementAt(newPos);
} catch(ArrayIndexOutOfBoundsException e) {
throw noSuchInstanceException;
}
} else {
// We are dealing with the last element of the table ..
//
throw noSuchInstanceException;
}
return last;
}
/**
* Return the first entry OID registered in the table.
*
* <p>
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @return The <CODE>SnmpOid</CODE> of the first entry in the table.
*
* @exception SnmpStatusException If the table is empty.
*/
throws SnmpStatusException {
if (size == 0)
throw noSuchInstanceException;
// XX return (SnmpOid) oids.firstElement();
return tableoids[0];
}
// -------------------------------------------------------------------
// Abstract Protected Methods
// -------------------------------------------------------------------
/**
* This method is used internally and is implemented by the
* <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>.
*
* <p> Return the next OID arc corresponding to a readable columnar
* object in the underlying entry OBJECT-TYPE.</p>
*
* <p>
* @param rowOid The OID index of the row involved in the operation.
*
* @param var Id of the variable we start from, looking for the next.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @return The next columnar object id.
*
* @exception SnmpStatusException If no id is found after the given id.
*
**/
throws SnmpStatusException;
/**
* This method is used internally and is implemented by the
* <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>.
*
* <p>
* @param rowOid The OID index of the row involved in the operation.
*
* @param var The var we want to validate.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @exception SnmpStatusException If this id is not valid.
*
*/
throws SnmpStatusException;
/**
*
* This method is used internally and is implemented by the
* <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>.
*
* <p>
* @param rowOid The OID index of the row involved in the operation.
*
* @param var The OID arc.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @exception SnmpStatusException If this id is not valid.
*
*/
throws SnmpStatusException;
/**
* This method is used internally and is implemented by the
* <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>.
*/
throws SnmpStatusException;
/**
* This method is used internally and is implemented by the
* <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>.
*/
throws SnmpStatusException;
/**
* This method is used internally and is implemented by the
* <CODE>SnmpMibTable</CODE> subclasses generated by <CODE>mibgen</CODE>.
*/
throws SnmpStatusException;
// ----------------------------------------------------------------------
// PACKAGE METHODS
// ----------------------------------------------------------------------
/**
* Get the <CODE>SnmpOid</CODE> index of the row that follows the
* index extracted from the specified OID array.
* Builds the SnmpOid corresponding to the row OID and calls
* <code>getNextOid(oid,userData)</code>;
*
* <p>
* @param oid The OID array.
*
* @param pos The position in the OID array at which the index starts.
*
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @return The next <CODE>SnmpOid</CODE>.
*
* @exception SnmpStatusException There is no index following the
* specified one in the table.
*/
throws SnmpStatusException {
// Construct the sub-oid starting at pos.
// This sub-oid correspond to the oid part just after the entry
// variable oid.
//
}
// ---------------------------------------------------------------------
//
// Register an exception when checking the RowStatus variable
//
// ---------------------------------------------------------------------
int errorStatus)
throws SnmpStatusException {
}
// ---------------------------------------------------------------------
//
// Register an exception when checking the RowStatus variable
//
// ---------------------------------------------------------------------
int errorStatus)
throws SnmpStatusException {
}
// ---------------------------------------------------------------------
//
// Implements the method defined in SnmpMibNode.
//
// ---------------------------------------------------------------------
throws SnmpStatusException {
// Checks that the oid is valid
// validateOid(oid,depth);
// Gets the part of the OID that identifies the entry
// Finds the entry: false means that the entry does not exists
// Fails if the entry is not found and the table does not
// not support creation.
// We know that the entry does not exists if (isentry == false).
if (!hasEntry) {
if (!handlers.isCreationAllowed())
// we're not doing a set
throw noSuchInstanceException;
else if (!isCreationEnabled())
// we're doing a set but creation is disabled.
throw new
}
// Validate the entry id
if (hasEntry) {
// The entry already exists - validate the id
}
// Registers this node for the identified entry.
//
// We only try to identify the RowStatus for SET operations
//
else
}
// ---------------------------------------------------------------------
//
// Implements the method defined in SnmpMibNode. The algorithm is very
// largely inspired from the original getNext() method.
//
// ---------------------------------------------------------------------
throws SnmpStatusException {
// This should be considered as a genErr, but we do not want to
// abort the whole request, so we're going to throw
// a noSuchObject...
//
throw noSuchObjectException;
long var= -1;
// If the querried oid contains less arcs than the OID of the
// xxxEntry object, we must return the first leaf under the
// first columnar object: the best way to do that is to reset
// the queried oid:
// oid[0] = nodeId (arc of the xxxEntry object)
// pos = 0 (points to the arc of the xxxEntry object)
// then we just have to proceed...
//
// this will have the side effect to set
// oid[pos] = nodeId
// and
// (pos+1) = length
// so we won't fall into the "else if" cases below -
// so using "else if" rather than "if ..." is guaranteed
// to be safe.
//
oid = new long[1];
pos = 0;
length = 1;
// oid[pos] is expected to be the id of the xxxEntry ...
// The id requested is greater than the id of the xxxEntry,
// so we won't find the next element in this table... (any
// element in this table will have a smaller OID)
//
throw noSuchObjectException;
// we must return the first leaf under the first columnar
// object, so we are back to our first case where pos was
// out of bounds... => reset the oid to contain only the
// arc of the xxxEntry object.
//
oid = new long[1];
pos = 0;
length = 0;
// The arc at the position "pos+1" is the id of the columnar
// object (ie: the id of the variable in the table entry)
//
}
// Now that we've got everything right we can begin.
// pos points to the last arc in the oid, and this arc is
// guaranteed to be the xxxEntry id (we have handled all
// the other possibilities before)
//
// We must therefore return the first leaf below the first
// columnar object in the table.
//
// Get the first index. If an exception is raised,
// then it means that the table is empty. We thus do not
// have to catch the exception - we let it propagate to
// the caller.
//
// In that case we have (pos+1) = (length-1), so pos
// points to the arc of the querried variable (columnar object).
// Since the requested oid stops there, it means we have
// to return the first leaf under this columnar object.
//
// So we first get the first index:
// Note: if this raises an exception, this means that the table
// is empty, so we can let the exception propagate to the caller.
//
// XXX revisit: not exactly perfect:
// a specific row could be empty.. But we don't know
// how to make the difference! => tradeoff holes
// in tables can't be properly supported (all rows
// must have the same holes)
//
}
} else {
// So now there remain one last case, namely: some part of the
// index is provided by the oid...
// We build a possibly incomplete and invalid index from
// the OID.
// The piece of index provided should begin at pos+2
// oid[pos] = id of the xxxEntry object,
// oid[pos+1] = id of the columnar object,
// oid[pos+2] ... oid[length-1] = piece of index.
//
// We get the next index following the provided index.
// If this raises an exception, then it means that we have
// reached the last index in the table, and we must then
// try with the next columnar object.
//
// Bug fix 4269251
// The SnmpIndex is defined to contain a valid oid:
// this is not an SNMP requirement for the getNext request.
// So we no more use the SnmpIndex but directly the SnmpOid.
//
try {
// If the variable must ne skipped, fall through...
//
// XXX revisit: not exactly perfect:
// a specific row could be empty.. But we don't know
// how to make the difference! => tradeoff holes
// in tables can't be properly supported (all rows
// must have the same holes)
//
throw noSuchObjectException;
} catch(SnmpStatusException se) {
}
}
return findNextAccessibleOid(entryoid,
oid,
data,
var);
}
long var)
throws SnmpStatusException {
// Loop on each var (column)
while(true) {
// This should not happen. If it happens, (bug, or customized
// methods returning garbage instead of raising an exception),
// it probably means that there is nothing to return anyway.
// So we throw the exception.
// => will skip to next node in the MIB tree.
//
// So here we know both the row (entryoid) and the column (var)
//
try {
// Raising an exception here will make the catch() clause
// switch to the next variable. If `var' is not readable
// for this specific entry, it is not readable for any
// other entry => skip to next column.
//
throw noSuchObjectException;
// Prepare the result and the ACM checker.
//
// Copy the entryOid at the end of `result'
//
// Set the node Id and var Id in result.
//
// Append nodeId.varId.<rowOid> to ACM checker.
//
// No we're going to ACM check our OID.
try {
// No exception thrown by checker => this is all OK!
// we have it: register the handler and return the
// result.
//
return result;
} catch(SnmpStatusException e) {
// Skip to the next entry. If an exception is
// thrown, will be catch by enclosing catch
// and a skip is done to the next var.
//
} finally {
// Clean the checker.
//
}
} catch(SnmpStatusException e) {
// Catching an exception here means we have to skip to the
// next column.
//
// Back to the first row.
// Find out the next column.
//
}
// This should not happen. If it happens, (bug, or customized
// methods returning garbage instead of raising an exception),
// it probably means that there is nothing to return anyway.
// No need to continue, we throw an exception.
// => will skip to next node in the MIB tree.
//
throw noSuchObjectException;
}
}
/**
* Validate the specified OID.
*
* <p>
* @param oid The OID array.
*
* @param pos The position in the array.
*
* @exception SnmpStatusException If the validation fails.
*/
// Control the length of the oid
//
throw noSuchInstanceException;
// Check that the entry identifier is specified
//
throw noSuchObjectException;
}
// ----------------------------------------------------------------------
// PRIVATE METHODS
// ----------------------------------------------------------------------
/**
* Enable this <CODE>SnmpMibTable</CODE> to send a notification.
*
* <p>
* @param notification The notification to send.
*/
// loop on listener
//
k.hasMoreElements(); ) {
(NotificationListener) k.nextElement();
// Get the associated handback list and the associated filter list
//
// loop on handback
//
h.hasMoreElements(); ) {
}
}
}
}
/**
* This method is used by the SnmpMibTable to create and send a table
* entry notification to all the listeners registered for this kind of
* notification.
*
* <p>
* @param type The notification type.
*
* @param timeStamp The notification emission date.
*
* @param entry The entry object.
*/
synchronized(this) {
}
this.sendNotification(notif) ;
}
/**
* Return true if the entry identified by the given OID index
* is contained in this table.
* <p>
* <b>Do not call this method directly</b>.
* <p>
* This method is provided has a hook for subclasses.
* determine whether the specified entry is contained in the table.
* You may want to override this method if you need to perform e.g.
* lazy evaluation of tables (you need to update the table when a
* request is received) or if your table is virtual.
* <p>
* Note that this method is called by the Runtime from within a
* synchronized block.
*
* @param oid The index part of the OID we're looking for.
* @param userData A contextual object containing user-data.
* This object is allocated through the <code>
* {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
* for each incoming SNMP request.
*
* @return <code>true</code> if the entry is found, <code>false</code>
* otherwise.
*
* @since 1.5
**/
}
/**
* Look for the given oid in the OID table (tableoids) and returns
* its position.
*
* <p>
* @param oid The OID we're looking for.
*
* @return The position of the OID in the table. -1 if the given
* OID was not found.
*
**/
int low= 0;
int comp;
//System.out.println("Try to retrieve: " + oid.toString());
// XX pos = (SnmpOid) oids.elementAt(curr);
//System.out.println("Compare with" + pos.toString());
// never know ...we might find something ...
//
if (comp == 0)
return curr;
return curr;
}
if (comp > 0) {
} else {
}
}
return -1;
}
/**
* Search the position at which the given oid should be inserted
* in the OID table (tableoids).
*
* <p>
* @param oid The OID we would like to insert.
*
* @return The position at which the OID should be inserted in
* the table.
*
* @exception SnmpStatusException if the OID is already present in the
* table.
*
**/
throws SnmpStatusException {
return getInsertionPoint(oid, true);
}
/**
* Search the position at which the given oid should be inserted
* in the OID table (tableoids).
*
* <p>
* @param oid The OID we would like to insert.
*
* @param fail Tells whether a SnmpStatusException must be generated
* if the given OID is already present in the table.
*
* @return The position at which the OID should be inserted in
* the table. When the OID is found, it returns the next
* position. Note that it is not valid to insert twice the
* same OID. This feature is only an optimization to improve
* the getNextOid() behaviour.
*
* @exception SnmpStatusException if the OID is already present in the
* table and <code>fail</code> is <code>true</code>.
*
**/
throws SnmpStatusException {
int low= 0;
int comp;
// XX pos= (SnmpOid) oids.elementAt(curr);
// never know ...we might find something ...
//
if (comp == 0) {
if (fail)
else
return curr+1;
}
if (comp>0) {
} else {
}
}
return curr;
}
/**
* Remove the OID located at the given position.
*
* <p>
* @param pos The position at which the OID to be removed is located.
*
**/
if (pos >= tablecount) return;
if (pos < 0) return;
if (l1 > 0)
}
/**
* Insert an OID at the given position.
*
* <p>
* @param oid The OID to be inserted in the table
* @param pos The position at which the OID to be added is located.
*
**/
// Vector must be enlarged
// Save old vector
// Allocate larger vectors
// Check pos validity
// Copy original vector up to `pos'
if (l1 > 0)
// Copy original vector from `pos' to end, leaving
// an empty room at `pos' in the new vector.
if (l2 > 0)
} else if (pos < tablecount) {
// Vector is large enough to accomodate one additional
// entry.
//
// Shift vector, making an empty room at `pos'
}
// Fill the gap at `pos'
tablecount++;
}
// ----------------------------------------------------------------------
// PROTECTED VARIABLES
// ----------------------------------------------------------------------
/**
* The id of the contained entry object.
* @serial
*/
/**
* The MIB to which the metadata is linked.
* @serial
*/
/**
* <CODE>true</CODE> if remote creation of entries via SET operations
* is enabled.
* [default value is <CODE>false</CODE>]
* @serial
*/
protected boolean creationEnabled = false;
/**
* The entry factory
*/
// ----------------------------------------------------------------------
// PRIVATE VARIABLES
// ----------------------------------------------------------------------
/**
* The number of elements in the table.
* @serial
*/
/**
* The list of indexes.
* @serial
*/
// private Vector indexes= new Vector();
/**
* The list of OIDs.
* @serial
*/
// private Vector oids= new Vector();
/**
* The list of entries.
* @serial
*/
/**
* The list of object names.
* @serial
*/
/**
* Callback handlers
*/
// final Vector callbacks = new Vector();
/**
* Listener hastable containing the hand-back objects.
*/
/**
* Listener hastable containing the filter objects.
*/
// PACKAGE VARIABLES
//------------------
/**
* SNMP table sequence number.
* The default value is set to 0.
*/
}