Trull

edu.luc.cs.trull
Class AwaitAll

java.lang.Object
  extended by edu.luc.cs.trull.EmptyComponent
      extended by edu.luc.cs.trull.TerminatingComponent
          extended by edu.luc.cs.trull.AbstractComponent
              extended by edu.luc.cs.trull.AbstractCombinator
                  extended by edu.luc.cs.trull.SingleChildCombinator
                      extended by edu.luc.cs.trull.AwaitAll
All Implemented Interfaces:
Combinator, Component, PropertyChangeSource, Startable, Suspendable, Terminating, java.beans.PropertyChangeListener, java.util.EventListener

public class AwaitAll
extends SingleChildCombinator

A conjunctive await. A conjunctive await waits until all specified events have occurred, executes an action if present, and continues as the given child component if present. It terminates when the child component terminates. If no events are specified, the combinator waits for any event.

See Also:
AwaitOne

Nested Class Summary
protected  class AwaitAll.LocalListener
          A dedicated listener that forwards outgoing events to all external listeners.
 
Nested classes/interfaces inherited from class edu.luc.cs.trull.AbstractCombinator
AbstractCombinator.DefaultTerminationListener
 
Field Summary
private  java.beans.PropertyChangeListener action
          The action to be invoked as soon as all events have come in.
private  Done DONE
          An instance of Done to be used in various places.
private  boolean hasStartedBody
          This flag indicates whether the child has been started.
private  java.beans.PropertyChangeListener internalListener
          The listener to the child component.
private static org.apache.log4j.Logger logger
           
private  java.util.Set missingEvents
          The set of triggering events still missing.
private  java.util.Set startEvents
          The set of triggering events for starting this component.
private  TerminationListener terminationListener
          The child termination listener of this component.
 
Fields inherited from class edu.luc.cs.trull.AbstractCombinator
components
 
Constructor Summary
AwaitAll()
          Constructs an empty AwaitAll component that is triggered by any first incoming event.
AwaitAll(java.lang.String[] labels, Component body)
          AwaitAll(labels, null, body).
AwaitAll(java.lang.String[] labels, java.beans.PropertyChangeListener action)
          AwaitAll(labels, action, new Done())
AwaitAll(java.lang.String[] labels, java.beans.PropertyChangeListener action, Component body)
          Constructs an AwaitAll component that waits for all the given labels, executes the given action, and then starts the body.
 
Method Summary
 java.beans.PropertyChangeListener getAction()
          Returns the action for this component to be executed when all triggering events have occurred.
protected  TerminationListener getChildTerminationListener()
          Returns the internal listener that is notified if the child component terminates.
protected  Component getDefaultChild()
          This method returns the default child component.
 java.lang.String[] getEvents()
          Returns the triggering events for this component.
protected  java.beans.PropertyChangeListener getInternalListener()
          Returns the internal listener that listens to the child component.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method processes incoming events.
 void resume()
          Resumes this suspendable component.
 void setAction(java.beans.PropertyChangeListener action)
          Sets the action for this component to be executed when all triggering events have occurred.
 void setEvents(java.util.Collection evts)
          Sets the triggering events for this component.
 void setEvents(java.lang.String[] labels)
          Sets the triggering events for this component.
 void start(java.beans.PropertyChangeEvent incoming)
          Starts this startable component.
protected  void startBody(java.beans.PropertyChangeEvent incoming)
           
 void stop()
          Stops this startable component.
 void suspend()
          Suspends this suspendable component.
 
Methods inherited from class edu.luc.cs.trull.SingleChildCombinator
addComponent, getChild, removeComponent
 
Methods inherited from class edu.luc.cs.trull.AbstractCombinator
addComponent, addComponent, getComponent, getComponentCount, getComponents, removeAllComponents, removeComponent
 
Methods inherited from class edu.luc.cs.trull.AbstractComponent
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getExternalListeners, getPropertyChangeListeners, removePropertyChangeListener
 
Methods inherited from class edu.luc.cs.trull.TerminatingComponent
fireTermination, getParent, getTermEvent, scheduleTermination, setTerminationListener
 
Methods inherited from class edu.luc.cs.trull.EmptyComponent
getTerminationListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.luc.cs.trull.PropertyChangeSource
addPropertyChangeListener, getPropertyChangeListeners, removePropertyChangeListener
 
Methods inherited from interface edu.luc.cs.trull.Terminating
getTerminationListener, setTerminationListener
 

Field Detail

action

private java.beans.PropertyChangeListener action
The action to be invoked as soon as all events have come in.


DONE

private Done DONE
An instance of Done to be used in various places.


hasStartedBody

private boolean hasStartedBody
This flag indicates whether the child has been started.


internalListener

private java.beans.PropertyChangeListener internalListener
The listener to the child component.


logger

private static final org.apache.log4j.Logger logger

missingEvents

private java.util.Set missingEvents
The set of triggering events still missing.


startEvents

private java.util.Set startEvents
The set of triggering events for starting this component.


terminationListener

private TerminationListener terminationListener
The child termination listener of this component.

Constructor Detail

AwaitAll

public AwaitAll()
Constructs an empty AwaitAll component that is triggered by any first incoming event. Specific properties can be changed later.


AwaitAll

public AwaitAll(java.lang.String[] labels,
                Component body)
AwaitAll(labels, null, body).


AwaitAll

public AwaitAll(java.lang.String[] labels,
                java.beans.PropertyChangeListener action)
AwaitAll(labels, action, new Done())


AwaitAll

public AwaitAll(java.lang.String[] labels,
                java.beans.PropertyChangeListener action,
                Component body)
Constructs an AwaitAll component that waits for all the given labels, executes the given action, and then starts the body.

Parameters:
labels - an array of event labels to wait for.
action - the action to be executed when all specified events have occurred. May be null.
body - the component to be started after all specified events have occurred. If null, an empty component is used.
Method Detail

getAction

public java.beans.PropertyChangeListener getAction()
Returns the action for this component to be executed when all triggering events have occurred.

Returns:
the action for this component.

getChildTerminationListener

protected TerminationListener getChildTerminationListener()
Description copied from class: AbstractCombinator
Returns the internal listener that is notified if the child component terminates.

Specified by:
getChildTerminationListener in class AbstractCombinator
Returns:
the termination listener.

getDefaultChild

protected Component getDefaultChild()
Description copied from class: SingleChildCombinator
This method returns the default child component.

Specified by:
getDefaultChild in class SingleChildCombinator

getEvents

public java.lang.String[] getEvents()
Returns the triggering events for this component.

Returns:
an array containing the String event labels.

getInternalListener

protected java.beans.PropertyChangeListener getInternalListener()
Description copied from class: SingleChildCombinator
Returns the internal listener that listens to the child component.

Specified by:
getInternalListener in class SingleChildCombinator

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
This method processes incoming events. If the component has already been triggered, events are forwarded to the child component.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class SingleChildCombinator
Parameters:
evt - the event being received.

resume

public void resume()
Description copied from interface: Suspendable
Resumes this suspendable component.

Specified by:
resume in interface Suspendable
Overrides:
resume in class SingleChildCombinator

setAction

public void setAction(java.beans.PropertyChangeListener action)
Sets the action for this component to be executed when all triggering events have occurred.

Parameters:
action - the action for this component. May be null.

setEvents

public void setEvents(java.util.Collection evts)
Sets the triggering events for this component.

Parameters:
evts - a collection of String event labels.

setEvents

public void setEvents(java.lang.String[] labels)
Sets the triggering events for this component.

Parameters:
labels - an array of String event labels.

start

public void start(java.beans.PropertyChangeEvent incoming)
Description copied from interface: Startable
Starts this startable component.

Specified by:
start in interface Startable
Overrides:
start in class SingleChildCombinator
Parameters:
incoming - the event that triggered the invocation of this method. May be null.

startBody

protected void startBody(java.beans.PropertyChangeEvent incoming)

stop

public void stop()
Description copied from interface: Startable
Stops this startable component.

Specified by:
stop in interface Startable
Overrides:
stop in class SingleChildCombinator

suspend

public void suspend()
Description copied from interface: Suspendable
Suspends this suspendable component.

Specified by:
suspend in interface Suspendable
Overrides:
suspend in class SingleChildCombinator

Trull

http://www.cs.luc.edu/trull/