com.sun.management.snmp.agent
Class SnmpErrorHandlerAgent

java.lang.Object
  extended by com.sun.management.snmp.agent.SnmpMibAgent
      extended by com.sun.management.snmp.agent.SnmpErrorHandlerAgent
All Implemented Interfaces:
SnmpMibAgentMBean, Serializable, MBeanRegistration

public class SnmpErrorHandlerAgent
extends SnmpMibAgent
implements Serializable

A simple MIB agent that implements SNMP calls (get, set, getnext and getbulk) in a way that only errors or exceptions are returned. Every call done on this agent fails. Error handling is done according to the manager's SNMP protocol version.

It is used by SnmpAdaptorServer for its default agent behavior. When a received Oid doesn't match, this agent is called to fill the result list with errors.

Since:
Java DMK 5.1
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.sun.management.snmp.agent.SnmpMibAgent
mibName, server
 
Constructor Summary
SnmpErrorHandlerAgent()
           
 
Method Summary
 void check(SnmpMibRequest inRequest)
          Checks if a set operation can be performed.
 void get(SnmpMibRequest inRequest)
          Processes a get operation.
 void getBulk(SnmpMibRequest inRequest, int nonRepeat, int maxRepeat)
          Processes a getBulk operation.
 void getNext(SnmpMibRequest inRequest)
          Processes a getNext operation.
 long[] getRootOid()
          Gets the root object identifier of the MIB.
 void init()
          Initializes the MIB (with no registration of the MBeans into the MBean server).
 ObjectName preRegister(MBeanServer server, ObjectName name)
          Initializes the MIB but each single MBean representing the MIB is inserted into the MBean server.
 void set(SnmpMibRequest inRequest)
          Processes a set operation.
 
Methods inherited from class com.sun.management.snmp.agent.SnmpMibAgent
getBindingState, getMBeanServer, getMibName, getSnmpAdaptor, getSnmpAdaptorName, newMibRequest, newMibRequest, postDeregister, postRegister, preDeregister, 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
 

Constructor Detail

SnmpErrorHandlerAgent

public SnmpErrorHandlerAgent()
Method Detail

init

public void init()
          throws IllegalAccessException
Initializes the MIB (with no registration of the MBeans into the MBean server). Does nothing.

Specified by:
init in class SnmpMibAgent
Throws:
IllegalAccessException - The MIB cannot be initialized.

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Initializes the MIB but each single MBean representing the MIB is inserted into the MBean server.

Specified by:
preRegister in interface MBeanRegistration
Specified by:
preRegister in class SnmpMibAgent
Parameters:
server - The MBean server to register the service with.
name - The object name.
Returns:
The passed name parameter.
Throws:
Exception

getRootOid

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

The root object identifier is the object identifier uniquely identifying the MIB.

Specified by:
getRootOid in class SnmpMibAgent
Returns:
The returned oid is null.

get

public void get(SnmpMibRequest inRequest)
         throws SnmpStatusException
Processes a get operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests.

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

check

public void check(SnmpMibRequest inRequest)
           throws SnmpStatusException
Checks if a set operation can be performed. If the operation can not be performed, the method should emit a SnmpStatusException.

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

set

public void set(SnmpMibRequest inRequest)
         throws SnmpStatusException
Processes a set operation. Should never be called (check previously called having failed).

Specified by:
set in interface SnmpMibAgentMBean
Overrides:
set in class SnmpMibAgent
Parameters:
inRequest - The SnmpMibRequest object holding the list of variable to be set.
Throws:
SnmpStatusException - An error occurred during the operation.
See Also:
SnmpMibAgent.set(SnmpMibRequest)

getNext

public void getNext(SnmpMibRequest inRequest)
             throws SnmpStatusException
Processes a getNext operation. It will throw an exception for V1 requests or it will set exceptions within the list for V2 requests..

Specified by:
getNext in interface SnmpMibAgentMBean
Overrides:
getNext in class SnmpMibAgent
Parameters:
inRequest - The SnmpMibRequest object holding the list of variables to be retrieved.
Throws:
SnmpStatusException - An error occurred during the operation.
See Also:
SnmpMibAgent.getNext(SnmpMibRequest)

getBulk

public void getBulk(SnmpMibRequest inRequest,
                    int nonRepeat,
                    int maxRepeat)
             throws SnmpStatusException
Processes a getBulk operation. It will throw an exception if the request is a V1 one or it will set exceptions within the list for V2 ones.

Specified by:
getBulk in interface SnmpMibAgentMBean
Overrides:
getBulk in class SnmpMibAgent
Parameters:
inRequest - The SnmpMibRequest object holding the list of variable to be retrieved.
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)

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.