1 /*
   2  * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 package com.sun.jmx.snmp.agent;
  28 
  29 
  30 
  31 // java imports
  32 //
  33 import java.util.Vector;
  34 import java.io.IOException;
  35 
  36 // jmx imports
  37 //
  38 import com.sun.jmx.snmp.SnmpOid;
  39 import com.sun.jmx.snmp.SnmpStatusException;
  40 
  41 /**
  42  * The logical link between an SNMP MIB and the SNMP communication stack.
  43  *
  44  * <p><b>This API is a Sun Microsystems internal API  and is subject
  45  * to change without notice.</b></p>
  46  */
  47 
  48 public interface SnmpMibHandler {
  49 
  50     /**
  51      * Adds a new MIB in the SNMP MIB handler.
  52      * This method is called automatically by {@link com.sun.jmx.snmp.agent.SnmpMibAgent#setSnmpAdaptor(SnmpMibHandler)} and
  53      * {@link com.sun.jmx.snmp.agent.SnmpMibAgent#setSnmpAdaptorName(ObjectName)} and should not be called directly.
  54      *
  55      * @param mib The MIB to add.
  56      *
  57      * @return A reference on the SNMP MIB handler.
  58      *
  59      * @exception IllegalArgumentException If the parameter is null.
  60      */
  61     public SnmpMibHandler addMib(SnmpMibAgent mib) throws IllegalArgumentException;
  62 
  63 /**
  64      * Adds a new MIB in the SNMP MIB handler.
  65      *
  66      * @param mib The MIB to add.
  67      * @param oids The array of oid used to add the mib. Each oid is a root oid for the mib.
  68      * @return A reference on the SNMP MIB handler.
  69      *
  70      * @exception IllegalArgumentException If the parameter is null.
  71      *
  72      * @since 1.5
  73      */
  74     public SnmpMibHandler addMib(SnmpMibAgent mib, SnmpOid[] oids) throws IllegalArgumentException;
  75 
  76     /**
  77      * Adds a new contextualized MIB in the SNMP MIB handler.
  78      *
  79      * @param mib The MIB to add.
  80      * @param contextName The MIB context name. If null is passed, will be registered in the default context.
  81      *
  82      * @return A reference to the SNMP MIB handler.
  83      *
  84      * @exception IllegalArgumentException If the parameter is null.
  85      *
  86      * @since 1.5
  87      */
  88     public SnmpMibHandler addMib(SnmpMibAgent mib, String contextName)
  89         throws IllegalArgumentException;
  90 
  91     /**
  92      * Adds a new contextualized MIB in the SNMP MIB handler.
  93      *
  94      * @param mib The MIB to add.
  95      * @param contextName The MIB context name. If null is passed, will be registered in the default context.
  96      * @param oids The array of oid used to add the mib. Each oid is a root oid for the mib.
  97      *
  98      * @return A reference to the SNMP MIB handler.
  99      *
 100      * @exception IllegalArgumentException If the parameter is null.
 101      *
 102      * @since 1.5
 103      */
 104     public SnmpMibHandler addMib(SnmpMibAgent mib, String contextName, SnmpOid[] oids)
 105         throws IllegalArgumentException;
 106 
 107     /**
 108      * Removes the specified MIB from the SNMP protocol adaptor.
 109      * This method is called automatically by {@link com.sun.jmx.snmp.agent.SnmpMibAgent#setSnmpAdaptor(SnmpMibHandler)} and
 110      * {@link com.sun.jmx.snmp.agent.SnmpMibAgent#setSnmpAdaptorName(ObjectName)} and should not be called directly.
 111      *
 112      * @param mib The MIB to be removed.
 113      *
 114      * @return <CODE>true</CODE> if the specified <CODE>mib</CODE> was a MIB included in the SNMP MIB handler,
 115      * <CODE>false</CODE> otherwise.
 116      */
 117     public boolean removeMib(SnmpMibAgent mib);
 118   /**
 119      * Removes the specified MIB from the SNMP protocol adaptor.
 120      * This method is called automatically by {@link com.sun.jmx.snmp.agent.SnmpMibAgent#setSnmpAdaptor(SnmpMibHandler)} and
 121      * {@link com.sun.jmx.snmp.agent.SnmpMibAgent#setSnmpAdaptorName(ObjectName)} and should not be called directly.
 122      *
 123      * @param mib The MIB to be removed.
 124      * @param oids The oid the MIB was previously registered for.
 125      * @return <CODE>true</CODE> if the specified <CODE>mib</CODE> was a MIB included in the SNMP MIB handler,
 126      * <CODE>false</CODE> otherwise.
 127      *
 128      * @since 1.5
 129      */
 130     public boolean removeMib(SnmpMibAgent mib, SnmpOid[] oids);
 131      /**
 132      * Removes the specified MIB from the SNMP protocol adaptor.
 133      *
 134      * @param mib The MIB to be removed.
 135      * @param contextName The context name used at registration time.
 136      *
 137      * @return <CODE>true</CODE> if the specified <CODE>mib</CODE> was a MIB included in the SNMP MIB handler,
 138      * <CODE>false</CODE> otherwise.
 139      *
 140      * @since 1.5
 141      */
 142     public boolean removeMib(SnmpMibAgent mib, String contextName);
 143      /**
 144      * Removes the specified MIB from the SNMP protocol adaptor.
 145      *
 146      * @param mib The MIB to be removed.
 147      * @param contextName The context name used at registration time.
 148      * @param oids The oid the MIB was previously registered for.
 149      * @return <CODE>true</CODE> if the specified <CODE>mib</CODE> was a MIB included in the SNMP MIB handler,
 150      * <CODE>false</CODE> otherwise.
 151      *
 152      * @since 1.5
 153      */
 154     public boolean removeMib(SnmpMibAgent mib, String contextName, SnmpOid[] oids);
 155 }