- java.lang.Object
-
- org.snmp4j.agent.mo.ext.StaticMOGroup
-
- All Implemented Interfaces:
ManagedObject<SubRequest<?>>,GenericManagedObject,MOGroup
public class StaticMOGroup extends Object implements GenericManagedObject, MOGroup
TheStaticMOGroupcan be used to easily implement static (read-only) managed objects.Note: Dynamic variables (see
Variable.isDynamic()) cannot be used to when using defaultVariableBindings sinceVariables are cloned when added to them. In order to use dynamic objects (i.e., objects that may change their value when being accessed), a sub-class ofVariableBindingneeds to be used that overwrites itsVariableBinding.setVariable(org.snmp4j.smi.Variable)method.- Since:
- 1.2
- Version:
- 3.2
- Author:
- Frank Fock
-
-
Constructor Summary
Constructors Constructor Description StaticMOGroup(org.snmp4j.smi.OID root, org.snmp4j.smi.VariableBinding[] vbs)Creates a static managed object group for the sub-tree with the specified root OID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanup(SubRequest<?> request)Cleansup a (sub)request and frees all resources locked during the preparation phase.voidcommit(SubRequest<?> request)Sets the error status of the request toPDU.commitFailed.org.snmp4j.smi.OIDfind(MOScope range)Finds the first object ID (OID) in the specified search range.voidget(SubRequest<?> request)Processes a GET request and return the result in the supplied sub-request.MOScopegetScope()Returns the scope of object identifiers this managed object is managing.booleannext(SubRequest<?> request)Finds the successor instance for the object instance ID (OID) given by the supplied sub-request and returns it within the supplied sub-request object.voidprepare(SubRequest<?> request)Sets the error status of the request toPDU.notWritable.voidregisterMOs(MOServer server, org.snmp4j.smi.OctetString context)Registers the managed objects of this group with the server for the supplied context.StringtoString()voidundo(SubRequest<?> request)Sets the error status of the request toPDU.undoFailed.voidunregisterMOs(MOServer server, org.snmp4j.smi.OctetString context)Unregisters the managed objects of this group from the supplied server and from the supplied context.
-
-
-
Constructor Detail
-
StaticMOGroup
public StaticMOGroup(org.snmp4j.smi.OID root, org.snmp4j.smi.VariableBinding[] vbs)Creates a static managed object group for the sub-tree with the specified root OID.- Parameters:
root- the root OID of the sub-tree to be registered by this managed object.vbs- the variable bindings to be returned in this sub-tree.
-
-
Method Detail
-
registerMOs
public void registerMOs(MOServer server, org.snmp4j.smi.OctetString context) throws DuplicateRegistrationException
Description copied from interface:MOGroupRegisters the managed objects of this group with the server for the supplied context.- Specified by:
registerMOsin interfaceMOGroup- Parameters:
server- theMOServerwhere to register the managed objects.context- the context to use (may benullif no specific context is selected).- Throws:
DuplicateRegistrationException- if a managed object's scope (i.e. lower bound) is already registered at the server.
-
unregisterMOs
public void unregisterMOs(MOServer server, org.snmp4j.smi.OctetString context)
Description copied from interface:MOGroupUnregisters the managed objects of this group from the supplied server and from the supplied context.- Specified by:
unregisterMOsin interfaceMOGroup- Parameters:
server- theMOServerwhere to unregister the managed objects.context- the context to use (may benullif no specific context is selected).
-
getScope
public MOScope getScope()
Description copied from interface:ManagedObjectReturns the scope of object identifiers this managed object is managing.- Specified by:
getScopein interfaceManagedObject<SubRequest<?>>- Returns:
- the
MOScopethat defines a range (possibly also a single or none instance OID) of object IDs managed by this managed object.
-
find
public org.snmp4j.smi.OID find(MOScope range)
Description copied from interface:ManagedObjectFinds the first object ID (OID) in the specified search range.- Specified by:
findin interfaceManagedObject<SubRequest<?>>- Parameters:
range- theMOScopefor the search.- Returns:
- the
OIDthat is included in the searchrangeandnullif no such instances could be found.
-
get
public void get(SubRequest<?> request)
Description copied from interface:ManagedObjectProcesses a GET request and return the result in the supplied sub-request.- Specified by:
getin interfaceManagedObject<SubRequest<?>>- Parameters:
request- theSubRequestto process.
-
next
public boolean next(SubRequest<?> request)
Description copied from interface:ManagedObjectFinds the successor instance for the object instance ID (OID) given by the supplied sub-request and returns it within the supplied sub-request object.- Specified by:
nextin interfaceManagedObject<SubRequest<?>>- Parameters:
request- theSubRequestto process.- Returns:
trueif the search request found an appropriate instance,falseotherwise.
-
prepare
public void prepare(SubRequest<?> request)
Sets the error status of the request toPDU.notWritable.- Specified by:
preparein interfaceManagedObject<SubRequest<?>>- Parameters:
request- a request to process prepare SET request for.
-
commit
public void commit(SubRequest<?> request)
Sets the error status of the request toPDU.commitFailed.- Specified by:
commitin interfaceManagedObject<SubRequest<?>>- Parameters:
request- a request to process commit SET request for.
-
undo
public void undo(SubRequest<?> request)
Sets the error status of the request toPDU.undoFailed.- Specified by:
undoin interfaceManagedObject<SubRequest<?>>- Parameters:
request- a request to process undo SET request for.
-
cleanup
public void cleanup(SubRequest<?> request)
Description copied from interface:ManagedObjectCleansup a (sub)request and frees all resources locked during the preparation phase.- Specified by:
cleanupin interfaceManagedObject<SubRequest<?>>- Parameters:
request- theSubRequestto process.
-
-