org.d_haven.event.command

Class CommandEventHandler

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
CommandEventPipelinem_eventPipeline
CommandFailureHandlerm_failureHandler
SwitchedEnqueuePredicatem_predicate
Constructor Summary
CommandEventHandler(CommandFailureHandler failureHandler, SwitchedEnqueuePredicate predicate)
Create the CommandEventHandler with the failure handler and the predicate provided.
Method Summary
voidcheckPipelineProvided()
CommandFailureHandlergetCommandFailureHandler()
Get the CommandFailureHandler in use for this event handler.
voidhandleEvent(Object element)
voidsetCommandEventPipeline(CommandEventPipeline pipeline)
Provide the CommandEventPipeline to use for requeueing delayed and repeating commands.
voidsetCommandFailureHandler(CommandFailureHandler handler)
Set the CommandFailureHandler to use with this event handler.
booleantimeToRequeue(DefaultCommandManager.DelayedCommandInfo info)
StringtoString()
Provide a debug string for this class.

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

checkPipelineProvided

private void checkPipelineProvided()

getCommandFailureHandler

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

Returns: the failure handler

handleEvent

public void handleEvent(Object element)

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

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

timeToRequeue

private boolean timeToRequeue(DefaultCommandManager.DelayedCommandInfo info)

toString

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

Returns: the debug string