| Constructor and Description |
|---|
DefaultMOServer() |
| Modifier and Type | Method and Description |
|---|---|
void |
addContext(org.snmp4j.smi.OctetString context)
Adds the supplied context to the server.
|
void |
addContextListener(ContextListener l)
Adds a context listener to the server.
|
void |
addLookupListener(MOServerLookupListener listener,
ManagedObject mo)
Adds a managed object lookup listener for the supplied managed object to
this managed object server.
|
protected void |
checkForUpdate(UpdatableManagedObject mo,
MOQuery query)
Checks
updateStrategy whether the queried managed object needs
to be updated. |
protected void |
fireContextChanged(ContextEvent event) |
protected void |
fireLookupEvent(ManagedObject mo,
MOQuery query) |
protected void |
fireQueryEvent(ManagedObject mo,
MOQuery query) |
org.snmp4j.smi.OctetString[] |
getContexts()
Returns the contexts known by the server.
|
MOLockStrategy |
getLockStrategy()
Return the locking strategy for this server.
|
ManagedObject |
getManagedObject(org.snmp4j.smi.OID key,
org.snmp4j.smi.OctetString context)
Returns the
ManagedObject with the specified OID
as ID returned by RegisteredManagedObject.getID() or the lower bound
(regardless whether the ManagedObject's scope includes it or not)
when registered in the supplied context. |
ManagedObject |
getManagedObject(org.snmp4j.smi.OID key,
org.snmp4j.smi.OctetString context,
boolean fireLookupEvents)
Returns the
ManagedObject with the specified OID
as ID returned by RegisteredManagedObject.getID() or the lower bound
(regardless whether the ManagedObject's scope includes it or not)
when registered in the supplied context. |
org.snmp4j.smi.OctetString[] |
getRegisteredContexts(ManagedObject managedObject)
Returns the contexts for which the supplied
ManagedObject has been
registered. |
SortedMap<MOScope,ManagedObject> |
getRegistry() |
UpdateStrategy |
getUpdateStrategy()
Gets the update strategy for
UpdatableManagedObjects. |
static org.snmp4j.smi.Variable |
getValue(MOServer server,
org.snmp4j.smi.OctetString context,
org.snmp4j.smi.OID key)
Returns the value of a particular MIB object instance using the
ManagedObjectValueAccess interface. |
boolean |
isContextSupported(org.snmp4j.smi.OctetString context)
Checks whether the supplied context is supported (registered) by this
server.
|
Iterator<Map.Entry<MOScope,ManagedObject>> |
iterator()
Return a read-only
Iterator over the content of this server. |
boolean |
lock(Object owner,
ManagedObject managedObject)
Locks a ManagedObject by the supplied owner.
|
boolean |
lock(Object owner,
ManagedObject managedObject,
long timeoutMillis)
Locks a ManagedObject by the supplied owner.
|
ManagedObject |
lookup(MOQuery query)
Lookup the first (lexicographically ordered) managed object that matches
the supplied query.
|
ManagedObject |
lookup(MOQuery query,
LockRequest lockRequest)
Lookup the first (lexicographically ordered) managed object that matches
the supplied query.
|
void |
register(ManagedObject mo,
org.snmp4j.smi.OctetString context)
Registers a managed object for the specified context.
|
static <R extends MOTableRow,T extends MOTable<R,? extends MOColumn,? extends MOTableModel<R>>> |
registerTableRowListener(MOServer server,
MOTableRowListener<R> listener)
Register a single
MOTableRowListener with all tables in the
specified MOServer. |
void |
removeContext(org.snmp4j.smi.OctetString context)
Removes a context from the server.
|
void |
removeContextListener(ContextListener l)
Removes a previously added context listener.
|
boolean |
removeLookupListener(MOServerLookupListener listener,
ManagedObject mo)
Removes a managed object lookup listener for the specified managed object.
|
void |
setLockStrategy(MOLockStrategy lockStrategy)
Sets the lock strategy for this server.
|
void |
setUpdateStrategy(UpdateStrategy updateStrategy)
Sets the update strategy for
UpdatableManagedObjects. |
static boolean |
setValue(MOServer server,
org.snmp4j.smi.OctetString context,
org.snmp4j.smi.VariableBinding newValueAndKey)
Sets the value of a particular MIB object instance using the
ManagedObjectValueAccess interface. |
String |
toString() |
boolean |
unlock(Object owner,
ManagedObject managedObject)
Unlocks a ManagedObject that has been locked by the specified owner.
|
ManagedObject |
unregister(ManagedObject mo,
org.snmp4j.smi.OctetString context)
Removes the registration of the supplied managed object for the specified
context.
|
static <R extends MOTableRow,T extends MOTable<R,? extends MOColumn,? extends MOTableModel<R>>> |
unregisterTableRowListener(MOServer server,
MOTableRowListener<R> listener)
Unregister a single
MOTableRowListener with all tables in the
specified MOServer. |
public ManagedObject lookup(MOQuery query)
MOServerMOLockStrategy.public ManagedObject lookup(MOQuery query, LockRequest lockRequest)
MOServerMOLockStrategy before the lookup
listener is fired.
CAUTION: To make sure that the acquired lock is released after the
using of the managed object has been finished, the MOServer.unlock(Object, ManagedObject)
method must be called then.lookup in interface MOServerquery - a MOQuery instance.lockRequest - the LockRequest that holds the lock owner and the timeout for
acquiring a lock and returns whether a lock has been acquired or not
on behalf of this lookup operation.ManagedObject that matches the query and
null if no such object exists.public MOLockStrategy getLockStrategy()
ManagedObject is returned (and before the corresponding lookup event is being fired) or not.null, no locking is performed
at all (which is only recommended for static content servers).public void setLockStrategy(MOLockStrategy lockStrategy)
ManagedObject is returned (and before the corresponding lookup event is being fired) or not.
By default, only write access needs a lock.lockStrategy - a MOLockStrategy instance or null to suppress any locking.protected void checkForUpdate(UpdatableManagedObject mo, MOQuery query)
updateStrategy whether the queried managed object needs
to be updated. This method is called on behalf of
lookup(MOQuery query) after fireQueryEvent(org.snmp4j.agent.ManagedObject, org.snmp4j.agent.MOQuery) and before
fireLookupEvent(org.snmp4j.agent.ManagedObject, org.snmp4j.agent.MOQuery) is being called.mo - an UpdatableManagedObject instance.query - the query that is interested in content of mo.public ManagedObject getManagedObject(org.snmp4j.smi.OID key, org.snmp4j.smi.OctetString context, boolean fireLookupEvents)
ManagedObject with the specified OID
as ID returned by RegisteredManagedObject.getID() or the lower bound
(regardless whether the ManagedObject's scope includes it or not)
when registered in the supplied context.
Note: The query used to lookup the managed object will indicate an intended
read-only access for the MOServerLookupEvents fired on behalf of
this method.
key - the OID identifying the key (lower bound) of the
ManagedObject.context - the optional context to look in. A null value searches
in all contexts.fireLookupEvents - if true lookup and query events will be fired as if the managed
objects has been looked up by lookup(MOQuery). In addition, if
the looked up managed object is an UpdatableManagedObject it will be locked
if the lock strategy of this server requires it. The lock is active until the look up
events have been fired completely. The lock operation waits without timeout for the lock
to become available.
Otherwise, no events will be fired at all.ManagedObject instance or null if such
an instance does not exists.public ManagedObject getManagedObject(org.snmp4j.smi.OID key, org.snmp4j.smi.OctetString context)
ManagedObject with the specified OID
as ID returned by RegisteredManagedObject.getID() or the lower bound
(regardless whether the ManagedObject's scope includes it or not)
when registered in the supplied context.
Note: The query used to lookup the managed object will indicate an intended
read-only access for the MOServerLookupEvents fired on behalf of
this method.key - the OID identifying the key (lower bound) of the
ManagedObject.context - the optional context to look in. A null value searches
in all contexts.ManagedObject instance or null if such
an instance does not exists.public static org.snmp4j.smi.Variable getValue(MOServer server, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID key)
ManagedObjectValueAccess interface. If a ManagedObject
does not support this interface, its value cannot be returned and
null will be returned instead.
Note: This method does not perform any locking based on the MOLockStrategy.server - the MOServer where to lookup the value.context - the optional context to look in. A null value searches
in all contexts.key - the OID identifying the variable instance to return.Variable associated with OID and
context in server or null if
no such variable exists.public static boolean setValue(MOServer server, org.snmp4j.smi.OctetString context, org.snmp4j.smi.VariableBinding newValueAndKey)
ManagedObjectValueAccess interface. If a ManagedObject
does not support this interface, its value cannot be set and
false will be returned.
Note: This method does not perform any locking based on the MOLockStrategy.server - the MOServer where to lookup the value.context - the optional context to look in. A null value searches
in all contexts.newValueAndKey - the OID identifying the variable instance to set and its new value.true if the value has been set successfully,
false otherwise.protected void fireLookupEvent(ManagedObject mo, MOQuery query)
protected void fireQueryEvent(ManagedObject mo, MOQuery query)
public org.snmp4j.smi.OctetString[] getContexts()
MOServergetContexts in interface MOServerpublic boolean isContextSupported(org.snmp4j.smi.OctetString context)
MOServerisContextSupported in interface MOServercontext - a context name.true if the context is support (thus has previously added
by MOServer.addContext(org.snmp4j.smi.OctetString)) and false otherwise.public SortedMap<MOScope,ManagedObject> getRegistry()
public UpdateStrategy getUpdateStrategy()
UpdatableManagedObjects. If the
strategy is null no updates will be performed on behalf
of calls to lookup(org.snmp4j.agent.MOQuery).null if no
strategy is active.lookup(org.snmp4j.agent.MOQuery)public void setUpdateStrategy(UpdateStrategy updateStrategy)
UpdatableManagedObjects. If the
strategy is null no updates will be performed on behalf
of calls to lookup(MOQuery).updateStrategy - the new UpdateStrategy instance or null if no
updates should be performed.lookup(MOQuery)public void register(ManagedObject mo, org.snmp4j.smi.OctetString context) throws DuplicateRegistrationException
MOServerregister in interface MOServermo - a ManagedObject instance.context - the context name for which to register the mo or
null if the managed oject is to be registered for all
contexts (including the default context).DuplicateRegistrationException - if the registration conflicts (i.e. overlaps) with an already existing
registration.public ManagedObject unregister(ManagedObject mo, org.snmp4j.smi.OctetString context)
MOServerunregister in interface MOServermo - a ManagedObject instance.context - the context name for which to unregister the mo or
null if the managed object is to be unregistered for all
contexts (including the default context). In the latter case however,
explicit registrations for a particular context will not be removed!ManagedObjectinstance or null if
the removal failed.public void addContext(org.snmp4j.smi.OctetString context)
MOServeraddContext in interface MOServercontext - an OctetString representing the context name to add.public void removeContext(org.snmp4j.smi.OctetString context)
MOServerremoveContext in interface MOServercontext - n OctetString representing the context name to remove.public boolean lock(Object owner, ManagedObject managedObject)
MOServerpublic boolean lock(Object owner, ManagedObject managedObject, long timeoutMillis)
MOServerlock in interface MOServerowner - an Object.managedObject - the ManagedObject to lock.timeoutMillis - the number of 1/1000 seconds to wait for the lock. 0 or less disables
the timeout and waits forever until the lock is released by the current owner.true if the lock could be acquired, false
otherwise, i.e. if an InterruptedException or timeout has occurred.public boolean unlock(Object owner, ManagedObject managedObject)
MOServerNote: In debug log mode a message is locked if the lock owner does not match the current lock owner.
public Iterator<Map.Entry<MOScope,ManagedObject>> iterator()
MOServerIterator over the content of this server.
The iterator is thread safe and can be used while the server is being
modified. The remove operation of the iterator is not supported.iterator in interface MOServerIterator on the Map.Entry instances managed by
this server. Each Entry consists of an MOScope
key instance and a corresponding ManagedObject value instance.
If the ManagedObject has been registered for a specific
context, then a MOContextScope is returned as key, otherwise
the managed objects own MOScope is returned.public void addLookupListener(MOServerLookupListener listener, ManagedObject mo)
MOServerMOServerLookupListener is called
before the managed object is returned by MOServer.lookup(MOQuery query).addLookupListener in interface MOServerlistener - a MOServerLookupListener instance, for example a managed
object that needs to update its state whenever it has been looked upmo - the ManagedObject that triggers the
MOServerLookupEvent to be fired when it has been looked up.public boolean removeLookupListener(MOServerLookupListener listener, ManagedObject mo)
MOServerremoveLookupListener in interface MOServerlistener - a MOServerLookupListener instance.mo - the ManagedObject that triggered the
MOServerLookupEvent to be fired when it has been looked up.true if the listener could be removed or false
if such a listener is not registered.public void addContextListener(ContextListener l)
MOServeraddContextListener in interface MOServerl - a ContextListener instance to be informed about context
changes.public void removeContextListener(ContextListener l)
MOServerremoveContextListener in interface MOServerl - a ContextListener instance.protected void fireContextChanged(ContextEvent event)
public org.snmp4j.smi.OctetString[] getRegisteredContexts(ManagedObject managedObject)
MOServerManagedObject has been
registered.getRegisteredContexts in interface MOServermanagedObject - a ManagedObject instance.managedObject has
been registered. If the managedObject has been registered
for all contexts, a null element is included in the array.public static <R extends MOTableRow,T extends MOTable<R,? extends MOColumn,? extends MOTableModel<R>>> void registerTableRowListener(MOServer server, MOTableRowListener<R> listener)
MOTableRowListener with all tables in the
specified MOServer. This overall registration can be used,
for example, to apply table size limits to all tables in an agent.
See MOTableSizeLimit for details.
Note: The server must not change its registration content while this
method is being called, otherwise a
ConcurrentModificationException might be thrown.
R - the MOTableRow type supported by the table row listener to register.T - the MOTable type supported by the table row listener to register.server - a MOServer instance.listener - the MOTableRowListener instance to register.public static <R extends MOTableRow,T extends MOTable<R,? extends MOColumn,? extends MOTableModel<R>>> void unregisterTableRowListener(MOServer server, MOTableRowListener<R> listener)
MOTableRowListener with all tables in the
specified MOServer. This overall unregistration can be used,
for example, to remove table size limits from all tables in an agent.
See MOTableSizeLimit for details.
Note: The server must not change its registration content while this
method is being called, otherwise a
ConcurrentModificationException might be thrown.R - the MOTableRow type supported by the table row listener to register.T - the MOTable type supported by the table row listener to register.server - a MOServer instance.listener - the MOTableRowListener instance to unregister.Copyright © 2020 SNMP4J.org. All rights reserved.