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

📄 snmptablesupport.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*  * @(#)file      SnmpTableSupport.java  * @(#)author    Sun Microsystems, Inc.  * @(#)version   1.18  * @(#)date      08/09/12  *  * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package com.sun.jmx.snmp.agent;// java imports//import java.io.Serializable;import java.util.Date;import java.util.Vector;import java.util.Enumeration;import java.util.List;import java.util.ArrayList;// jmx imports//import javax.management.Notification;import javax.management.ObjectName;import javax.management.NotificationFilter;import javax.management.NotificationListener;import javax.management.NotificationBroadcaster;import javax.management.MBeanNotificationInfo;import javax.management.ListenerNotFoundException;import com.sun.jmx.snmp.SnmpOid;import com.sun.jmx.snmp.SnmpValue;import com.sun.jmx.snmp.SnmpVarBind;import com.sun.jmx.snmp.SnmpStatusException;/** * This class is an abstraction for an SNMP table. * It is the base class for implementing SNMP tables in the * MBean world. * * <p> * 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. * </p> * * <p> * For each table defined in a MIB, mibgen will generate a specific * class called Table<i>TableName</i> that will subclass this class, and * a corresponding <i>TableName</i>Meta class extending SnmpMibTable  * and corresponding to the MIB view of the same table. * </p> * * <p> * Objects of this class are instantiated by MBeans representing * the SNMP Group to which the table belong. * </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.SnmpTableEntryFactory * @see com.sun.jmx.snmp.agent.SnmpMibTable * */public abstract class SnmpTableSupport implements SnmpTableEntryFactory, // NPCTE fix for bugId 4499265, esc 0, MR 04 sept 2001//  SnmpTableCallbackHandler {    SnmpTableCallbackHandler, Serializable {// end of NPCTE fix for bugId 4499265    //-----------------------------------------------------------------    //    //  Protected Variables    //    //-----------------------------------------------------------------        /**     * The list of entries     **/    protected List         entries;    /**     * The associated metadata object     **/    protected SnmpMibTable meta;    /**     * The MIB to which this table belongs     **/    protected SnmpMib      theMib;    //-----------------------------------------------------------------    //    //  Private Variables    //    //-----------------------------------------------------------------        /**     * This variable is initialized while binding this object to its      * corresponding meta object.     **/    private boolean registrationRequired = false;    //-----------------------------------------------------------------    //    //  Constructor    //    //-----------------------------------------------------------------    /**     * Initializes the table.     * The steps are these:     * <ul><li> allocate an array for storing entry object,</li>     *     <li> retrieve the corresponding metadata object     *          from the MIB,     *     <li> bind this object to the corresponding metadata object     *          from the MIB.</li>     * </ul>     *     * @param mib The MIB to which this table belong.      *     **/    protected SnmpTableSupport(SnmpMib mib) {	theMib  = mib;	meta    = getRegisteredTableMeta(mib);	bindWithTableMeta();	entries = allocateTable();    }    //-----------------------------------------------------------------    //    //  Implementation of the SnmpTableEntryFactory interface    //    //-----------------------------------------------------------------    /**     * Creates a new entry in the table.     *     * This factory method is generated by mibgen and used internally.     * It is part of the      * {@link com.sun.jmx.snmp.agent.SnmpTableEntryFactory} interface.     * You may subclass this method to implement any specific behaviour     * your application requires.     *     * @exception SnmpStatusException if the entry cannot be created.     **/    public abstract void createNewEntry(SnmpMibSubRequest request, 					SnmpOid rowOid, int depth, 					SnmpMibTable meta) 	throws SnmpStatusException;    //-----------------------------------------------------------------    //    //  Public methods    //    //-----------------------------------------------------------------    /**     * Returns the entry located at the given position in the table.     *     * @return The entry located at the given position, <code>null</code>     *         if no entry can be found at this position.     **/    // XXXX xxxx zzz ZZZZ => public? or protected?    public Object getEntry(int pos) {	if (entries == null) return null;	return entries.get(pos);    }    /**     * Returns the number of entries registered in the table.     *     * @return The number of entries registered in the table.     **/    public int getSize() {	return meta.getSize();    }    /**     * This method lets you dynamically switch the creation policy.     *     * <CODE>setCreationEnabled()</CODE> will switch the policy of      *      remote entry creation via SET operations, by calling      *      <code>setCreationEnabled()</code> on the metadata object      *      associated with this table.     * <BR> By default remote entry creation via SET operation is disabled.     *     * @param remoteCreationFlag Tells whether remote entry creation must     *        be enabled or disabled.     * <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>     *     * @see com.sun.jmx.snmp.agent.SnmpMibTable     *     **/    public void setCreationEnabled(boolean remoteCreationFlag) {	meta.setCreationEnabled(remoteCreationFlag);    }    /**     * 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 <code>isCreationEnabled()</code> on the metadata      * object associated with this table.     *     * @return true if a new entry must be created, false otherwise.<br>     *         [default: returns <CODE>false</CODE>]     *     * @see com.sun.jmx.snmp.agent.SnmpMibTable     **/    public boolean isCreationEnabled() {	return meta.isCreationEnabled();    }    /**     * 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.     *     * @return <code>true</code> if the associated metadata requires entries     *         to be registered (mibgen generated generic metadata).     **/    public boolean isRegistrationRequired() {	return registrationRequired;    }    /**     * Builds an entry SnmpIndex from its row OID.     *     * This method is generated by mibgen and used internally.     *     * @param rowOid The SnmpOid object identifying a table entry.     *      * @return The SnmpIndex of the entry identified by <code>rowOid</code>.     *     * @exception SnmpStatusException if the index cannot be built from the      *            given OID.     **/    public SnmpIndex buildSnmpIndex(SnmpOid rowOid)  	throws SnmpStatusException {	return buildSnmpIndex(rowOid.longValue(false), 0);    }    /**     * Builds an SnmpOid from an SnmpIndex object.     *     * This method is generated by mibgen and used internally.     *     * @param index An SnmpIndex object identifying a table entry.     *     * @return The SnmpOid form of the given entry index.     *     * @exception SnmpStatusException if the given index is not valid.     **/    public abstract SnmpOid buildOidFromIndex(SnmpIndex index) 	throws SnmpStatusException;    /**     * 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.     *

⌨️ 快捷键说明

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