T
- the generic typepublic abstract class AsyncEventListener<T extends LensEvent> extends Object implements LensEventListener<T>
HANDLER_METHOD_NAME
Constructor and Description |
---|
AsyncEventListener()
Create a single threaded event listener with an unbounded queue, with daemon threads.
|
AsyncEventListener(int poolSize,
int maxPoolSize)
Create a event listener with poolSize threads with an unbounded queue and daemon threads.
|
AsyncEventListener(int poolSize,
int maxPoolSize,
int maxQueueSize,
long timeOutSeconds,
boolean isDaemon)
Create an asynchronous event listener which uses a thread poool to process events.
|
Modifier and Type | Method and Description |
---|---|
BlockingQueue<Runnable> |
getEventQueue() |
void |
onEvent(T event)
Creates a new runnable and calls the process method in it.
|
abstract void |
process(T event)
Should implement the actual event handling.
|
void |
stop()
Should be called to stop the event processor thread.
|
public AsyncEventListener()
public AsyncEventListener(int poolSize, int maxPoolSize)
poolSize
- the pool sizemaxPoolSize
- the max pool sizepublic AsyncEventListener(int poolSize, int maxPoolSize, int maxQueueSize, long timeOutSeconds, boolean isDaemon)
poolSize
- size of the event processing poolmaxPoolSize
- the max pool sizemaxQueueSize
- max size of the event queue, if this is non positive, then the queue is unboundedtimeOutSeconds
- time out in seconds when an idle thread is destroyedisDaemon
- if the threads used to process should be daemon threads,
if false, then implementation should call stop()
to stop the thread poolpublic void onEvent(T event) throws LensException
onEvent
in interface LensEventListener<T extends LensEvent>
event
- the eventLensException
- the lens exceptionpublic abstract void process(T event)
event
- the eventpublic void stop()
public BlockingQueue<Runnable> getEventQueue()
Copyright © 2014–2016 Apache Software Foundation. All rights reserved.