public interface MOServer
Modifier and Type | Method and Description |
---|---|
void |
addContext(org.snmp4j.smi.OctetString context)
Adds the supplied context to the server.
|
void |
addContextListener(ContextListener listener)
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.
|
org.snmp4j.smi.OctetString[] |
getContexts()
Returns the contexts known by the server.
|
org.snmp4j.smi.OctetString[] |
getRegisteredContexts(ManagedObject managedObject)
Returns the contexts for which the supplied
ManagedObject has been
registered. |
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.
|
void |
removeContext(org.snmp4j.smi.OctetString context)
Removes a context from the server.
|
void |
removeContextListener(ContextListener listener)
Removes a previously added context listener.
|
boolean |
removeLookupListener(MOServerLookupListener listener,
ManagedObject mo)
Removes a managed object lookup listener for the specified managed object.
|
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.
|
void addContextListener(ContextListener listener)
listener
- a ContextListener
instance to be informed about context
changes.void removeContextListener(ContextListener listener)
listener
- a ContextListener
instance.void addContext(org.snmp4j.smi.OctetString context)
context
- an OctetString
representing the context name to add.void removeContext(org.snmp4j.smi.OctetString context)
context
- n OctetString
representing the context name to remove.void register(ManagedObject mo, org.snmp4j.smi.OctetString context) throws DuplicateRegistrationException
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.ManagedObject unregister(ManagedObject mo, org.snmp4j.smi.OctetString context)
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.void addLookupListener(MOServerLookupListener listener, ManagedObject mo)
MOServerLookupListener
is called
before the managed object is returned by lookup(MOQuery query)
.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.boolean removeLookupListener(MOServerLookupListener listener, ManagedObject mo)
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.ManagedObject lookup(MOQuery query)
MOLockStrategy
.query
- a MOQuery
instance.ManagedObject
that matches the query and
null
if no such object exists.ManagedObject lookup(MOQuery query, LockRequest lockRequest)
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.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.ManagedObject
that matches the query and
null
if no such object exists.Iterator<Map.Entry<MOScope,ManagedObject>> iterator()
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
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.boolean lock(Object owner, ManagedObject managedObject)
owner
- an Object.managedObject
- the ManagedObject to lock.true
if the lock could be acquired, false
otherwise, i.e. if an InterruptedException has occurred.boolean lock(Object owner, ManagedObject managedObject, long timeoutMillis)
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.boolean unlock(Object owner, ManagedObject managedObject)
Note: In debug log mode a message is locked if the lock owner does not match the current lock owner.
owner
- an Object.managedObject
- the ManagedObject to unlock. If managedObject
is null
then this call has no effect.true
if the lock has been found and released successfully,
false
otherwise.org.snmp4j.smi.OctetString[] getContexts()
boolean isContextSupported(org.snmp4j.smi.OctetString context)
context
- a context name.true
if the context is support (thus has previously added
by addContext(org.snmp4j.smi.OctetString)
) and false
otherwise.org.snmp4j.smi.OctetString[] getRegisteredContexts(ManagedObject managedObject)
ManagedObject
has been
registered.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.Copyright © 2019 SNMP4J.org. All rights reserved.