java.lang.Object
org.snmp4j.agent.mo.ext.StaticMOGroup
- All Implemented Interfaces:
ManagedObject<SubRequest<?>>
,GenericManagedObject
,MOGroup
The
StaticMOGroup
can be used to easily implement static
(read-only) managed objects.
Note: Dynamic variables (see Variable.isDynamic()
) cannot be used to
with StaticMOGroup
because default VariableBinding
's Variable
s 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 of
VariableBinding
needs to be used that overwrites its
VariableBinding.setVariable(org.snmp4j.smi.Variable)
method.
StaticMOGroup
is read-only by default. To implement read-write objects
a subclass is needed that overwrites prepare(SubRequest)
, commit(SubRequest)
,
undo(SubRequest)
, and cleanup(SubRequest)
.- Since:
- 1.2
- Version:
- 3.2
- Author:
- Frank Fock
-
Constructor Summary
ConstructorDescriptionStaticMOGroup
(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
Modifier and TypeMethodDescriptionvoid
cleanup
(SubRequest<?> request) Cleanup a (sub)request and free all resources locked during the preparation phase.void
commit
(SubRequest<?> request) Sets the error status of the request toPDU.commitFailed
.org.snmp4j.smi.OID
Find the first object ID (OID) in the specified search range.void
get
(SubRequest<?> request) Process a GET request and return the result in the supplied sub-request.getScope()
Return the scope of object identifiers this managed object is managing.boolean
next
(SubRequest<?> request) Find the successor instance for the object instance ID (OID) given by the supplied sub-request and returns it within the supplied sub-request object.void
prepare
(SubRequest<?> request) Sets the error status of the request toPDU.notWritable
.void
registerMOs
(MOServer server, org.snmp4j.smi.OctetString context) Registers the managed objects of this group with the server for the supplied context.toString()
void
undo
(SubRequest<?> request) Sets the error status of the request toPDU.undoFailed
.void
unregisterMOs
(MOServer server, org.snmp4j.smi.OctetString context) Unregisters the managed objects of this group from the supplied server and from the supplied context.
-
Constructor Details
-
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 Details
-
registerMOs
public void registerMOs(MOServer server, org.snmp4j.smi.OctetString context) throws DuplicateRegistrationException Description copied from interface:MOGroup
Registers the managed objects of this group with the server for the supplied context.- Specified by:
registerMOs
in interfaceMOGroup
- Parameters:
server
- theMOServer
where to register the managed objects.context
- the context to use (may benull
if no specific context is selected).- Throws:
DuplicateRegistrationException
- if a managed object's scope (i.e. lower bound) is already registered at the server.
-
unregisterMOs
Description copied from interface:MOGroup
Unregisters the managed objects of this group from the supplied server and from the supplied context.- Specified by:
unregisterMOs
in interfaceMOGroup
- Parameters:
server
- theMOServer
where to unregister the managed objects.context
- the context to use (may benull
if no specific context is selected).
-
getScope
Description copied from interface:ManagedObject
Return the scope of object identifiers this managed object is managing.- Specified by:
getScope
in interfaceManagedObject<SubRequest<?>>
- Returns:
- the
MOScope
that defines a range (possibly also a single or none instance OID) of object IDs managed by this managed object.
-
find
Description copied from interface:ManagedObject
Find the first object ID (OID) in the specified search range.- Specified by:
find
in interfaceManagedObject<SubRequest<?>>
- Parameters:
range
- theMOScope
for the search.- Returns:
- the
OID
that is included in the searchrange
andnull
if no such instances could be found.
-
get
Description copied from interface:ManagedObject
Process a GET request and return the result in the supplied sub-request.- Specified by:
get
in interfaceManagedObject<SubRequest<?>>
- Parameters:
request
- theSubRequest
to process.
-
next
Description copied from interface:ManagedObject
Find 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:
next
in interfaceManagedObject<SubRequest<?>>
- Parameters:
request
- theSubRequest
to process.- Returns:
true
if the search request found an appropriate instance,false
otherwise.
-
prepare
Sets the error status of the request toPDU.notWritable
.- Specified by:
prepare
in interfaceManagedObject<SubRequest<?>>
- Parameters:
request
- a request to process prepare SET request for.
-
commit
Sets the error status of the request toPDU.commitFailed
.- Specified by:
commit
in interfaceManagedObject<SubRequest<?>>
- Parameters:
request
- a request to process commit SET request for.
-
undo
Sets the error status of the request toPDU.undoFailed
.- Specified by:
undo
in interfaceManagedObject<SubRequest<?>>
- Parameters:
request
- a request to process undo SET request for.
-
cleanup
Description copied from interface:ManagedObject
Cleanup a (sub)request and free all resources locked during the preparation phase.- Specified by:
cleanup
in interfaceManagedObject<SubRequest<?>>
- Parameters:
request
- theSubRequest
to process.
-
toString
-