|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
util.rmi.RmiPropertyContainer
util.rmi.AbstractRmiCaster
stella.CastingContainer
stella.AbstractSequencer<SequenceStep>
stella.xml.LoopingSequencer
public class LoopingSequencer
| Nested Class Summary | |
|---|---|
private class |
LoopingSequencer.Conditioner
The helper class that deals with incoming reply messages. |
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Field Summary | |
|---|---|
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 List<SequenceStep> |
dom
The SequenceList helper object. |
static String |
DONE_PREFIX
The String prefixing a done command trigger. |
private ParameterClustering |
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. |
| Fields inherited from class util.rmi.AbstractRmiCaster |
|---|
ALTERNATEHOST, ALTERNATEPORT, KEY_BINDNAME, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORT |
| Fields inherited from class util.PropertyBundles |
|---|
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES |
| Fields inherited from class util.PropertyResources |
|---|
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset |
| Fields inherited from class util.PropertyContainer |
|---|
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR |
| Fields inherited from interface stella.ReservedTriggers |
|---|
RESERVED |
| Fields inherited from interface util.PropertySupplying |
|---|
CONFIG, KEY_CLASS |
| Fields inherited from interface util.ResourceSupplying |
|---|
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME |
| Constructor Summary | |
|---|---|
LoopingSequencer(Map<String,String> parser)
Constructs a new xml-sequence instant. |
|
| Method Summary | |
|---|---|
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. |
boolean |
query(String istrue,
Map<String,Object> auxiliary)
Parses a string following the general boolean algebra rules. |
void |
registerCluster(ParameterClustering 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. |
| Methods inherited from class stella.AbstractSequencer |
|---|
createSequencer |
| Methods inherited from class stella.CastingContainer |
|---|
addErrorListener, addRmiErrorListener, exit, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus |
| Methods inherited from class util.rmi.AbstractRmiCaster |
|---|
bindAlternate, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, getBindName, unbindFromRegistry, unbindFromRegistry |
| Methods inherited from class util.rmi.RmiPropertyContainer |
|---|
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty |
| Methods inherited from class util.PropertyBundles |
|---|
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource |
| Methods inherited from class util.PropertyResources |
|---|
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, init, keyCreate, keyCreate, reload, setApplet |
| Methods inherited from class util.PropertyContainer |
|---|
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, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface stella.ErrorCaster |
|---|
addErrorListener, removeErrorListener |
| Methods inherited from interface util.PropertySupplying |
|---|
defaultBoolean, 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, stringProperties |
| Methods inherited from interface util.ResourceSupplying |
|---|
getResource, getResourceAsStream, getResources |
| Methods inherited from interface util.Initializable |
|---|
init |
| Field Detail |
|---|
public static final String LOOPCOUNTER
public static final String LOOPTIMER
public 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 ParameterClustering extern
private Map<String,Boolean> local
private Map<String,Boolean> finished
private Map<String,Boolean> replies
private Map<String,String> match
private Map<String,Set<String>> lookup
private 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 Object lock
private long sleep
private static final ThreadGroup DELAY
| Constructor Detail |
|---|
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.
| Method Detail |
|---|
public void registerRender(CommandRendering boss)
registerRender in interface Sequencing<SequenceStep>public void registerCluster(ParameterClustering externals)
registerCluster in interface ClusterDependingpublic 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) .
append in interface Sequencing<SequenceStep>public void prepend(List<SequenceStep> prep)
insert(int, int, java.util.List) .
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()
run in interface Runnableprivate 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 ReplySubscriber
protected void setReply(String varname,
Boolean val)
public boolean query(String istrue,
Map<String,Object> auxiliary)
throws ParseException
ParseExceptionExpressionNode
private 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)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||