se.ericsson.eto.norarc.javaframe
Class Router

java.lang.Object
  extended byse.ericsson.eto.norarc.javaframe.ActiveObject
      extended byse.ericsson.eto.norarc.javaframe.StateMachine
          extended byse.ericsson.eto.norarc.javaframe.Router
All Implemented Interfaces:
Addressable, java.io.Serializable

public class Router
extends StateMachine

A Router is a special StateMachine that performs routing of Messages to one in a list of Mediators.

See Also:
Serialized Form

Field Summary
 java.util.LinkedList mediatorList
           
 
Fields inherited from class se.ericsson.eto.norarc.javaframe.StateMachine
currentMessage, currentState, inSchedulerList, messageBox, myScheduler, nextFSM, saveQueue, wantedScheduler
 
Fields inherited from class se.ericsson.eto.norarc.javaframe.ActiveObject
activeObjectName, owner
 
Constructor Summary
Router(Scheduler sched)
          Associates this Router with the given Scheduler.
 
Method Summary
 void addAddress(Addressable newMediator)
          Adds a Mediator to the list of routing targets.
protected  void exec(Message sig)
          The execution utility called by the scheduling process.
protected  void execRouterTrans(Message sig)
          Normally the Router has only a single transition executed.
protected  void execStartTransition()
          Default execStartTransition is empty.
 Mediator getAddress()
          Overriding the general method by simply taking the first Mediator of the list
protected  void output(Message sig, Mediator receiver)
          Outputs sig to the receiver.
 
Methods inherited from class se.ericsson.eto.norarc.javaframe.StateMachine
forward, getCurrentMessage, getCurrentState, getScheduler, init, moveStateMachine, restart
 
Methods inherited from class se.ericsson.eto.norarc.javaframe.ActiveObject
activeObjectName, setActiveObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mediatorList

public java.util.LinkedList mediatorList
Constructor Detail

Router

public Router(Scheduler sched)
Associates this Router with the given Scheduler.

Method Detail

addAddress

public void addAddress(Addressable newMediator)
                throws java.lang.IllegalArgumentException
Adds a Mediator to the list of routing targets.

Parameters:
newMediator - Assumed to be not null. If not, an IllegalArgumentException is thrown.
Throws:
java.lang.IllegalArgumentException

getAddress

public Mediator getAddress()
Overriding the general method by simply taking the first Mediator of the list


execRouterTrans

protected void execRouterTrans(Message sig)
Normally the Router has only a single transition executed. The default behavior is to forward the incoming message to the first address


output

protected void output(Message sig,
                      Mediator receiver)
Outputs sig to the receiver. To be used within overridden execRouterTrans.

Parameters:
sig - the Message that will be routed on
receiver - the Mediator that will receive the sig

exec

protected void exec(Message sig)
The execution utility called by the scheduling process. exec may be overridden with extreme care! to have it as a "normal" StateMachine exchange with currentState.exec(sig, this);

Overrides:
exec in class StateMachine
Parameters:
sig - Invariant: sig != null

execStartTransition

protected void execStartTransition()
Default execStartTransition is empty.

Specified by:
execStartTransition in class StateMachine