⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snmpmibtable.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        // 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 	addNotificationListener(NotificationListener listener, 				NotificationFilter filter, Object handback)  {        // Check listener        //         if (listener == null) {            throw new java.lang.IllegalArgumentException 		("Listener can't be null") ;        }        // looking for listener in handbackTable        //        java.util.Vector handbackList = 	    (java.util.Vector) handbackTable.get(listener) ;         java.util.Vector filterList = 	    (java.util.Vector) filterTable.get(listener) ;         if ( handbackList == null ) {            handbackList = new java.util.Vector() ;            filterList = new java.util.Vector() ;            handbackTable.put(listener, handbackList) ;            filterTable.put(listener, filterList) ;        }        // Add the handback and the filter        //        handbackList.addElement(handback) ;        filterList.addElement(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 	removeNotificationListener(NotificationListener listener) 	throws ListenerNotFoundException {        // looking for listener in handbackTable        //        java.util.Vector handbackList = 	    (java.util.Vector) handbackTable.get(listener) ;         java.util.Vector filterList = 	    (java.util.Vector) filterTable.get(listener) ;         if ( handbackList == null ) {            throw new ListenerNotFoundException("listener");        }        // If handback is null, remove the listener entry        //        handbackTable.remove(listener) ;        filterTable.remove(listener) ;    }        /**         * Return a <CODE>NotificationInfo</CODE> object containing the      * notification class and the notification type sent by the      * <CODE>SnmpMibTable</CODE>.       */    public MBeanNotificationInfo[] getNotificationInfo() {                String[] types = {SnmpTableEntryNotification.SNMP_ENTRY_ADDED,                           SnmpTableEntryNotification.SNMP_ENTRY_REMOVED};                MBeanNotificationInfo[] notifsInfo = {	    new MBeanNotificationInfo	    (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.     */    public void registerEntryFactory(SnmpTableEntryFactory factory) {	this.factory = factory;    }    // ----------------------------------------------------------------------    // PROTECTED METHODS - RowStatus    // ----------------------------------------------------------------------            /**     * Return true if the columnar object identified by <code>var</code>     * is used to control the addition/deletion of rows in this table.     *     * <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.     *      **/    protected boolean isRowStatus(SnmpOid rowOid, long var,				    Object  userData) {	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     *     not use any variable to control creation/deletion of     *     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      *     variable to control creation/deletion of rows,     *     <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     **/    protected int getRowAction(SnmpMibSubRequest req, SnmpOid rowOid,			       int depth) 	throws SnmpStatusException {	final boolean     isnew  = req.isNewEntry();	final SnmpVarBind vb = req.getRowStatusVarBind();	if (vb == null) {	    if (isnew && ! hasRowStatus()) 		return EnumRowStatus.createAndGo;	    else return EnumRowStatus.unspecified;	}	try {	    return mapRowStatus(rowOid, vb, req.getUserData());	} catch( SnmpStatusException x) {	    checkRowStatusFail(req, x.getStatus());	}	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     **/    protected int mapRowStatus(SnmpOid rowOid, SnmpVarBind vbstatus,			       Object userData) 	throws SnmpStatusException {	final SnmpValue rsvalue = vbstatus.value;		if (rsvalue instanceof SnmpInt)	    return ((SnmpInt)rsvalue).intValue();	else	    throw new SnmpStatusException(		       SnmpStatusException.snmpRspInconsistentValue);    }    /**     * 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     **/    protected SnmpValue setRowStatus(SnmpOid rowOid, int newStatus, 				     Object userData) 	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.     *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -