com.gridsystems.nextgrid.api.pom
Class ControlProcessImpl

java.lang.Object
  extended by com.gridsystems.nextgrid.api.pom.PemHelper
      extended by com.gridsystems.nextgrid.api.pom.ProcessImpl
          extended by com.gridsystems.nextgrid.api.pom.ControlProcessImpl
All Implemented Interfaces:
Enactable, java.io.Serializable, java.lang.Cloneable, nextgrid.api.pom.ControlProcess, nextgrid.api.pom.Process
Direct Known Subclasses:
AsyncProcessImpl, DoWhileProcessImpl, IfThenElseProcessImpl, RepeatUntilProcessImpl, SequenceProcessImpl, SplitJoinProcessImpl, UnorderedListProcessImpl, WhileDoProcessImpl

public abstract class ControlProcessImpl
extends ProcessImpl
implements nextgrid.api.pom.ControlProcess

Control Process.

A control process is a process container that adds implicit execution flow constraints to its children processes. These constraints may be implemented through dependencies among the processes.

In addition to this, a control process can introduce "hints" that the enactor may use to drive the evaluation process. For example, a conditional control structure may instruct the enactor to only evaluate a subset of its branches for considering it as valid.

Author:
Rodrigo Ruiz
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.gridsystems.nextgrid.api.pom.ProcessImpl
ProcessImpl.ValidationType
 
Field Summary
 
Fields inherited from class com.gridsystems.nextgrid.api.pom.ProcessImpl
DFA_INITIAL_STATE, ENACTOR_LOG
 
Constructor Summary
protected ControlProcessImpl(int maxChildren)
          Creates a new instance.
 
Method Summary
 void addChildren(int index, nextgrid.api.pom.Process child)
          Inserts the specified element at the specified position in this list.
 void addChildren(nextgrid.api.pom.Process... processes)
          Adds a set of processes to the child list.
 nextgrid.api.pom.Process copy()
          
 void discover(nextgrid.api.env.ProcessEnvironment env)
          
 void doEvaluate(nextgrid.api.env.ProcessEnvironment env)
          Performs the actual actions needed for evaluating this process instance.
 nextgrid.api.pom.Process findProcessById(java.net.URI id)
          
 int getChildCount()
          Gets the number of child processes.
 nextgrid.api.pom.Process[] getChildren()
          Gets the processes in the children list.
 nextgrid.api.pom.Process getChildren(int index)
          Gets a child process by its index.
 nextgrid.api.pom.Reference<?> getLocalVar(java.lang.String name)
          
 java.util.Map<java.lang.String,nextgrid.api.pom.Reference<?>> getLocalVars()
          
 boolean isMemoizeActive()
          
 void prioritise(nextgrid.api.env.ProcessEnvironment env, java.util.PriorityQueue<nextgrid.api.pom.Process> queue)
          
 nextgrid.api.pom.Process removeChild(int index)
          Removes the element at the specified position in this list.
 boolean removeChild(nextgrid.api.pom.Process child)
          Removes a process instance from the children list.
protected  void resetChildren()
          Resets all child processes.
 void setChildren(int index, nextgrid.api.pom.Process child)
          Sets a child process.
 void setChildren(nextgrid.api.pom.Process... children)
          Sets the list of child processes for this process instance.
 void setLocalVar(java.lang.String name, nextgrid.api.pom.Reference<?> value)
          
 void setMemoizeActive(boolean memoizeActive)
          
 void trim(int count)
          Sets the size of the children list to a maximum of count items.
 
Methods inherited from class com.gridsystems.nextgrid.api.pom.ProcessImpl
attachListeners, doReset, doValidate, enact, evaluate, evaluate, findRoot, getAttribute, getAttribute, getAttribute, getAttributes, getDescription, getId, getInput, getInputs, getInputs, getInputType, getName, getOutput, getOutputs, getOutputs, getOutputType, getParent, getState, getUsedInputNames, getUsedOutputNames, invalidate, isEvaluated, isLazy, isValidated, prioritise, putInput, putOutput, removeInput, removeOutput, reset, setAttribute, setAttribute, setDescription, setEvaluated, setId, setLazy, setName, setParent, setState, unuseInput, unuseOutput, useInput, useOutput, validate, waitForInputs
 
Methods inherited from class com.gridsystems.nextgrid.api.pom.PemHelper
addListener, fireDiscovererSelected, fireDiscoveryFailed, fireDiscoveryFinished, fireDiscoveryStarting, fireEvent, fireProcessEvaluated, fireProcessFailed, fireProcessFailed, fireProcessFinished, fireProcessFinished, fireProcessSelected, fireProcessStarted, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nextgrid.api.pom.ControlProcess
isLazy, setLazy
 
Methods inherited from interface nextgrid.api.pom.Process
addListener, enact, evaluate, findRoot, getAttribute, getAttribute, getAttribute, getAttributes, getDescription, getId, getInput, getInputs, getInputType, getName, getOutput, getOutputs, getOutputType, getParent, getUsedInputNames, getUsedOutputNames, invalidate, isEvaluated, isValidated, putInput, putOutput, removeInput, removeListener, removeOutput, reset, setAttribute, setAttribute, setDescription, setId, setName, setParent, unuseInput, unuseOutput, useInput, useOutput, validate
 
Methods inherited from interface com.gridsystems.nextgrid.api.pom.Enactable
run
 

Constructor Detail

ControlProcessImpl

protected ControlProcessImpl(int maxChildren)
Creates a new instance.

Parameters:
maxChildren - The max number of supported children processes
Method Detail

findProcessById

public final nextgrid.api.pom.Process findProcessById(java.net.URI id)

Specified by:
findProcessById in interface nextgrid.api.pom.Process

prioritise

public final void prioritise(nextgrid.api.env.ProcessEnvironment env,
                             java.util.PriorityQueue<nextgrid.api.pom.Process> queue)
                      throws nextgrid.api.pom.ProcessException

Specified by:
prioritise in interface nextgrid.api.pom.Process
Throws:
nextgrid.api.pom.ProcessException

discover

public void discover(nextgrid.api.env.ProcessEnvironment env)
              throws nextgrid.api.pom.ProcessException

Specified by:
discover in interface nextgrid.api.pom.Process
Throws:
nextgrid.api.pom.ProcessException

doEvaluate

public final void doEvaluate(nextgrid.api.env.ProcessEnvironment env)
                      throws nextgrid.api.pom.ProcessException
Performs the actual actions needed for evaluating this process instance.

Specified by:
doEvaluate in class ProcessImpl
Parameters:
env - The process environment
Throws:
nextgrid.api.pom.ProcessException - If an error occurs

isMemoizeActive

public final boolean isMemoizeActive()

Specified by:
isMemoizeActive in interface nextgrid.api.pom.ControlProcess

setMemoizeActive

public final void setMemoizeActive(boolean memoizeActive)

Specified by:
setMemoizeActive in interface nextgrid.api.pom.ControlProcess

getChildren

public final nextgrid.api.pom.Process[] getChildren()
Gets the processes in the children list.

Specified by:
getChildren in interface nextgrid.api.pom.ControlProcess
Returns:
An array of child processes

getChildren

public final nextgrid.api.pom.Process getChildren(int index)
Gets a child process by its index.

Specified by:
getChildren in interface nextgrid.api.pom.ControlProcess
Parameters:
index - The child process position
Returns:
The process

getChildCount

public final int getChildCount()
Gets the number of child processes.

Specified by:
getChildCount in interface nextgrid.api.pom.ControlProcess
Returns:
the number of child processes

trim

public final void trim(int count)
Sets the size of the children list to a maximum of count items.

It correctly removes all items from position count to the end of the list. If the list is already smaller than count, it does nothing.

Specified by:
trim in interface nextgrid.api.pom.ControlProcess
Parameters:
count - The max number of elements to maintain in the children list

setChildren

public final void setChildren(nextgrid.api.pom.Process... children)
Sets the list of child processes for this process instance.

Specified by:
setChildren in interface nextgrid.api.pom.ControlProcess
Parameters:
children - An array of processes

setChildren

public final void setChildren(int index,
                              nextgrid.api.pom.Process child)
Sets a child process.

Specified by:
setChildren in interface nextgrid.api.pom.ControlProcess
Parameters:
index - The position in the list
child - The process to set
Throws:
java.lang.UnsupportedOperationException - If the process does not support children

addChildren

public final void addChildren(int index,
                              nextgrid.api.pom.Process child)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
addChildren in interface nextgrid.api.pom.ControlProcess
Parameters:
index - index at which the specified element is to be inserted.
child - element to be inserted.
Throws:
java.lang.UnsupportedOperationException - if the add method is not supported by this list.
java.lang.ClassCastException - if the class of the specified element prevents it from being added to this list.
java.lang.IllegalArgumentException - if some aspect of the specified element prevents it from being added to this list.
java.lang.IndexOutOfBoundsException - index is out of range (index < 0 || index > size()).

addChildren

public final void addChildren(nextgrid.api.pom.Process... processes)
Adds a set of processes to the child list.

Specified by:
addChildren in interface nextgrid.api.pom.ControlProcess
Parameters:
processes - The processes to add

removeChild

public final nextgrid.api.pom.Process removeChild(int index)
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Specified by:
removeChild in interface nextgrid.api.pom.ControlProcess
Parameters:
index - the index of the element to remove
Returns:
the element previously at the specified position
Throws:
java.lang.UnsupportedOperationException - if the remove method is not supported by this list.
java.lang.IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

removeChild

public final boolean removeChild(nextgrid.api.pom.Process child)
Removes a process instance from the children list.

Specified by:
removeChild in interface nextgrid.api.pom.ControlProcess
Parameters:
child - The process to remove
Returns:
true if it is removed

getLocalVar

public final nextgrid.api.pom.Reference<?> getLocalVar(java.lang.String name)

Specified by:
getLocalVar in interface nextgrid.api.pom.ControlProcess

setLocalVar

public final void setLocalVar(java.lang.String name,
                              nextgrid.api.pom.Reference<?> value)

Specified by:
setLocalVar in interface nextgrid.api.pom.ControlProcess

getLocalVars

public final java.util.Map<java.lang.String,nextgrid.api.pom.Reference<?>> getLocalVars()

Specified by:
getLocalVars in interface nextgrid.api.pom.ControlProcess

copy

public nextgrid.api.pom.Process copy()

Specified by:
copy in interface nextgrid.api.pom.Process
Overrides:
copy in class ProcessImpl

resetChildren

protected final void resetChildren()
Resets all child processes.

This method can be used by loop constructs to prepare each iteration.

Specified by:
resetChildren in class ProcessImpl


Copyright © 2006-2008 Grid Systems, S.A.. All Rights Reserved.