com.sun.management.snmp.agent
Class SnmpGenericObjectServer

java.lang.Object
  extended by com.sun.management.snmp.agent.SnmpGenericObjectServer

public class SnmpGenericObjectServer
extends Object

This class is a utility class that transforms SNMP GET / SET requests into standard JMX getAttributes() setAttributes() requests.

The transformation relies on the metadata information provided by the SnmpGenericMetaServer object which is passed as the first parameter to every method. This SnmpGenericMetaServer object is usually a Metadata object generated by mibgen.

This class is used internally by mibgen generated metadata objects and you should never need to use it directly.

Since:
Java DMK 5.1

Field Summary
protected  MBeanServer server
          The MBean server through which the MBeans will be accessed.
 
Constructor Summary
SnmpGenericObjectServer(MBeanServer server)
          Builds a new SnmpGenericObjectServer.
 
Method Summary
 void check(SnmpGenericMetaServer meta, ObjectName name, SnmpMibSubRequest req, int depth)
          Checks whether an SNMP SET request can be successfully performed.
 void check(SnmpGenericMetaServer meta, ObjectName name, SnmpValue x, long id, Object data)
          Checks whether a SET operation can be performed on a given SNMP variable.
 SnmpValue get(SnmpGenericMetaServer meta, ObjectName name, long id, Object data)
          Get the value of an SNMP variable.
 void get(SnmpGenericMetaServer meta, ObjectName name, SnmpMibSubRequest req, int depth)
          Execute an SNMP GET request.
 void registerTableEntry(SnmpMibTable meta, SnmpOid rowOid, ObjectName objname, Object entry)
           
 void set(SnmpGenericMetaServer meta, ObjectName name, SnmpMibSubRequest req, int depth)
          Execute an SNMP SET request.
 SnmpValue set(SnmpGenericMetaServer meta, ObjectName name, SnmpValue x, long id, Object data)
          Set the value of an SNMP variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected final MBeanServer server
The MBean server through which the MBeans will be accessed.

Constructor Detail

SnmpGenericObjectServer

public SnmpGenericObjectServer(MBeanServer server)
Builds a new SnmpGenericObjectServer. Usually there will be a single object of this type per MIB.

Parameters:
server - The MBeanServer in which the MBean accessed by this MIB are registered.
Method Detail

get

public void get(SnmpGenericMetaServer meta,
                ObjectName name,
                SnmpMibSubRequest req,
                int depth)
         throws SnmpStatusException
Execute an SNMP GET request.

This method first builds the list of attributes that need to be retrieved from the MBean and then calls getAttributes() on the MBean server. Then it updates the SnmpMibSubRequest with the values retrieved from the MBean.

The SNMP metadata information is obtained through the given meta object, which usually is an instance of a mibgen generated class.

This method is called internally by mibgen generated objects and you should never need to call it directly.

Parameters:
meta - The metadata object impacted by the subrequest
name - The ObjectName of the MBean impacted by this subrequest
req - The SNMP subrequest to execute on the MBean
depth - The depth of the SNMP object in the OID tree.
Throws:
SnmpStatusException - whenever an SNMP exception must be raised. Raising an exception will abort the request.
Exceptions should never be raised directly, but only by means of req.registerGetException(VariableId,SnmpStatusException)

get

public SnmpValue get(SnmpGenericMetaServer meta,
                     ObjectName name,
                     long id,
                     Object data)
              throws SnmpStatusException
Get the value of an SNMP variable.

You should never need to use this method directly.

Parameters:
meta - The impacted metadata object
name - The ObjectName of the impacted MBean
id - The OID arc identifying the variable we're trying to set.
data - User contextual data allocated through the SnmpUserDataFactory
Returns:
The value of the variable.
Throws:
SnmpStatusException - whenever an SNMP exception must be raised. Raising an exception will abort the request.
Exceptions should never be raised directly, but only by means of req.registerGetException(VariableId,SnmpStatusException)

set

public void set(SnmpGenericMetaServer meta,
                ObjectName name,
                SnmpMibSubRequest req,
                int depth)
         throws SnmpStatusException
Execute an SNMP SET request.

This method first builds the list of attributes that need to be set on the MBean and then calls setAttributes() on the MBean server. Then it updates the SnmpMibSubRequest with the new values retrieved from the MBean.

The SNMP metadata information is obtained through the given meta object, which usually is an instance of a mibgen generated class.

This method is called internally by mibgen generated objects and you should never need to call it directly.

Parameters:
meta - The metadata object impacted by the subrequest
name - The ObjectName of the MBean impacted by this subrequest
req - The SNMP subrequest to execute on the MBean
depth - The depth of the SNMP object in the OID tree.
Throws:
SnmpStatusException - whenever an SNMP exception must be raised. Raising an exception will abort the request.
Exceptions should never be raised directly, but only by means of req.registerGetException(VariableId,SnmpStatusException)

set

public SnmpValue set(SnmpGenericMetaServer meta,
                     ObjectName name,
                     SnmpValue x,
                     long id,
                     Object data)
              throws SnmpStatusException
Set the value of an SNMP variable.

You should never need to use this method directly.

Parameters:
meta - The impacted metadata object
name - The ObjectName of the impacted MBean
x - The new requested SnmpValue
id - The OID arc identifying the variable we're trying to set.
data - User contextual data allocated through the SnmpUserDataFactory
Returns:
The new value of the variable after the operation.
Throws:
SnmpStatusException - whenever an SNMP exception must be raised. Raising an exception will abort the request.
Exceptions should never be raised directly, but only by means of req.registerSetException(VariableId,SnmpStatusException)

check

public void check(SnmpGenericMetaServer meta,
                  ObjectName name,
                  SnmpMibSubRequest req,
                  int depth)
           throws SnmpStatusException
Checks whether an SNMP SET request can be successfully performed.

For each variable in the subrequest, this method calls checkSetAccess() on the meta object, and then tries to invoke the checkAttributeName() method on the MBean. If this method is not defined then it is assumed that the SET won't fail.

This method is called internally by mibgen generated objects and you should never need to call it directly.

Parameters:
meta - The metadata object impacted by the subrequest
name - The ObjectName of the MBean impacted by this subrequest
req - The SNMP subrequest to execute on the MBean
depth - The depth of the SNMP object in the OID tree.
Throws:
SnmpStatusException - if the requested SET operation must be rejected. Raising an exception will abort the request.
Exceptions should never be raised directly, but only by means of req.registerCheckException(VariableId,SnmpStatusException)

check

public void check(SnmpGenericMetaServer meta,
                  ObjectName name,
                  SnmpValue x,
                  long id,
                  Object data)
           throws SnmpStatusException
Checks whether a SET operation can be performed on a given SNMP variable.

Parameters:
meta - The impacted metadata object
name - The ObjectName of the impacted MBean
x - The new requested SnmpValue
id - The OID arc identifying the variable we're trying to set.
data - User contextual data allocated through the SnmpUserDataFactory

This method calls checkSetAccess() on the meta object, and then tries to invoke the checkAttributeName() method on the MBean. If this method is not defined then it is assumed that the SET won't fail.

This method is called internally by mibgen generated objects and you should never need to call it directly.

Throws:
SnmpStatusException - if the requested SET operation must be rejected. Raising an exception will abort the request.
Exceptions should never be raised directly, but only by means of req.registerCheckException(VariableId,SnmpStatusException)

registerTableEntry

public void registerTableEntry(SnmpMibTable meta,
                               SnmpOid rowOid,
                               ObjectName objname,
                               Object entry)
                        throws SnmpStatusException
Throws:
SnmpStatusException

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.