public class EventConsumerAwait<T_PayloadBack extends PayloadBack,T_Payload extends Payload> extends java.lang.Object implements EventConsumer
EventConsumer
interface,
but the EventConsumer#awaitExecution(long)
is already implemented here.
The EventConsumer.processEvent(java.util.EventObject)
implementation
should call setDone(String)
on receive and execute an event
if the event succeeds the execution or succeeds with exception or error.
EventConsumer.processEvent(java.util.EventObject)
is not defined here.
Hence the implementation of 'processEvent(...)' should be done in the specific kind in the inherit class.Modifier and Type | Field and Description |
---|---|
protected boolean |
bDone
It is set in
setDone(String) , should be called if the event was received with the "done" information. |
private boolean |
bWait
Marker that
Object.wait() was called in awaitExecution(long, boolean) . |
protected T_Payload |
cmdData
This cmdData are used and reused for calling commands to the
FileRemote#device() during walking. |
EventWithDst<T_PayloadBack,T_Payload> |
evBack
Back event with the evCmd as opponent.
|
protected EventThread_ifc |
evThread
This reference should be used if the Consumer implementor (the inherit class) should offer a specific thread
where the events are intermediately stored before execution in this consumer.
|
java.lang.String |
name |
protected T_PayloadBack |
progressData
Data for the progress and success back event used and reused for all back event calling, referenced from
evBack |
protected java.lang.String |
sError
Set in
setDone(String) as info about error from the event. |
static java.lang.String |
version
Version, history and license.
|
mEventConsumed, mEventConsumerException, mEventConsumFinished, mEventDonotRelinquish, mMaskReservedHere
Modifier | Constructor and Description |
---|---|
protected |
EventConsumerAwait(java.lang.String name,
T_PayloadBack backData,
EventThread_ifc evThread,
T_Payload cmdData,
EventThread_ifc cmdThread)
Called from the inherit class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
awaitExecution(long timeout,
boolean clearDone)
Awaits for execution till "done" was set by the event which uses this destination or till the timeout is expired.
|
EventConsumerAwait |
clean()
|
boolean |
done()
Quest whether done was coming.
|
EventThread_ifc |
evThread()
If the inherit consumer defines a specific thread, get it here.
|
int |
processEvent(java.util.EventObject evRaw)
This operation is called from
EventWithDst.sendEvent(Object) or from EventTimerThread.stepThread()
as overridden. |
protected int |
processEvent(T_PayloadBack progress,
EventWithDst<T_Payload,T_PayloadBack> evCmd)
This operation should be overridden and called as super.processEvent()
if more should be done with the progress event.
|
protected void |
setDone(java.lang.String sError)
This operation should be called by the implementing class if an event was received with "done" information.
|
public static final java.lang.String version
FileRemoteProgressEventConsumer
:
PayloadBack
contains the minimal necessary payload to test done and error.
awaitExecution(long, boolean)
: If the event was cleaned
without success this operation should be left. It is done via bWait
= false test.
The adequate notifyAll in clean()
wakes up the 'await...'.
protected final T_Payload extends Payload cmdData
FileRemote#device()
during walking.
It are referenced from evBack.protected final T_PayloadBack extends PayloadBack progressData
evBack
public final EventWithDst<T_PayloadBack extends PayloadBack,T_Payload extends Payload> evBack
T_Payload
for internal commands which are executed if possible in the same thread.
The back event is used for check success, and also necessary if the device uses communication and/or an own thread.
The EventConsumer for this evBack is this own class.
It offers awaitExecution(long, boolean)
in its base class FileRemoteProgressEventConsumer
.public final java.lang.String name
protected boolean bDone
setDone(String)
, should be called if the event was received with the "done" information.
It is used to continue after awaitExecution(long, boolean)
.private boolean bWait
Object.wait()
was called in awaitExecution(long, boolean)
.protected java.lang.String sError
setDone(String)
as info about error from the event.protected final EventThread_ifc evThread
protected EventConsumerAwait(java.lang.String name, T_PayloadBack backData, EventThread_ifc evThread, T_Payload cmdData, EventThread_ifc cmdThread)
evThread
- maybe null if not used here.public EventThread_ifc evThread()
evThread
in interface EventConsumer
protected int processEvent(T_PayloadBack progress, EventWithDst<T_Payload,T_PayloadBack> evCmd)
progress
- progress data to informevCmd
- The command event may be given as opponent of the progress event for feedback,
for example if a quest is given ("skip/override" etc.)
This can be used in the overridden operations.public int processEvent(java.util.EventObject evRaw)
EventWithDst.sendEvent(Object)
or from EventTimerThread.stepThread()
as overridden. It prepares and calls {@link #processEvent(T_PayloadBack, EventWithDst)
which is overridden by the application.processEvent
in interface EventConsumer
evRaw
- The event. It contains some data. The type of the event is not specified here. Any events
can be processed.EventConsumer.mEventConsumed
or EventConsumer.mEventDonotRelinquish
etc. see list above.
This value is forwarded to EventSource.notifyConsumed(int)
and can be evaluated by the application
in the calling thread or in any other thread which have access to implementation of EventSource
.protected final void setDone(java.lang.String sError)
sError
- If the event contains an error string, it may be helpfully.public boolean done()
bDone
public final boolean awaitExecution(long timeout, boolean clearDone)
setDone(String)
was called.timeout
- milliseconds timeoutclearDone
- clear the done flag again before return (not on entry!). Use clean()
to clean done before entry.public EventConsumerAwait clean()
bDone
and also sError
.
It should be called on initializing the event,
in any case before awaitExecution(long, boolean)
was called.