public class XMLSequencer extends AbstractSequencer<Collection<DOMSequence.TaskElement>> implements ReservedTriggers, CancelRunnable
| Modifier and Type | Class and Description |
|---|---|
private class |
XMLSequencer.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.
|
static Object |
CHAINING
The type signaling pure chaining targets with no steps.
|
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 DOMSequence |
dom
The
DOMSequence helper object. |
static String |
DONE_PREFIX
The String prefixing a done command trigger.
|
private GlobalGrouping |
extern
A trigger set of external triggers.
|
private Map |
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 |
local
The local triggers, set by the sequencer.
|
private Object |
lock
The synchronizing object.
|
private Map |
lookUp
A lookup table matching command templates to a list of replies.
|
private Map |
matchUp
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 Map |
replies
The internal triggers constructed from replies.
|
private long |
sleep
The sleep time, ms.
|
private ListIterator<Collection<DOMSequence.TaskElement>> |
step
The list iterator to pass through the dom sequence.
|
private Collection<DOMSequence.TaskElement> |
task
The collection of tasks belonging to the current step.
|
private Map |
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 |
|---|
XMLSequencer(Map<String,String> parser)
Constructs a new xml-sequence instant.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort(List<Collection<DOMSequence.TaskElement>> abort)
Aborts current task and sequence.
|
void |
append(List<Collection<DOMSequence.TaskElement>> append)
Appends the sequencing step found in the target file at the end of the
current sequence.
|
void |
cancel()
Cancel this sequencer.
|
void |
forward(ReplyEvent answer)
This method is called by the
ReplyDeliverer. |
Thread |
getAsociatedThread()
Returns the thread the sequencer is running in.
|
DOMSequence |
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 xml)
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<Collection<DOMSequence.TaskElement>> xml)
Loads a sequencer file.
|
long |
maxTimeToCancel()
Returns the maximum time the sequencer needs to cancel.
|
void |
prepend(List<Collection<DOMSequence.TaskElement>> 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). |
boolean |
query(String istrue)
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 |
retrieveReplies()
Parses boolean expression for all variable names.
|
void |
run()
The run method of the sequencer.
|
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.
|
private void |
setTaskTriggers()
Scans the
DOMSequence for all task references. |
private void |
setupLocals()
Sets up the local variables.
|
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.
|
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, waitdefaultBoolean, 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 DONE_PREFIX
public static final String ACKNOWLEDGE_PREFIX
public static final Object CHAINING
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 local
private Map finished
private Map replies
private Map matchUp
private Map lookUp
private final Map typetable
private DOMSequence dom
DOMSequence helper object.private ListIterator<Collection<DOMSequence.TaskElement>> step
private Collection<DOMSequence.TaskElement> task
private Thread mythread
private boolean cancel
private final Object lock
private final long sleep
private static final ThreadGroup DELAY
public XMLSequencer(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<Collection<DOMSequence.TaskElement>>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<Collection<DOMSequence.TaskElement>>public Thread start()
start in interface Sequencing<Collection<DOMSequence.TaskElement>>public Thread getAsociatedThread()
getAsociatedThread in interface CancelRunnablepublic DOMSequence getStepsForTarget(TargetDefinition target)
DOMSequence list is returned.getStepsForTarget in interface Sequencing<Collection<DOMSequence.TaskElement>>public void load(List<Collection<DOMSequence.TaskElement>> xml)
DOMSequence.
No clearing steps are performed.load in interface Sequencing<Collection<DOMSequence.TaskElement>>public void abort(List<Collection<DOMSequence.TaskElement>> abort)
abort in interface Sequencing<Collection<DOMSequence.TaskElement>>public void append(List<Collection<DOMSequence.TaskElement>> append)
insert(int, int, java.util.List).append in interface Sequencing<Collection<DOMSequence.TaskElement>>public void prepend(List<Collection<DOMSequence.TaskElement>> prep)
insert(int, int, java.util.List).prepend in interface Sequencing<Collection<DOMSequence.TaskElement>>public void cancel()
cancel in interface CancelRunnablepublic long maxTimeToCancel()
maxTimeToCancel in interface CancelRunnablepublic boolean isCancel()
isCancel in interface Sequencing<Collection<DOMSequence.TaskElement>>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) throws ParseException
ParseExceptionExpressionNodepublic void retrieveReplies()
throws ParseException
ParseExceptionpublic String toString()
toString in class PropertyContainerprivate void setupLocals()
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 void insert(int index,
int start,
List xml)
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 void setTaskTriggers()
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)