|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.snmp4j.agent.DefaultMOServer
public class DefaultMOServer
The default MO server implementation uses a sorted map for the managed object registry.
| Constructor Summary | |
|---|---|
DefaultMOServer()
|
|
| Method Summary | |
|---|---|
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. |
ManagedObject |
getManagedObject(org.snmp4j.smi.OID key,
org.snmp4j.smi.OctetString context)
Returns the ManagedObject with the specified OID
and 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 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. |
java.util.Iterator<java.util.Map.Entry<MOScope,ManagedObject>> |
iterator()
Returns 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)
Lookups 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 |
registerTableRowListener(MOServer server,
MOTableRowListener 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 |
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. |
java.lang.String |
toString()
|
void |
unlock(java.lang.Object owner,
ManagedObject managedObject)
Unlocks a ManagedObject that has been locked by the specified owner. |
void |
unregister(ManagedObject mo,
org.snmp4j.smi.OctetString context)
Removes the registration of the supplied managed object for the specified context. |
static void |
unregisterTableRowListener(MOServer server,
MOTableRowListener listener)
Unregister a single MOTableRowListener with all tables in the
specified MOServer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultMOServer()
| Method Detail |
|---|
public ManagedObject lookup(MOQuery query)
MOServer
lookup in interface MOServerquery - a MOQuery instance.
ManagedObject that matches the query and
null if no such object exists.
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)
ManagedObject with the specified OID
and 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.
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.
associated with OID and
context in server or null if
no such variable exists.- Since:
- 1.4
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.
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.
if the value has been set successfully,
false otherwise.- Since:
- 1.4
protected void fireLookupEvent(ManagedObject mo,
MOQuery query)
protected void fireQueryEvent(ManagedObject mo,
MOQuery query)
public org.snmp4j.smi.OctetString[] getContexts()
MOServer
getContexts in interface MOServerpublic boolean isContextSupported(org.snmp4j.smi.OctetString context)
MOServer
isContextSupported 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 java.util.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
MOServer
register 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 void unregister(ManagedObject mo,
org.snmp4j.smi.OctetString context)
MOServer
unregister in interface MOServermo - a ManagedObject instance.context - the context name for which to unregister the mo or
null if the managed oject 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!public void addContext(org.snmp4j.smi.OctetString context)
MOServer
addContext in interface MOServercontext - an OctetString representing the context name to add.public void removeContext(org.snmp4j.smi.OctetString context)
MOServer
removeContext in interface MOServercontext - n OctetString representing the context name to remove.
public boolean lock(java.lang.Object owner,
ManagedObject managedObject)
MOServer
lock in interface MOServerowner - an Object.managedObject - the ManagedObject to lock.
true if the lock could be acquired, false
otherwise, i.e. if an InterruptedException has occurred.
public boolean lock(java.lang.Object owner,
ManagedObject managedObject,
long timeoutMillis)
MOServer
lock in interface MOServerowner - an Object.managedObject - the ManagedObject to lock.timeoutMillis - the number of 1/1000 seconds to wait for the lock.
true if the lock could be acquired, false
otherwise, i.e. if an InterruptedException or timeout has occurred.
public void unlock(java.lang.Object owner,
ManagedObject managedObject)
MOServerNote: In debug log mode a message is locked if the lock owner does not match the current lock owner.
unlock in interface MOServerowner - an Object.managedObject - the ManagedObject to unlock.public java.util.Iterator<java.util.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)
MOServer
removeLookupListener 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)
MOServer
addContextListener in interface MOServerl - a ContextListener instance to be informed about context
changes.public void removeContextListener(ContextListener l)
MOServer
removeContextListener in interface MOServerl - a ContextListener instance.protected void fireContextChanged(ContextEvent event)
public java.lang.String toString()
toString in class java.lang.Objectpublic 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 bee registered
for all contexts, a null element is included in the array.
public static void registerTableRowListener(MOServer server,
MOTableRowListener 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.
server - a MOServer instance.listener - the MOTableRowListener instance to register.
public static void unregisterTableRowListener(MOServer server,
MOTableRowListener 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.
server - a MOServer instance.listener - the MOTableRowListener instance to unregister.
|
Copyright 2005-2010 Frank Fock (SNMP4J.org) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||