akka.io
Class AbstractPipePair<CmdAbove,CmdBelow,EvtAbove,EvtBelow>

java.lang.Object
  extended by akka.io.AbstractPipePair<CmdAbove,CmdBelow,EvtAbove,EvtBelow>
Direct Known Subclasses:
AbstractSymmetricPipePair

public abstract class AbstractPipePair<CmdAbove,CmdBelow,EvtAbove,EvtBelow>
extends java.lang.Object

Java API: A pair of pipes, one for commands and one for events. Commands travel from top to bottom, events from bottom to top.

See Also:
PipelineStage, AbstractSymmetricPipePair, PipePairFactory

Constructor Summary
AbstractPipePair()
           
 
Method Summary
<Cmd,Evt> java.lang.Iterable<scala.util.Either<Evt,Cmd>>
dealias(java.lang.Iterable<scala.util.Either<Evt,Cmd>> msg)
          INTERNAL API: Dealias a possibly optimized return value such that it can be safely used; this is never needed when only using public API.
 scala.util.Either<EvtAbove,CmdBelow> makeCommand(CmdBelow cmd)
          Helper method for wrapping a command which shall be emitted.
 scala.util.Either<EvtAbove,CmdBelow> makeEvent(EvtAbove event)
          Helper method for wrapping an event which shall be emitted.
abstract  java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> onCommand(CmdAbove cmd)
          Commands reaching this pipe pair are transformed into a sequence of commands for the next or events for the previous stage.
abstract  java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> onEvent(EvtBelow event)
          Events reaching this pipe pair are transformed into a sequence of commands for the next or events for the previous stage.
 java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> onManagementCommand(java.lang.Object cmd)
          Management commands are sent to all stages in a broadcast fashion, conceptually in parallel (but not actually executing a stage reentrantly in case of events or commands being generated in response to a management command).
 java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> singleCommand(CmdBelow cmd)
          Wrap a single command for efficient return to the pipeline’s machinery.
 java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> singleEvent(EvtAbove evt)
          Wrap a single event for efficient return to the pipeline’s machinery.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPipePair

public AbstractPipePair()
Method Detail

onCommand

public abstract java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> onCommand(CmdAbove cmd)
Commands reaching this pipe pair are transformed into a sequence of commands for the next or events for the previous stage.

Throwing exceptions within this method will abort processing of the whole pipeline which this pipe pair is part of.

Parameters:
cmd - the incoming command
Returns:
an Iterable of elements which are either events or commands

See Also:
makeCommand(CmdBelow), makeEvent(EvtAbove)

onEvent

public abstract java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> onEvent(EvtBelow event)
Events reaching this pipe pair are transformed into a sequence of commands for the next or events for the previous stage.

Throwing exceptions within this method will abort processing of the whole pipeline which this pipe pair is part of.

Parameters:
cmd - the incoming command
Returns:
an Iterable of elements which are either events or commands

See Also:
makeCommand(CmdBelow), makeEvent(EvtAbove)

onManagementCommand

public java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> onManagementCommand(java.lang.Object cmd)
Management commands are sent to all stages in a broadcast fashion, conceptually in parallel (but not actually executing a stage reentrantly in case of events or commands being generated in response to a management command).


makeCommand

public scala.util.Either<EvtAbove,CmdBelow> makeCommand(CmdBelow cmd)
Helper method for wrapping a command which shall be emitted.


makeEvent

public scala.util.Either<EvtAbove,CmdBelow> makeEvent(EvtAbove event)
Helper method for wrapping an event which shall be emitted.


singleCommand

public java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> singleCommand(CmdBelow cmd)
Wrap a single command for efficient return to the pipeline’s machinery. This method avoids allocating a Right and an Iterable by reusing one such instance within the AbstractPipePair, hence it can be used ONLY ONCE by each pipeline stage. Prototypic and safe usage looks like this:


 final MyResult result = ... ;
 return singleCommand(result);
 

See Also:
PipelineContext.singleCommand(Cmd)

singleEvent

public java.lang.Iterable<scala.util.Either<EvtAbove,CmdBelow>> singleEvent(EvtAbove evt)
Wrap a single event for efficient return to the pipeline’s machinery. This method avoids allocating a Left and an Iterable by reusing one such instance within the AbstractPipePair, hence it can be used ONLY ONCE by each pipeline stage. Prototypic and safe usage looks like this:


 final MyResult result = ... ;
 return singleEvent(result);
 

See Also:
PipelineContext.singleEvent(Evt)

dealias

public <Cmd,Evt> java.lang.Iterable<scala.util.Either<Evt,Cmd>> dealias(java.lang.Iterable<scala.util.Either<Evt,Cmd>> msg)
INTERNAL API: Dealias a possibly optimized return value such that it can be safely used; this is never needed when only using public API.