|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.devexperts.qd.util.DataProcessor
public abstract class DataProcessor
This class is base class for listening QD for data availability and rescheduling its processing using Executor
.
Classes that extend DataProcessor
listen for data coming from QD and process incoming data in
separate thread or threads.
Executor
may be single thread or thread pool executor. One Executor
may be shared by different data processors.
It is guaranteed that new data processing handler will not be called until previous has completed its work.
DataProcessor
registers DataListener
in DataProvider
when
startProcessing(DataProvider)
startProcessing} method is called.
Class client is responsible to call stopProcessing
when processing is not required any more.
This class is thread-safe and lock-free. Change carefully.
Constructor Summary | |
---|---|
protected |
DataProcessor(java.util.concurrent.Executor executor)
Constructs new data processor for the specified executor. |
protected |
DataProcessor(java.util.concurrent.Executor executor,
DataProvider... dataProviders)
Deprecated. Usage of this method can lead to NullPointerException or other problems in extending code,
because this method starts processing and leaks this pointer to other threads (submits it to executor}
right from inside constructor. Derived classes that initialize their fields (including final ones) in constructor
may see default, non-initialized values of those fields. Use DataProcessor(Executor) and call
startProcessing(DataProvider) method after construction. Use CompositeDataProvider class if you
need support for multiple data providers. |
Method Summary | |
---|---|
protected abstract void |
processData(RecordSource source)
Method for processing incoming data from QD. |
void |
startProcessing(DataProvider provider)
Starts data processing for the specified DataProvider . |
void |
stopProcessing()
Stops data processing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DataProcessor(java.util.concurrent.Executor executor, DataProvider... dataProviders)
NullPointerException
or other problems in extending code,
because this method starts processing and leaks this
pointer to other threads (submits it to executor}
right from inside constructor. Derived classes that initialize their fields (including final ones) in constructor
may see default, non-initialized values of those fields. Use DataProcessor(Executor)
and call
startProcessing(DataProvider)
method after construction. Use CompositeDataProvider
class if you
need support for multiple data providers.
DataListener
s on passed DataProvider
s
and start processing.
java.lang.NullPointerException
- if executor is null.protected DataProcessor(java.util.concurrent.Executor executor)
java.lang.NullPointerException
- if executor is null.Method Detail |
---|
protected abstract void processData(RecordSource source)
DataProcessor
calls this method in Executor
thread.
public void startProcessing(DataProvider provider)
DataProvider
.
This method may be called at most once after construction.
java.lang.NullPointerException
- if provider
is null.
java.lang.IllegalStateException
- if called multiple times. It is checked weakly to ensure fail-fast error detection
behaviour. There is no strict thread-safe guarantee for this exception to be thrown if this method is called
concurrently from multiple threads.public void stopProcessing()
DataListener
on DataProvider
.
This method may be called only after startProcessing(DataProvider)
.
Note: client code is responsible for disposing DataProvider originally passed to DataProcessor.
java.lang.IllegalStateException
- if called before startProcessing(DataProvider)
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |