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

📄 snmpadaptorserver.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * @param addr The IP address to bind.     *     * @since 1.5     */    public SnmpAdaptorServer(InetAddressAcl acl, InetAddress addr) {        this(false, acl, com.sun.jmx.snmp.ServiceName.SNMP_ADAPTOR_PORT,	     addr) ;    }    /**     * Initializes this SNMP protocol adaptor using the specified port, the      * specified  address based ACL implementation and the specified      * <CODE>InetAddress</CODE>.     *     * @param acl The <CODE>InetAddressAcl</CODE> implementation.     * @param port The port number for sending SNMP responses.     * @param addr The IP address to bind.     *     * @since 1.5     */    public SnmpAdaptorServer(InetAddressAcl acl, int port, InetAddress addr) {        this(false, acl, port, addr);    }    /**     * Initializes this SNMP protocol adaptor using the specified port and the      * specified <CODE>InetAddress</CODE>.     * This constructor allows to initialize an SNMP adaptor without using      * the ACL mechanism (by setting the <CODE>useAcl</CODE> parameter to      * false).     * <br>This constructor must be used in particular with a platform that      * does not support the <CODE>java.security.acl</CODE> package like pJava.     *     * @param useAcl Specifies if this new SNMP adaptor uses the ACL mechanism.     * If the specified parameter is set to <CODE>true</CODE>, this      * constructor is equivalent to     * <CODE>SnmpAdaptorServer((int)port,(InetAddress)addr)</CODE>.     * @param port The port number for sending SNMP responses.     * @param addr The IP address to bind.     */    public SnmpAdaptorServer(boolean useAcl, int port, InetAddress addr) {	this(useAcl,null,port,addr);    }    // If forceAcl is `true' and InetAddressAcl is null, then a default    // SnmpAcl object is created.    //    private SnmpAdaptorServer(boolean forceAcl, InetAddressAcl acl, 			      int port, InetAddress addr) {        super(CommunicatorServer.SNMP_TYPE) ;	                // Initialize the ACL implementation.        //        if (acl == null && forceAcl) {            try {                acl = (InetAddressAcl) 		    new SnmpAcl("SNMP protocol adaptor IP ACL");            } catch (UnknownHostException e) {                if (isDebugOn()) {                    debug("constructor", 			  "UnknowHostException when creating ACL");                    debug("constructor", e);                }            }        } else {	    this.useAcl = (acl!=null) || forceAcl;	}        init(acl, port, addr) ;    }          // GETTERS AND SETTERS    //--------------------    /**     * Gets the number of managers that have been processed by this      * SNMP protocol adaptor  since its creation.     *     * @return The number of managers handled by this SNMP protocol adaptor     * since its creation. This counter is not reset by the <CODE>stop</CODE>     * method.     */    public int getServedClientCount() {        return super.getServedClientCount();    }    /**     * Gets the number of managers currently being processed by this      * SNMP protocol adaptor.     *     * @return The number of managers currently being processed by this      * SNMP protocol adaptor.     */    public int getActiveClientCount() {        return super.getActiveClientCount();    }    /**     * Gets the maximum number of managers that this SNMP protocol adaptor can      * process concurrently.     *     * @return The maximum number of managers that this SNMP protocol adaptor      *         can process concurrently.     */    public int getMaxActiveClientCount() {        return super.getMaxActiveClientCount();    }    /**     * Sets the maximum number of managers this SNMP protocol adaptor can      * process concurrently.     *     * @param c The number of managers.     *     * @exception java.lang.IllegalStateException This method has been invoked     * while the communicator was <CODE>ONLINE</CODE> or <CODE>STARTING</CODE>.     */    public void setMaxActiveClientCount(int c) 	throws java.lang.IllegalStateException {	super.setMaxActiveClientCount(c);    }        /**     * Returns the Ip address based ACL used by this SNMP protocol adaptor.     * @return The <CODE>InetAddressAcl</CODE> implementation.     *     * @since 1.5     */    public InetAddressAcl getInetAddressAcl() {	return (InetAddressAcl)ipacl;	    }    /**     * Returns the port used by this SNMP protocol adaptor for sending traps.     * By default, port 162 is used.     *      * @return The port number for sending SNMP traps.     */    public Integer getTrapPort() {        return new Integer(trapPort) ;    }      /**     * Sets the port used by this SNMP protocol adaptor for sending traps.     *     * @param port The port number for sending SNMP traps.     */    public void setTrapPort(Integer port) {        setTrapPort(port.intValue());    }      /**     * Sets the port used by this SNMP protocol adaptor for sending traps.     *     * @param port The port number for sending SNMP traps.     */    public void setTrapPort(int port) {        int val= port ;        if (val < 0) throw new             IllegalArgumentException("Trap port cannot be a negative value");        trapPort= val ;    }      /**     * Returns the port used by this SNMP protocol adaptor for sending      * inform requests. By default, port 162 is used.     *      * @return The port number for sending SNMP inform requests.     */    public int getInformPort() {        return informPort;    }      /**     * Sets the port used by this SNMP protocol adaptor for sending      * inform requests.     *     * @param port The port number for sending SNMP inform requests.     */    public void setInformPort(int port) {        if (port < 0)            throw new IllegalArgumentException("Inform request port "+					       "cannot be a negative value");        informPort= port ;    }        /**     * Returns the protocol of this SNMP protocol adaptor.     *     * @return The string "snmp".     */    public String getProtocol() {        return "snmp";    }      /**     * Returns the buffer size of this SNMP protocol adaptor.     * This buffer size is used for both incoming request and outgoing      * inform requests.     * By default, buffer size 1024 is used.     *     * @return The buffer size.     */    public Integer getBufferSize() {        return new Integer(bufferSize) ;    }    /**     * Sets the buffer size of this SNMP protocol adaptor.     * This buffer size is used for both incoming request and outgoing      * inform requests.     *     * @param s The buffer size.     *     * @exception java.lang.IllegalStateException This method has been invoked     * while the communicator was <CODE>ONLINE</CODE> or <CODE>STARTING</CODE>.     */    public void setBufferSize(Integer s) 	throws java.lang.IllegalStateException {        if ((state == ONLINE) || (state == STARTING)) {            throw new IllegalStateException("Stop server before carrying out"+					    " this operation");        }        bufferSize = s.intValue() ;    }      /**     * Gets the number of times to try sending an inform request before      * giving up.     * By default, a maximum of 3 tries is used.     * @return The maximun number of tries.     */    final public int getMaxTries() {        return maxTries;    }        /**     * Changes the maximun number of times to try sending an inform      * request before giving up.     * @param newMaxTries The maximun number of tries.     */    final public synchronized void setMaxTries(int newMaxTries) {        if (newMaxTries < 0)            throw new IllegalArgumentException();        maxTries = newMaxTries;    }        /**     * Gets the timeout to wait for an inform response from the manager.     * By default, a timeout of 3 seconds is used.     * @return The value of the timeout property.     */    final public int getTimeout() {        return timeout;    }        /**     * Changes the timeout to wait for an inform response from the manager.     * @param newTimeout The timeout (in milliseconds).     */    final public synchronized void setTimeout(int newTimeout) {        if (newTimeout < 0)            throw new IllegalArgumentException();        timeout= newTimeout;    }        /**     * Returns the message factory of this SNMP protocol adaptor.     *     * @return The factory object.     */    public SnmpPduFactory getPduFactory() {        return pduFactory ;    }        /**     * Sets the message factory of this SNMP protocol adaptor.     *     * @param factory The factory object (null means the default factory).     */    public void setPduFactory(SnmpPduFactory factory) {        if (factory == null)            pduFactory = new SnmpPduFactoryBER() ;        else            pduFactory = factory ;    }      /**     * Set the user-data factory of this SNMP protocol adaptor.     *     * @param factory The factory object (null means no factory).     * @see com.sun.jmx.snmp.agent.SnmpUserDataFactory     */    public void setUserDataFactory(SnmpUserDataFactory factory) {	userDataFactory = factory ;    }      /**     * Get the user-data factory associated with this SNMP protocol adaptor.     *     * @return The factory object (null means no factory).     * @see com.sun.jmx.snmp.agent.SnmpUserDataFactory     */    public SnmpUserDataFactory getUserDataFactory() {	return userDataFactory;    }      /**     * Returns <CODE>true</CODE> if authentication traps are enabled.     * <P>     * When this feature is enabled, the SNMP protocol adaptor sends      * an <CODE>authenticationFailure</CODE> trap each time an      * authentication fails.     * <P>     * The default behaviour is to send authentication traps.     *      * @return <CODE>true</CODE> if authentication traps are enabled,      *         <CODE>false</CODE> otherwise.     */    public boolean getAuthTrapEnabled() {        return authTrapEnabled ;    }      /**     * Sets the flag indicating if traps need to be sent in case of      * authentication failure.     *      * @param enabled Flag indicating if traps need to be sent.     */    public void setAuthTrapEnabled(boolean enabled) {        authTrapEnabled = enabled ;    }    /**     * Returns <code>true</code> if this SNMP protocol adaptor sends a      * response in case of authentication failure.     * <P>     * When this feature is enabled, the SNMP protocol adaptor sends a      * response with <CODE>noSuchName</CODE> or <CODE>readOnly</CODE> when      * the authentication failed. If the flag is disabled, the     * SNMP protocol adaptor trashes the PDU silently.     * <P>     * The default behavior is to send responses.     *      * @return <CODE>true</CODE> if responses are sent.     */    public boolean getAuthRespEnabled() {        return authRespEnabled ;    }    /**     * Sets the flag indicating if responses need to be sent in case of      * authentication failure.     *      * @param enabled Flag indicating if responses need to be sent.     */    public void setAuthRespEnabled(boolean enabled) {        authRespEnabled = enabled ;    }        /**     * Returns the enterprise OID. It is used by      * {@link #snmpV1Trap snmpV1Trap} to fill the 'enterprise' field of the      * trap request.     *      * @return The OID in string format "x.x.x.x".     */    public String getEnterpriseOid() {        return enterpriseOid.toString() ;    }    /**     * Sets the enterprise OID.     *     * @param oid The OID in string format "x.x.x.x".     *     * @exception IllegalArgumentException The string format is incorrect     */    public void setEnterpriseOid(String oid) throws IllegalArgumentException {        enterpriseOid = new SnmpOid(oid) ;    }        /**     * Returns the names of the MIBs available in this SNMP protocol adaptor.     *      * @return An array of MIB names.     */    public String[] getMibs() {        String[] result = new String[mibs.size()] ;        int i = 0 ;        for (Enumeration e = mibs.elements() ; e.hasMoreElements() ;) {            SnmpMibAgent mib = (SnmpMibAgent)e.nextElement() ;            result[i++] = mib.getMibName();        }        return result ;    }        // GETTERS FOR SNMP GROUP (MIBII)    //-------------------------------        /**     * Returns the <CODE>snmpOutTraps</CODE> value defined in MIB-II.     *      * @return The <CODE>snmpOutTraps</CODE> value.     */    public Long getSnmpOutTraps() {        return new Long(snmpOutTraps);    }      /**

⌨️ 快捷键说明

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