com.sun.management.snmp.agent
Class SnmpMib

java.lang.Object
  extended by com.sun.management.snmp.agent.SnmpMibAgent
      extended by com.sun.management.snmp.agent.SnmpMib
All Implemented Interfaces:
SnmpMibAgentMBean, Serializable, MBeanRegistration
Direct Known Subclasses:
SNMP_USER_BASED_SM_MIB

public abstract class SnmpMib
extends SnmpMibAgent
implements Serializable

Abstract class for representing an SNMP MIB.

When compiling a SNMP MIB, among all the classes generated by mibgen, there is one which extends SnmpMib for representing a whole MIB.
The class is used by the SNMP protocol adaptor as the entry point in the MIB.

This generated class can be subclassed in your code in order to plug in your own specific behavior.

Since:
Java DMK 5.1
See Also:
Serialized Form

Field Summary
protected  SnmpMibOid root
          The top element in the Mib tree.
 
Fields inherited from class com.sun.management.snmp.agent.SnmpMibAgent
mibName, server
 
Constructor Summary
SnmpMib()
          Default constructor.
 
Method Summary
 void check(SnmpMibRequest req)
          Checks if a set operation can be performed.
 void get(SnmpMibRequest req)
          Processes a get operation.
 void getBulk(SnmpMibRequest req, int nonRepeat, int maxRepeat)
          Processes a getBulk operation.
protected  ObjectName getGroupObjectName(String name, String oid, String defaultName)
           This callback should return the ObjectName associated to the group identified by the given groupName.
protected  String getGroupOid(String groupName, String defaultOid)
           This callback should return the OID associated to the group identified by the given groupName.
 void getNext(SnmpMibRequest req)
          Processes a getNext operation.
abstract  SnmpMibTable getRegisteredTableMeta(String name)
          Returns a registered SNMP Table metadata node.
 long[] getRootOid()
          Gets the root object identifier of the MIB.
protected  void registerGroupNode(String groupName, String groupOid, ObjectName groupObjName, SnmpMibNode node, Object group, MBeanServer server)
           Register an SNMP group and its metadata node in the MIB.
abstract  void registerTableMeta(String name, SnmpMibTable table)
           Register an SNMP Table metadata node in the MIB.
 void set(SnmpMibRequest req)
          Processes a set operation.
 
Methods inherited from class com.sun.management.snmp.agent.SnmpMibAgent
getBindingState, getMBeanServer, getMibName, getSnmpAdaptor, getSnmpAdaptorName, init, newMibRequest, newMibRequest, postDeregister, postRegister, preDeregister, preRegister, setSnmpAdaptor, setSnmpAdaptor, setSnmpAdaptor, setSnmpAdaptor, setSnmpAdaptorName, setSnmpAdaptorName, setSnmpAdaptorName, setSnmpAdaptorName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected SnmpMibOid root
The top element in the Mib tree.

Constructor Detail

SnmpMib

public SnmpMib()
Default constructor. Initializes the OID tree.

Method Detail

getGroupOid

protected String getGroupOid(String groupName,
                             String defaultOid)

This callback should return the OID associated to the group identified by the given groupName.

This method is provided as a hook to plug-in some custom specific behavior. Although doing so is discouraged you might want to subclass this method in order to store & provide more metadata information (mapping OID <-> symbolic name) within the agent, or to "change" the root of the MIB OID by prefixing the defaultOid by an application dependent OID string, for instance.

The default implementation of this method is to return the given defaultOid

Parameters:
groupName - The java-ized name of the SNMP group.
defaultOid - The OID defined in the MIB for that group (in dot notation).
Returns:
The OID of the group identified by groupName, in dot-notation.

getGroupObjectName

protected ObjectName getGroupObjectName(String name,
                                        String oid,
                                        String defaultName)
                                 throws MalformedObjectNameException

This callback should return the ObjectName associated to the group identified by the given groupName.

This method is provided as a hook to plug-in some custom specific behavior. You might want to override this method in order to provide a different object naming scheme than that proposed by default by mibgen.

This method is only meaningful if the MIB is registered in the MBeanServer, otherwise, it will not be called.

The default implementation of this method is to return an ObjectName built from the given defaultName.

Parameters:
name - The java-ized name of the SNMP group.
oid - The OID returned by getGroupOid() - in dot notation.
defaultName - The name by default generated by mibgen
Returns:
The ObjectName of the group identified by name
Throws:
MalformedObjectNameException

registerGroupNode

protected void registerGroupNode(String groupName,
                                 String groupOid,
                                 ObjectName groupObjName,
                                 SnmpMibNode node,
                                 Object group,
                                 MBeanServer server)
                          throws NotCompliantMBeanException,
                                 MBeanRegistrationException,
                                 InstanceAlreadyExistsException,
                                 IllegalAccessException

Register an SNMP group and its metadata node in the MIB.

This method is provided as a hook to plug-in some custom specific behavior. You might want to override this method if you want to set special links between the MBean, its metadata node, its OID or ObjectName etc..

If the MIB is not registered in the MBeanServer, the server and groupObjName parameters will be null.
If the given group MBean is not null, and if the server and groupObjName parameters are not null, then this method will also automatically register the group MBean with the given MBeanServer server.

Parameters:
groupName - The java-ized name of the SNMP group.
groupOid - The OID as returned by getGroupOid() - in dot notation.
groupObjName - The ObjectName as returned by getGroupObjectName(). This parameter may be null if the MIB is not registered in the MBeanServer.
node - The metadata node, as returned by the metadata factory method for this group.
group - The MBean for this group, as returned by the MBean factory method for this group.
server - The MBeanServer in which the groups are to be registered. This parameter will be null if the MIB is not registered, otherwise it is a reference to the MBeanServer in which the MIB is registered.
Throws:
NotCompliantMBeanException
MBeanRegistrationException
InstanceAlreadyExistsException
IllegalAccessException

registerTableMeta

public abstract void registerTableMeta(String name,
                                       SnmpMibTable table)

Register an SNMP Table metadata node in the MIB.

This method is used internally and you should never need to call it directly.
It is used to establish the link between an SNMP table metadata node and its bean-like counterpart.
The group metadata nodes will create and register their underlying table metadata nodes in the MIB using this method.
The metadata nodes will be later retrieved from the MIB by the bean-like table objects using the getRegisterTableMeta() method.

Parameters:
name - The java-ized name of the SNMP table.
table - The SNMP table metadata node - usually this corresponds to a mibgen generated object.

getRegisteredTableMeta

public abstract SnmpMibTable getRegisteredTableMeta(String name)
Returns a registered SNMP Table metadata node.

This method is used internally and you should never need to call it directly.


get

public void get(SnmpMibRequest req)
         throws SnmpStatusException
Processes a get operation.

Specified by:
get in interface SnmpMibAgentMBean
Overrides:
get in class SnmpMibAgent
Parameters:
req - The SnmpMibRequest object holding the list of variable to be retrieved. This list is composed of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
See Also:
SnmpMibAgent.get(SnmpMibRequest)

set

public void set(SnmpMibRequest req)
         throws SnmpStatusException
Processes a set operation.

Specified by:
set in interface SnmpMibAgentMBean
Overrides:
set in class SnmpMibAgent
Parameters:
req - The SnmpMibRequest object holding the list of variable to be set. This list is composed of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation. Throwing an exception in this method will break the atomicity of the SET operation. Care must be taken so that the exception is thrown in the SnmpMibAgent.check(SnmpMibRequest) method instead.
See Also:
SnmpMibAgent.set(SnmpMibRequest)

check

public void check(SnmpMibRequest req)
           throws SnmpStatusException
Checks if a set operation can be performed. If the operation cannot be performed, the method will raise a SnmpStatusException.

Specified by:
check in interface SnmpMibAgentMBean
Overrides:
check in class SnmpMibAgent
Parameters:
req - The SnmpMibRequest object holding the list of variable to be set. This list is composed of SnmpVarBind objects.
Throws:
SnmpStatusException - The set operation cannot be performed.
See Also:
SnmpMibAgent.check(SnmpMibRequest)

getNext

public void getNext(SnmpMibRequest req)
             throws SnmpStatusException
Processes a getNext operation.

Specified by:
getNext in interface SnmpMibAgentMBean
Overrides:
getNext in class SnmpMibAgent
Parameters:
req - The SnmpMibRequest object holding the list of OIDs from which the next variables should be retrieved. This list is composed of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
See Also:
SnmpMibAgent.getNext(SnmpMibRequest)

getBulk

public void getBulk(SnmpMibRequest req,
                    int nonRepeat,
                    int maxRepeat)
             throws SnmpStatusException
Processes a getBulk operation. The method implements the getBulk operation by calling appropriately the getNext method.

Specified by:
getBulk in interface SnmpMibAgentMBean
Overrides:
getBulk in class SnmpMibAgent
Parameters:
req - The SnmpMibRequest object holding the list of variable to be retrieved. This list is composed of SnmpVarBind objects.
nonRepeat - The number of variables, starting with the first variable in the variable-bindings, for which a single lexicographic successor is requested.
maxRepeat - The number of lexicographic successors requested for each of the last R variables. R is the number of variables following the first nonRepeat variables for which multiple lexicographic successors are requested.
Throws:
SnmpStatusException - An error occurred during the operation.
See Also:
SnmpMibAgent.getBulk(SnmpMibRequest,int,int)

getRootOid

public long[] getRootOid()
Gets the root object identifier of the MIB.

In order to be accurate, the method should be called once the MIB is fully initialized (that is, after a call to init or preRegister).

Specified by:
getRootOid in class SnmpMibAgent
Returns:
The root object identifier.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.