eu.semaine.components
Class Component

java.lang.Object
  extended by java.lang.Thread
      extended by eu.semaine.components.Component
All Implemented Interfaces:
SEMAINEMessageAvailableListener, java.lang.Runnable
Direct Known Subclasses:
AgentMentalStateInterpreter, DummyActionSelection, DummyAnalyser, DummyBMLActionProposer, DummyBMLRealiser, DummyBMLRealiserAndPlayer, DummyFeatureExtractor, DummyFML2BML, DummyFMLActionProposer, DummyInterpreter, DummyVisualFML2BML, EmotionInterpreter, FacialExpressionInterpreter, GenericTestComponent, MessageLogComponent, NonVerbalInterpreter, QueuingAudioPlayer, RandomUtteranceActionProposer, SemaineAudioPlayer, SpeechBMLRealiser, SpeechPreprocessor, SystemManager, TestGui, TTSInputComponent, TurnTakingInterpreter, UserPresenceInterpreter, UtteranceActionProposer, UtteranceInterpreter, UtterancePreparationTestComponent

public class Component
extends java.lang.Thread
implements SEMAINEMessageAvailableListener

The abstract base class for all components. Subclasses need to:

Author:
marc

Nested Class Summary
static class Component.State
          States of components that can be reported to the system meta component.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  java.util.concurrent.BlockingQueue<Receiver> inputWaiting
           
protected  boolean isInput
           
protected  boolean isOutput
           
protected  JMSLogger log
           
protected  MetaMessenger meta
           
protected  java.util.List<Receiver> receivers
           
protected  java.util.List<Sender> senders
           
protected  Component.State state
           
protected  int waitingTime
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected Component(java.lang.String componentName)
          Create a component with the given name.
protected Component(java.lang.String componentName, boolean isInput, boolean isOutput)
          Create a component with the given name.
protected Component(java.lang.String componentName, boolean isInput, boolean isOutput, java.lang.String jmsUrl, java.lang.String jmsUser, java.lang.String jmsPassword)
          Create a component with the given name.
protected Component(java.lang.String componentName, java.lang.String jmsUrl, java.lang.String jmsUser, java.lang.String jmsPassword)
          Create a component with the given name.
 
Method Summary
protected  void act()
          Proactive actions.
protected  void customStartIO()
          Any custom startup code can go here.
protected  boolean exitRequested()
           
 MetaMessenger getMeta()
          Provide access to this component's meta messenger, e.g. to query the component for its time.
protected  boolean hasSystemJustBecomeReady()
          Method that informs subclasses that the system has just become ready.
 void messageAvailableFrom(Receiver source)
          Method called from the corresponding receiver thread, to notify us that a message is available.
protected  void react(SEMAINEMessage message)
          Reactions to messages.
 void requestExit()
          Ask this component to exit as soon as possible.
 void run()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isInput

protected boolean isInput

isOutput

protected boolean isOutput

receivers

protected java.util.List<Receiver> receivers

senders

protected java.util.List<Sender> senders

inputWaiting

protected java.util.concurrent.BlockingQueue<Receiver> inputWaiting

log

protected JMSLogger log

state

protected Component.State state

meta

protected MetaMessenger meta

waitingTime

protected int waitingTime
Constructor Detail

Component

protected Component(java.lang.String componentName)
             throws JMSException
Create a component with the given name. The component is neither an input nor an output component, and communicates with the default JMS server (see IOBase.IOBase(String).

Parameters:
componentName - the component name as it is to be used throughout the system.
Throws:
JMSException - if the connection to the middleware cannot be established

Component

protected Component(java.lang.String componentName,
                    boolean isInput,
                    boolean isOutput)
             throws JMSException
Create a component with the given name. The component communicates with the default JMS server (see IOBase.IOBase(String).

Parameters:
componentName - the component name as it is to be used throughout the system.
isInput - whether the component is an input component
isOutput - whether the component is an output component
Throws:
JMSException - if the connection to the middleware cannot be established

Component

protected Component(java.lang.String componentName,
                    java.lang.String jmsUrl,
                    java.lang.String jmsUser,
                    java.lang.String jmsPassword)
             throws JMSException
Create a component with the given name. The component is neither an input nor an output component, and communicates with the JMS server given in the arguments.

Parameters:
componentName - the component name as it is to be used throughout the system.
jmsUrl - the url where to contact the JMS server
jmsUser - the username to use (can be null)
jmsPassword - the password to use (can be null)
Throws:
JMSException - if the connection to the middleware cannot be established

Component

protected Component(java.lang.String componentName,
                    boolean isInput,
                    boolean isOutput,
                    java.lang.String jmsUrl,
                    java.lang.String jmsUser,
                    java.lang.String jmsPassword)
             throws JMSException
Create a component with the given name. The component communicates with the JMS server given in the arguments.

Parameters:
componentName - the component name as it is to be used throughout the system.
isInput - whether the component is an input component
isOutput - whether the component is an output component
jmsUrl - the url where to contact the JMS server
jmsUser - the username to use (can be null)
jmsPassword - the password to use (can be null)
Throws:
JMSException - if the connection to the middleware cannot be established
Method Detail

getMeta

public MetaMessenger getMeta()
Provide access to this component's meta messenger, e.g. to query the component for its time.

Returns:
the meta messenger used by this component.

messageAvailableFrom

public void messageAvailableFrom(Receiver source)
Method called from the corresponding receiver thread, to notify us that a message is available.

Specified by:
messageAvailableFrom in interface SEMAINEMessageAvailableListener
Parameters:
source - the receiver that has a message available.

customStartIO

protected void customStartIO()
                      throws java.lang.Exception
Any custom startup code can go here.

Throws:
java.lang.Exception - if anything goes wrong in the internal processing of the component.

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

exitRequested

protected boolean exitRequested()

requestExit

public void requestExit()
Ask this component to exit as soon as possible.


hasSystemJustBecomeReady

protected boolean hasSystemJustBecomeReady()
Method that informs subclasses that the system has just become ready. This is true the first time act() is called after the system has become ready, and false otherwise. The recommended place to check this, if necessary, is therefore act().

Returns:
true if the system has just become ready, and false otherwise.

act

protected void act()
            throws java.lang.Exception
Proactive actions. This method is called every waitingTime milliseconds if no messages arrive, and after every message processing. This base implementation does nothing; subclasses should implement suitable behaviour here.

Throws:
JMSException - if communication with the JMS server goes wrong.
java.lang.Exception - if anything goes wrong in the internal processing of the component.

react

protected void react(SEMAINEMessage message)
              throws java.lang.Exception
Reactions to messages. This base implementation does nothing; subclasses should implement suitable behaviour here.

Throws:
JMSException - if communication with the JMS server goes wrong.
java.lang.Exception - if anything goes wrong in the internal processing of the component.