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)
Create a event listener with poolSize threads with an unbounded queue and daemon threads.
|
AsyncEventListener(int poolSize,
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)
poolSize
- the pool sizepublic AsyncEventListener(int poolSize, long timeOutSeconds, boolean isDaemon)
poolSize
- size of the event processing pooltimeOutSeconds
- 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–2018 Apache Software Foundation. All rights reserved.