org.d_haven.event.command
Class CommandEventHandler

java.lang.Object
  extended by org.d_haven.event.impl.AbstractEventHandler
      extended by org.d_haven.event.command.CommandEventHandler
All Implemented Interfaces:
EventHandler

public final class CommandEventHandler
extends AbstractEventHandler

The CommandEventHandler is used by the DefaultCommandManager to actually process the events. It is from this location that we run the commands and reschedule them as needed.


Field Summary
private  CommandEventPipeline m_eventPipeline
           
private  CommandFailureHandler m_failureHandler
           
private  SwitchedEnqueuePredicate m_predicate
           
 
Constructor Summary
CommandEventHandler(CommandFailureHandler failureHandler, SwitchedEnqueuePredicate predicate)
          Create the CommandEventHandler with the failure handler and the predicate provided.
 
Method Summary
private  void checkPipelineProvided()
           
 CommandFailureHandler getCommandFailureHandler()
          Get the CommandFailureHandler in use for this event handler.
 void handleEvent(java.lang.Object element)
          Handle one event at a time.
 void setCommandEventPipeline(CommandEventPipeline pipeline)
          Provide the CommandEventPipeline to use for requeueing delayed and repeating commands.
 void setCommandFailureHandler(CommandFailureHandler handler)
          Set the CommandFailureHandler to use with this event handler.
private  boolean timeToRequeue(DefaultCommandManager.DelayedCommandInfo info)
           
 java.lang.String toString()
          Provide a debug string for this class.
 
Methods inherited from class org.d_haven.event.impl.AbstractEventHandler
handleEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_eventPipeline

private CommandEventPipeline m_eventPipeline

m_failureHandler

private CommandFailureHandler m_failureHandler

m_predicate

private final SwitchedEnqueuePredicate m_predicate
Constructor Detail

CommandEventHandler

public CommandEventHandler(CommandFailureHandler failureHandler,
                           SwitchedEnqueuePredicate predicate)
Create the CommandEventHandler with the failure handler and the predicate provided.

Parameters:
failureHandler - The CommandFailureHandler used when a command fails
predicate - The predicate used to determine if we are accepting new commands
Method Detail

setCommandEventPipeline

public void setCommandEventPipeline(CommandEventPipeline pipeline)
Provide the CommandEventPipeline to use for requeueing delayed and repeating commands. This method must be called prior to handling any events.

Parameters:
pipeline - The pipeline to use for processing

handleEvent

public void handleEvent(java.lang.Object element)
Description copied from interface: EventHandler
Handle one event at a time.

Parameters:
element - The element that the EventHandler must process

checkPipelineProvided

private void checkPipelineProvided()

timeToRequeue

private boolean timeToRequeue(DefaultCommandManager.DelayedCommandInfo info)
                       throws SinkException
Throws:
SinkException

toString

public java.lang.String toString()
Provide a debug string for this class.

Overrides:
toString in class java.lang.Object
Returns:
the debug string

getCommandFailureHandler

public CommandFailureHandler getCommandFailureHandler()
Get the CommandFailureHandler in use for this event handler.

Returns:
the failure handler

setCommandFailureHandler

public void setCommandFailureHandler(CommandFailureHandler handler)
Set the CommandFailureHandler to use with this event handler. It is assumed that the CommandManager has already checked for null values before setting this command failure handler.

Parameters:
handler - the new handler