public class LoopingSequencer extends AbstractSequencer<SequenceStep> implements ReservedTriggers, CancelRunnable, ErrorCaster
| Modifier and Type | Class and Description |
|---|---|
private class |
LoopingSequencer.Conditioner
The helper class that deals with incoming reply messages.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
static String |
ACKNOWLEDGE_PREFIX
The String prefixing an acknowledge command trigger.
|
private boolean |
cancel
The cancel flag.
|
private CommandRendering |
chef
A link to the master command renderer.
|
protected static char |
COLON
The seperator char between command templates and ref-attributes.
|
private static long |
DEFSLEEP
Default maximum sleeping period, in ms.
|
private static ThreadGroup |
DELAY
The thread group the alarms run in ('delay').
|
private CommandLaunching[] |
devices
The devices, abstract representations of remote command servers.
|
private List<SequenceStep> |
dom
The
SequenceList helper object. |
static String |
DONE_PREFIX
The String prefixing a done command trigger.
|
private GlobalGrouping |
extern
A trigger set of external triggers.
|
private Map<String,Boolean> |
finished
The triggers linked to completed tasks, set by the sequencer.
|
static String |
KEY_DEVICETRIGGERS
The key matching to a comma-separated list of device trigger endings.
|
static String |
KEY_NAMEDTRIGGERS
The key matching to a comma-separated list of additional triggers.
|
static String |
KEY_SLEEP
The key matching the maximum sleep period for the sequencer, in ms.
|
static String |
KEY_TARGETTYPES
The key matching to the sequence-definition properties file.
|
private Map<String,Boolean> |
local
The local triggers, set by the sequencer.
|
private Object |
lock
The synchronizing object.
|
private Map<String,Set<String>> |
lookup
A lookup table matching command templates to a list of replies.
|
static String |
LOOPCOUNTER
The generic loop-counter name.
|
static String |
LOOPTIMER
The generic loop-counter name.
|
private Map<String,String> |
match
A lookup table matching reply events plus time to reply templates.
|
private Thread |
mythread
A reference to the thread the sequencer is running in.
|
protected static char |
PLUS
The char to indicate delayed trigger response.
|
private ListIterator<SequenceStep> |
pointer
The list iterator to pass through the sequence.
|
private Map<String,Boolean> |
replies
The internal triggers constructed from replies.
|
private long |
sleep
The sleep time, ms.
|
private SequenceStep |
step
The current active step.
|
private Collection<SequenceTask> |
task
The collection of tasks belonging to the current step
|
private Map<String,String> |
typetable
The lookup table for target types to sequence xml-files.
|
ALTERNATEHOST, ALTERNATEPORT, KEY_BINDNAME, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORTKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORRESERVEDCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Constructor and Description |
|---|
LoopingSequencer(Map<String,String> parser)
Constructs a new xml-sequence instant.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort(List<SequenceStep> abort)
Aborts current task and sequence.
|
void |
append(List<SequenceStep> append)
Appends the sequencing step found in the target file at the end of the
current sequence.
|
private boolean |
broadcast(SequenceTask todo)
This method is called when status/error messages should be broadcasted to
the error handler and the parameter cluster.
|
void |
cancel()
Cancel this sequencer.
|
private Map<String,Boolean> |
createLocals()
Sets up the local variables.
|
private Map<String,Set<String>> |
createPrefixes(Collection<String> vars)
We match our reply table to a lookup of required reply event prefixes, so
that we can announce our interrest, once the true command is created.
|
private Map<String,Boolean> |
createTaskTriggers(Collection<SequenceTask> alltask)
Scans the
DOMSequence for all task references. |
void |
forward(ReplyEvent answer)
This method is called by the
ReplyDeliverer. |
private static Collection<SequenceTask> |
getAllTasks(List<SequenceStep> dom)
Returns all tasks in this sequence as a collection.
|
Thread |
getAsociatedThread()
Returns the thread the sequencer is running in.
|
SequenceList |
getStepsForTarget(TargetDefinition target)
Converts an identifier into a list of sequencer steps.
|
private String |
getVariableFromReply(ReplyEvent reply)
Converts an incomming reply to a reply variable.
|
private void |
insert(int index,
int start,
List<SequenceStep> insert)
Inserts the sequence dom stored in the argument file at the given
position.
|
boolean |
isCancel()
Tests if the last sequence was executed successfully.
|
void |
load(List<SequenceStep> xml)
Loads a sequencer file.
|
long |
maxTimeToCancel()
Returns the maximum time the sequencer needs to cancel.
|
void |
prepend(List<SequenceStep> prep)
Prepends the sequncing step found in the target file at the start of the
current sequence.For expansion of comand version, see
insert(int, int, java.util.List<stella.xml.SequenceStep>). |
boolean |
query(String istrue,
Map<String,Object> auxiliary)
Parses a string following the general boolean algebra rules.
|
void |
registerGlobals(GlobalGrouping externals)
Register the set of external triggers.
|
void |
registerLauncher(CommandLaunching[] launch)
Registers a set of devices.
|
void |
registerRender(CommandRendering boss)
Registers the master mind.
|
void |
run()
The run method of the sequencer.
|
private void |
runTasks(Map<String,Object> loop)
This method expects a collection of current tasks set.
|
private boolean |
sendCommands(SequenceTask todo,
Map<String,Object> loop)
Sends the commands.
|
private void |
setReady(String[] template,
boolean to)
Sets directly stated triggers.
|
protected void |
setReply(String varname,
Boolean val)
Sets a specified variable to a value.
|
Thread |
start()
Starts the sequencer in a well-known thread.
|
String |
toString()
Returns the class name of this sequencer and the current tasks worked on.
|
private void |
updateReplies(Collection<SequenceTask> parallel)
Parses boolean expression for all variable names.
|
createSequenceraddErrorListener, addRmiErrorListener, exit, init, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatusbindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, getBindName, unbindFromRegistry, unbindFromRegistrycontainsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemotePropertyclone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, parseObject, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringPropertiesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddErrorListener, removeErrorListenerdefaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringPropertiespublic static final String LOOPCOUNTER
public static final String LOOPTIMER
public static final String DONE_PREFIX
public static final String ACKNOWLEDGE_PREFIX
public static final String KEY_TARGETTYPES
public static final String KEY_SLEEP
public static final String KEY_DEVICETRIGGERS
public static final String KEY_NAMEDTRIGGERS
private static final long DEFSLEEP
protected static final char COLON
protected static final char PLUS
private CommandRendering chef
private CommandLaunching[] devices
private GlobalGrouping extern
private Map<String,Boolean> local
private Map<String,Boolean> finished
private Map<String,String> match
private Map<String,Set<String>> lookup
private final Map<String,String> typetable
private List<SequenceStep> dom
SequenceList helper object.private ListIterator<SequenceStep> pointer
private SequenceStep step
private Collection<SequenceTask> task
private Thread mythread
private boolean cancel
private final Object lock
private final long sleep
private static final ThreadGroup DELAY
public LoopingSequencer(Map<String,String> parser)
The properties handed over
to the constructer are also used to define the properties of the helper
class, DOMSequence.
If the KEY_TARGETTYPES is not
present in this sequencers properties an NullPointerException is
thrown.
public void registerRender(CommandRendering boss)
registerRender in interface Sequencing<SequenceStep>public void registerGlobals(GlobalGrouping externals)
registerGlobals in interface GlobalDependingpublic void registerLauncher(CommandLaunching[] launch)
Additionally, this sequencer registers as the
ReplySubscriber at all command launchers if the argument
is non-null.
registerLauncher in interface Sequencing<SequenceStep>public Thread start()
start in interface Sequencing<SequenceStep>public Thread getAsociatedThread()
getAsociatedThread in interface CancelRunnablepublic SequenceList getStepsForTarget(TargetDefinition target)
SequenceList list is returned.getStepsForTarget in interface Sequencing<SequenceStep>public void load(List<SequenceStep> xml)
DOMSequence.
No clearing steps are performed.load in interface Sequencing<SequenceStep>public void abort(List<SequenceStep> abort)
abort in interface Sequencing<SequenceStep>public void append(List<SequenceStep> append)
insert(int, int, java.util.List<stella.xml.SequenceStep>).append in interface Sequencing<SequenceStep>public void prepend(List<SequenceStep> prep)
insert(int, int, java.util.List<stella.xml.SequenceStep>).prepend in interface Sequencing<SequenceStep>public void cancel()
cancel in interface CancelRunnablepublic long maxTimeToCancel()
maxTimeToCancel in interface CancelRunnablepublic boolean isCancel()
isCancel in interface Sequencing<SequenceStep>public void run()
private void runTasks(Map<String,Object> loop)
public void forward(ReplyEvent answer)
ReplyDeliverer. It spawns an
extra thread that process the reply to allow fast-return of this method.
ReplyEvent.getReplyMatch() is called.forward in interface ReplySubscriberprotected void setReply(String varname, Boolean val)
public boolean query(String istrue, Map<String,Object> auxiliary) throws ParseException
ParseExceptionExpressionNodeprivate void updateReplies(Collection<SequenceTask> parallel) throws ParseException
ParseExceptionprivate Map<String,Set<String>> createPrefixes(Collection<String> vars)
public String toString()
toString in class PropertyContainerprivate Map<String,Boolean> createLocals()
KEY_DEVICETRIGGERS and the
KEY_NAMEDTRIGGERS already point to an entire list.private void setReady(String[] template, boolean to)
DTDConstants.TRUE and
DTDConstants.FALSE work on the following triggers:
extern. If the
reference is resolvable, the trigger is set to the appropriate value.
Note that not all external triggers allow setting of their value.
An UnsupportedException may be thrown as a result.KEY_NAMEDTRIGGERS is used for
resolving the reference.finished. If this
look-up is successful, the appropriate task's done attribute is
set to the stated value, regardless of the actual execution status of the
task.private boolean broadcast(SequenceTask todo)
private boolean sendCommands(SequenceTask todo, Map<String,Object> loop)
private void insert(int index,
int start,
List<SequenceStep> insert)
step.
Inserting a new sequence into an old one has a problem with command template version numbers. It is believed, however, that a simple procedure is sufficient to overcome this problem and to cover all possible error cases. The general contract is:
This method does not abort the current tasks. If this
behaviour is intended the DOMSequence.abortStep(int) has to be called
before this method.
IllegalArgumentException - If index is less than zero or higher than the number of
active orders in the current sequence.private Map<String,Boolean> createTaskTriggers(Collection<SequenceTask> alltask)
DOMSequence for all task references. Each reference is
used as a task trigger, consisting of the tag name of the task element,
DTDConstants.TASK, plus its unique reference. All tasks present
in the dom sequence are scanned and their DTDConstants.TASKDONE
flag is evaluated.private String getVariableFromReply(ReplyEvent reply)
private static Collection<SequenceTask> getAllTasks(List<SequenceStep> dom)