Constructor | Description |
---|---|
DefaultMOServer() |
Modifier and Type | Method | 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,
MOServerLookupEvent event) |
|
protected void |
fireQueryEvent(ManagedObject mo,
MOServerLookupEvent event) |
|
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. |
java.util.SortedMap<MOScope,ManagedObject> |
getRegistry() |
|
UpdateStrategy |
getUpdateStrategy() |
Gets the update strategy for
UpdatableManagedObject s. |
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.
|
java.util.Iterator<java.util.Map.Entry<MOScope,ManagedObject>> |
iterator() |
Return a read-only
Iterator over the content of this server. |
boolean |
lock(java.lang.Object owner,
ManagedObject managedObject) |
Locks a ManagedObject by the supplied owner.
|
boolean |
lock(java.lang.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,
MOServerLookupEvent lookupEvent) |
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 void |
registerChangeListener(MOServer server,
MOChangeListener listener,
MOFilter moFilter) |
Register a single
MOChangeListener with all objects matching the given filter in the
specified MOServer . |
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
UpdatableManagedObject s. |
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. |
java.lang.String |
toString() |
|
boolean |
unlock(java.lang.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 void |
unregisterChangeListener(MOServer server,
MOChangeListener listener,
MOFilter moFilter) |
Unregister a single
MOChangeListener from all objects matching the given filter in the
specified MOServer . |
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)
MOServer
MOLockStrategy
.public ManagedObject lookup(MOQuery query, LockRequest lockRequest, MOServerLookupEvent lookupEvent)
MOLockStrategy
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 unlock(Object, ManagedObject)
method must be called then.lookup
in interface MOServer
query
- 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.lookupEvent
- provides additional information about the intended use and optionally a callback to be informed about
the completion of the use, including a reference to its result.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.MOServerLookupEvent)
and before
fireLookupEvent(org.snmp4j.agent.ManagedObject, org.snmp4j.agent.MOServerLookupEvent)
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 MOServerLookupEvent
s 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 MOServerLookupEvent
s 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, MOServerLookupEvent event)
protected void fireQueryEvent(ManagedObject mo, MOServerLookupEvent event)
public org.snmp4j.smi.OctetString[] getContexts()
MOServer
getContexts
in interface MOServer
public boolean isContextSupported(org.snmp4j.smi.OctetString context)
MOServer
isContextSupported
in interface MOServer
context
- a context name.true
if the context is support (thus has previously added
by MOServer.addContext(org.snmp4j.smi.OctetString)
) and false
otherwise.public java.util.SortedMap<MOScope,ManagedObject> getRegistry()
public UpdateStrategy getUpdateStrategy()
UpdatableManagedObject
s. 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)
UpdatableManagedObject
s. 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
MOServer
register
in interface MOServer
mo
- 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)
MOServer
unregister
in interface MOServer
mo
- 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!ManagedObject
instance or null
if
the removal failed.public void addContext(org.snmp4j.smi.OctetString context)
MOServer
addContext
in interface MOServer
context
- an OctetString
representing the context name to add.public void removeContext(org.snmp4j.smi.OctetString context)
MOServer
removeContext
in interface MOServer
context
- n OctetString
representing the context name to remove.public boolean lock(java.lang.Object owner, ManagedObject managedObject)
MOServer
public boolean lock(java.lang.Object owner, ManagedObject managedObject, long timeoutMillis)
MOServer
lock
in interface MOServer
owner
- 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(java.lang.Object owner, ManagedObject managedObject)
MOServer
Note: In debug log mode a message is locked if the lock owner does not match the current lock owner.
public java.util.Iterator<java.util.Map.Entry<MOScope,ManagedObject>> iterator()
MOServer
Iterator
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 MOServer
Iterator
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)
MOServer
MOServerLookupListener
is called
before the managed object is returned by MOServer.lookup(MOQuery query)
.addLookupListener
in interface MOServer
listener
- 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)
MOServer
removeLookupListener
in interface MOServer
listener
- 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)
MOServer
addContextListener
in interface MOServer
l
- a ContextListener
instance to be informed about context
changes.public void removeContextListener(ContextListener l)
MOServer
removeContextListener
in interface MOServer
l
- a ContextListener
instance.protected void fireContextChanged(ContextEvent event)
public java.lang.String toString()
toString
in class java.lang.Object
public org.snmp4j.smi.OctetString[] getRegisteredContexts(ManagedObject managedObject)
MOServer
ManagedObject
has been
registered.getRegisteredContexts
in interface MOServer
managedObject
- 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.public static void registerChangeListener(MOServer server, MOChangeListener listener, MOFilter moFilter)
MOChangeListener
with all objects matching the given filter in the
specified MOServer
. This overall registration can be used,
for example, to listen for object changes.
Note: The server must not change its registration content while this
method is being called, otherwise a
ConcurrentModificationException
might be thrown.
server
- a MOServer
instance.listener
- the MOTableRowListener
instance to register.moFilter
- an optional filter to select objects which should register the provided listener.public static void unregisterChangeListener(MOServer server, MOChangeListener listener, MOFilter moFilter)
MOChangeListener
from all objects matching the given filter in the
specified MOServer
.
Note: The server must not change its registration content while this
method is being called, otherwise a
ConcurrentModificationException
might be thrown.
server
- a MOServer
instance.listener
- the MOTableRowListener
instance to unregister.moFilter
- an optional filter to select objects which should no longer register the provided listener.Copyright © 2018 SNMP4J.org. All rights reserved.