public interface SnmpListener
Conceptually, a listener represents a provider component that listens for incoming SNMP notifications at the transport layer of the network. Typically, an implementation binds a socket to an IP address and port and receives all incoming SNMP notifications received on that socket.
A listener maintains an ordered collection of handlers, based on a priority
specified when each handler is registered. When an SNMP notification is
received, registered handlers are invoked in priority order. When a handler
indicates that it handled the event (via the return value of
SnmpNotificationHandler.handleNotification(SnmpNotificationEvent)
),
handlers of lower priority are not invoked.
The listener can be used to implement a strategy for handling different types of notifications, where a given handler supports one notification type (or perhaps a set of closely related types). For each received notification, the listener will ask each registered handler (in priority order) to handle the notification, stopping with the first handler that claims to have done so.
Modifier and Type | Method and Description |
---|---|
void |
addHandler(SnmpNotificationHandler handler)
Adds a notification handler.
|
void |
addHandler(SnmpNotificationHandler handler,
int priority)
Adds a notification handler.
|
void |
close()
Closes this listener.
|
void |
removeHandler(SnmpNotificationHandler handler)
Removes a notification handler.
|
void addHandler(SnmpNotificationHandler handler)
The handler will be added to the collection such that it is notified after all previously registered handlers.
This method has no effect if a handler identical to handler
is
already registered.
handler
- the handler to addvoid addHandler(SnmpNotificationHandler handler, int priority)
The handler will be added to the collection, such that it is notified
after all previously registered handlers whose priority is less than or
equal to the specified priority
.
This method has no effect if a handler identical to handler
is
already registered.
handler
- the handler to addpriority
- priority for the handlervoid removeHandler(SnmpNotificationHandler handler)
This method has no effect if handler
is not registered
handler
- the handler to removevoid close()
After the listener has been closed, no further notifications will be distributed to handlers.
Copyright © 2012–2015. All rights reserved.