|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.deltax.util.listener.ListenerSupport
This class is the pluggable support for asynchronous listening.
It exposes registration methods for
signal listeners and the
notify(Signal) method to be called to actually send signals.
| Field Summary | |
static long |
DEFAULT_RECEIVE_TIMEOUT
The default timea Listener is
given to exit gracefully from the Listener.receive(Signal)
method when it's removed.
|
protected java.lang.Object |
lock
A lock used in accessing the listeners/queue registry. |
| Constructor Summary | |
ListenerSupport()
Create a listener support. |
|
ListenerSupport(int maxThreads)
Create a listener support which uses at most the given number of threads |
|
| Method Summary | |
void |
addListener(Listener listener)
Add a listener to the listeners set. |
int |
countListeners()
Count the registered listeners. |
protected com.deltax.util.listener.SignalQueue[] |
getQueues()
Allows subclasses to retrieve the queue threads (experimental) |
long |
getReceiveTimeout()
Return the the amount of time (in ms.) a
Listeneris given to exit gracefully from the
Listener.receive(Signal) method when it's
removed.
|
boolean |
isRegistered(Listener listener)
Check whether a listener is registered or not. |
void |
notify(Signal signal)
Broadcast a signal. |
void |
removeAllListeners()
Unconditionally unregister all the listeners. |
void |
removeListener(Listener listener)
Remove a listener from the listeners set. |
void |
setReceiveTimeout(long receiveTimeout)
Set the the amount of time (in ms.) a
Listeneris given to exit gracefully from the
Listener.receive(Signal) method when it's
removed.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final long DEFAULT_RECEIVE_TIMEOUT
timea Listener is
given to exit gracefully from the Listener.receive(Signal)
method when it's removed.
It can be set by using setReceiveTimeout(long)after creating
the listener support.
protected java.lang.Object lock
| Constructor Detail |
public ListenerSupport(int maxThreads)
public ListenerSupport()
| Method Detail |
public void addListener(Listener listener)
If the support has a maximum thread count, the method will block if there are no free threads for the listener, until another listener releases a thread.
addListener in interface IListenerSupportlistener - the listener to addpublic void removeAllListeners()
removeAllListeners in interface IListenerSupportpublic boolean isRegistered(Listener listener)
isRegistered in interface IListenerSupportlistener - the listener to check
public void notify(Signal signal)
notify in interface IListenerSupport
public void removeListener(Listener listener)
throws BlockedListenerException
removeListener in interface IListenerSupportlistener - the listener to remove
BlockedListenerException - if the listener is blocked and cannot be removedprotected com.deltax.util.listener.SignalQueue[] getQueues()
public int countListeners()
countListeners in interface IListenerSupportIListenerSupport.countListeners()public long getReceiveTimeout()
time (in ms.) a
Listeneris given to exit gracefully from the
Listener.receive(Signal) method when it's
removed.
Note that this timeout does not apply to normal operations (i.e. a listener can normally block for how long it wants) but only when a listener is removed.
getReceiveTimeout in interface IListenerSupportpublic void setReceiveTimeout(long receiveTimeout)
time (in ms.) a
Listeneris given to exit gracefully from the
Listener.receive(Signal) method when it's
removed.
Note that this timeout does not apply to normal operations (i.e. a listener can normally block for how long it wants) but only when a listener is removed.
setReceiveTimeout in interface IListenerSupportreceiveTimeout - the timeout in milliseconds
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||