public class DefaultCounterListener extends Object implements CounterListener
DefaultCounterListener
is the default implementation of
the CounterListener
interface. For any counter incrementation
event it checks whether the referenced counter object already exists. If not,
it will be created and initialized with one. Otherwise, the current value
will be incremented by one. In either case, the current value will be
returned in the event object.
To use a DefaultCounterListener
with SNMP4J, add it to the
default CounterSupport
by:
CounterSupport.getInstance().addCounterListener(new DefaultCounterListener());
Constructor and Description |
---|
DefaultCounterListener()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
Counter32 |
add(OID oid,
Counter32 counter)
Adds a counter to this counter listener.
|
void |
incrementCounter(CounterEvent event)
Increment the supplied counter instance and return the current value
(after incrementation) in the event object if the event receiver is the
maintainer of the counter value.
|
boolean |
isCountRegisteredOnly() |
Counter32 |
remove(OID oid)
Removes a counter from this listener and returns it.
|
void |
setCountRegisteredOnly(boolean countRegisteredOnly)
Sets the flag which indicates how unregistered counter events
should be handled.
|
public void incrementCounter(CounterEvent event)
CounterListener
incrementCounter
in interface CounterListener
event
- a CounterEvent
instance.public Counter32 add(OID oid, Counter32 counter)
oid
- the object identifier of the counter instance (thus including
the .0 suffix).counter
- the counter to register.public Counter32 remove(OID oid)
oid
- the object identifier of the counter instance (thus including
the .0 suffix).public boolean isCountRegisteredOnly()
public void setCountRegisteredOnly(boolean countRegisteredOnly)
countRegisteredOnly
- if true counter events for OIDs which have not been
added by add(org.snmp4j.smi.OID, org.snmp4j.smi.Counter32)
will be ignored, otherwise a
Counter32
will be registered to count corresponding
events.Copyright © 2024 SNMP4J.org. All rights reserved.