jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/agent/SnmpMibAgentMBean.java
changeset 27193 db6241373358
parent 27175 2c33a5c73a2e
parent 27192 a16236cd61d7
child 27194 48c1741d0f2a
equal deleted inserted replaced
27175:2c33a5c73a2e 27193:db6241373358
     1 /*
       
     2  * Copyright (c) 1999, 2013, 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 
       
    35 // jmx imports
       
    36 //
       
    37 import javax.management.MBeanServer;
       
    38 import javax.management.ObjectName;
       
    39 import javax.management.MalformedObjectNameException;
       
    40 import javax.management.InstanceNotFoundException;
       
    41 import javax.management.ServiceNotFoundException;
       
    42 import com.sun.jmx.snmp.SnmpOid;
       
    43 import com.sun.jmx.snmp.SnmpStatusException;
       
    44 
       
    45 /**
       
    46  * Exposes the remote management interface of the <CODE>SnmpMibAgent</CODE> MBean.
       
    47  *
       
    48  * <p><b>This API is a Sun Microsystems internal API  and is subject
       
    49  * to change without notice.</b></p>
       
    50  */
       
    51 
       
    52 public interface SnmpMibAgentMBean {
       
    53 
       
    54     // PUBLIC METHODS
       
    55     //---------------
       
    56 
       
    57     /**
       
    58      * Processes a <CODE>get</CODE> operation.
       
    59      * This method must not be called from remote.
       
    60      *
       
    61      * @param req The SnmpMibRequest object holding the list of variables to
       
    62      *            be retrieved. This list is composed of
       
    63      *            <CODE>SnmpVarBind</CODE> objects.
       
    64      *
       
    65      * @exception SnmpStatusException An error occurred during the operation.
       
    66      * @see SnmpMibAgent#get(SnmpMibRequest)
       
    67      */
       
    68     public void get(SnmpMibRequest req) throws SnmpStatusException;
       
    69 
       
    70     /**
       
    71      * Processes a <CODE>getNext</CODE> operation.
       
    72      * This method must not be called from remote.
       
    73      *
       
    74      * @param req The SnmpMibRequest object holding the list of variables to
       
    75      *            be retrieved. This list is composed of
       
    76      *            <CODE>SnmpVarBind</CODE> objects.
       
    77      *
       
    78      * @exception SnmpStatusException An error occurred during the operation.
       
    79      * @see SnmpMibAgent#getNext(SnmpMibRequest)
       
    80      */
       
    81     public void getNext(SnmpMibRequest req) throws SnmpStatusException;
       
    82 
       
    83     /**
       
    84      * Processes a <CODE>getBulk</CODE> operation.
       
    85      * This method must not be called from remote.
       
    86      *
       
    87      * @param req The SnmpMibRequest object holding the list of variables to
       
    88      *            be retrieved. This list is composed of
       
    89      *            <CODE>SnmpVarBind</CODE> objects.
       
    90      *
       
    91      * @param nonRepeat The number of variables, starting with the first
       
    92      *    variable in the variable-bindings, for which a single
       
    93      *    lexicographic successor is requested.
       
    94      *
       
    95      * @param maxRepeat The number of lexicographic successors requested
       
    96      *    for each of the last R variables. R is the number of variables
       
    97      *    following the first <CODE>nonRepeat</CODE> variables for which
       
    98      *    multiple lexicographic successors are requested.
       
    99      *
       
   100      * @exception SnmpStatusException An error occurred during the operation.
       
   101      * @see SnmpMibAgent#getBulk(SnmpMibRequest,int,int)
       
   102      */
       
   103     public void getBulk(SnmpMibRequest req, int nonRepeat, int maxRepeat)
       
   104         throws SnmpStatusException;
       
   105 
       
   106     /**
       
   107      * Processes a <CODE>set</CODE> operation.
       
   108      * This method must not be called from remote.
       
   109      *
       
   110      * @param req The SnmpMibRequest object holding the list of variables to
       
   111      *            be set. This list is composed of
       
   112      *            <CODE>SnmpVarBind</CODE> objects.
       
   113      *
       
   114      * @exception SnmpStatusException An error occurred during the operation.
       
   115      * @see SnmpMibAgent#set(SnmpMibRequest)
       
   116      */
       
   117     public void set(SnmpMibRequest req) throws SnmpStatusException;
       
   118 
       
   119     /**
       
   120      * Checks if a <CODE>set</CODE> operation can be performed.
       
   121      * If the operation cannot be performed, the method should emit a
       
   122      * <CODE>SnmpStatusException</CODE>.
       
   123      *
       
   124      * @param req The SnmpMibRequest object holding the list of variables to
       
   125      *            be set. This list is composed of
       
   126      *            <CODE>SnmpVarBind</CODE> objects.
       
   127      *
       
   128      * @exception SnmpStatusException The <CODE>set</CODE> operation
       
   129      *    cannot be performed.
       
   130      * @see SnmpMibAgent#check(SnmpMibRequest)
       
   131      */
       
   132     public void check(SnmpMibRequest req) throws SnmpStatusException;
       
   133 
       
   134     // GETTERS AND SETTERS
       
   135     //--------------------
       
   136 
       
   137     /**
       
   138      * Gets the reference to the MBean server in which the SNMP MIB is
       
   139      * registered.
       
   140      *
       
   141      * @return The MBean server or null if the MIB is not registered in any
       
   142      *         MBean server.
       
   143      */
       
   144     public MBeanServer getMBeanServer();
       
   145 
       
   146     /**
       
   147      * Gets the reference to the SNMP protocol adaptor to which the MIB is
       
   148      * bound.
       
   149      * <BR>This method is used for accessing the SNMP MIB handler property
       
   150      * of the SNMP MIB agent in case of a standalone agent.
       
   151      *
       
   152      * @return The SNMP MIB handler.
       
   153      */
       
   154     public SnmpMibHandler getSnmpAdaptor();
       
   155 
       
   156     /**
       
   157      * Sets the reference to the SNMP protocol adaptor through which the
       
   158      * MIB will be SNMP accessible and add this new MIB in the SNMP MIB
       
   159      * handler.
       
   160      * <BR>This method is used for setting the SNMP MIB handler property of
       
   161      * the SNMP MIB agent in case of a standalone agent.
       
   162      *
       
   163      * @param stack The SNMP MIB handler.
       
   164      */
       
   165     public void setSnmpAdaptor(SnmpMibHandler stack);
       
   166 
       
   167     /**
       
   168      * Sets the reference to the SNMP protocol adaptor through which the MIB
       
   169      * will be SNMP accessible and add this new MIB in the SNMP MIB handler.
       
   170      * This method is to be called to set a specific agent to a specific OID.
       
   171      * This can be useful when dealing with MIB overlapping.
       
   172      * Some OID can be implemented in more than one MIB. In this case, the
       
   173      * OID nearer agent will be used on SNMP operations.
       
   174      * @param stack The SNMP MIB handler.
       
   175      * @param oids The set of OIDs this agent implements.
       
   176      *
       
   177      * @since 1.5
       
   178      */
       
   179     public void setSnmpAdaptor(SnmpMibHandler stack, SnmpOid[] oids);
       
   180 
       
   181     /**
       
   182      * Sets the reference to the SNMP protocol adaptor through which the MIB
       
   183      * will be SNMP accessible and add this new MIB in the SNMP MIB handler.
       
   184      * Adds a new contextualized MIB in the SNMP MIB handler.
       
   185      *
       
   186      * @param stack The SNMP MIB handler.
       
   187      * @param contextName The MIB context name. If null is passed, will be
       
   188      *        registered in the default context.
       
   189      *
       
   190      * @exception IllegalArgumentException If the parameter is null.
       
   191      *
       
   192      * @since 1.5
       
   193      */
       
   194     public void setSnmpAdaptor(SnmpMibHandler stack, String contextName);
       
   195 
       
   196     /**
       
   197      * Sets the reference to the SNMP protocol adaptor through which the MIB
       
   198      * will be SNMP accessible and adds this new MIB in the SNMP MIB handler.
       
   199      * Adds a new contextualized MIB in the SNMP MIB handler.
       
   200      *
       
   201      * @param stack The SNMP MIB handler.
       
   202      * @param contextName The MIB context name. If null is passed, will be
       
   203      *        registered in the default context.
       
   204      * @param oids The set of OIDs this agent implements.
       
   205      * @exception IllegalArgumentException If the parameter is null.
       
   206      *
       
   207      * @since 1.5
       
   208      */
       
   209     public void setSnmpAdaptor(SnmpMibHandler stack,
       
   210                                String contextName,
       
   211                                SnmpOid[] oids);
       
   212 
       
   213     /**
       
   214      * Gets the object name of the SNMP protocol adaptor to which the MIB is
       
   215      * bound.
       
   216      *
       
   217      * @return The name of the SNMP protocol adaptor.
       
   218      */
       
   219     public ObjectName getSnmpAdaptorName();
       
   220 
       
   221     /**
       
   222      * Sets the reference to the SNMP protocol adaptor through which the MIB
       
   223      * will be SNMP accessible and add this new MIB in the SNMP MIB handler
       
   224      * associated to the specified <CODE>name</CODE>.
       
   225      *
       
   226      * @param name The object name of the SNMP MIB handler.
       
   227      *
       
   228      * @exception InstanceNotFoundException The MBean does not exist in the
       
   229      *        MBean server.
       
   230      * @exception ServiceNotFoundException This SNMP MIB is not registered
       
   231      *        in the MBean server or the requested service is not supported.
       
   232      */
       
   233     public void setSnmpAdaptorName(ObjectName name)
       
   234         throws InstanceNotFoundException, ServiceNotFoundException;
       
   235 
       
   236 
       
   237     /**
       
   238      * Sets the reference to the SNMP protocol adaptor through which the MIB
       
   239      * will be SNMP accessible and add this new MIB in the SNMP MIB handler
       
   240      * associated to the specified <CODE>name</CODE>.
       
   241      * This method is to be called to set a specific agent to a specific OID.
       
   242      * This can be useful when dealing with MIB overlapping.
       
   243      * Some OID can be implemented in more than one MIB. In this case, the
       
   244      * OID nearer agent will be used on SNMP operations.
       
   245      * @param name The name of the SNMP protocol adaptor.
       
   246      * @param oids The set of OIDs this agent implements.
       
   247      * @exception InstanceNotFoundException The SNMP protocol adaptor does
       
   248      *     not exist in the MBean server.
       
   249      *
       
   250      * @exception ServiceNotFoundException This SNMP MIB is not registered
       
   251      *     in the MBean server or the requested service is not supported.
       
   252      *
       
   253      * @since 1.5
       
   254      */
       
   255     public void setSnmpAdaptorName(ObjectName name, SnmpOid[] oids)
       
   256         throws InstanceNotFoundException, ServiceNotFoundException;
       
   257 
       
   258     /**
       
   259      * Sets the reference to the SNMP protocol adaptor through which the MIB
       
   260      * will be SNMP accessible and add this new MIB in the SNMP MIB handler
       
   261      * associated to the specified <CODE>name</CODE>.
       
   262      *
       
   263      * @param name The name of the SNMP protocol adaptor.
       
   264      * @param contextName The MIB context name. If null is passed, will be
       
   265      *     registered in the default context.
       
   266      * @exception InstanceNotFoundException The SNMP protocol adaptor does
       
   267      *     not exist in the MBean server.
       
   268      *
       
   269      * @exception ServiceNotFoundException This SNMP MIB is not registered
       
   270      *     in the MBean server or the requested service is not supported.
       
   271      *
       
   272      * @since 1.5
       
   273      */
       
   274     public void setSnmpAdaptorName(ObjectName name, String contextName)
       
   275         throws InstanceNotFoundException, ServiceNotFoundException;
       
   276 
       
   277      /**
       
   278      * Sets the reference to the SNMP protocol adaptor through which the MIB
       
   279      * will be SNMP accessible and add this new MIB in the SNMP MIB handler
       
   280      * associated to the specified <CODE>name</CODE>.
       
   281      *
       
   282      * @param name The name of the SNMP protocol adaptor.
       
   283      * @param contextName The MIB context name. If null is passed, will be
       
   284      *        registered in the default context.
       
   285      * @param oids The set of OIDs this agent implements.
       
   286      * @exception InstanceNotFoundException The SNMP protocol adaptor does
       
   287      *     not exist in the MBean server.
       
   288      *
       
   289      * @exception ServiceNotFoundException This SNMP MIB is not registered
       
   290      *     in the MBean server or the requested service is not supported.
       
   291      *
       
   292      * @since 1.5
       
   293      */
       
   294     public void setSnmpAdaptorName(ObjectName name,
       
   295                                    String contextName,
       
   296                                    SnmpOid[] oids)
       
   297         throws InstanceNotFoundException, ServiceNotFoundException;
       
   298 
       
   299     /**
       
   300      * Indicates whether or not the MIB module is bound to a SNMP protocol
       
   301      * adaptor.
       
   302      * As a reminder, only bound MIBs can be accessed through SNMP protocol
       
   303      * adaptor.
       
   304      *
       
   305      * @return <CODE>true</CODE> if the MIB module is bound,
       
   306      *         <CODE>false</CODE> otherwise.
       
   307      */
       
   308     public boolean getBindingState();
       
   309 
       
   310     /**
       
   311      * Gets the MIB name.
       
   312      *
       
   313      * @return The MIB name.
       
   314      */
       
   315     public String getMibName();
       
   316 }