public class EfferentCommandHandler extends java.lang.Object implements IEfferentCommandListener
IEfferentCommand
s. After instantiating a
sensor, this can be attached to the IEfferentCommandManager
by using
the constructor and providing the appropriate Executor
. IEfferentCommand
s. To change this
behavior override any of the shouldXXXX methods. If you overload the actual
state change methods, be sure to call the super method as well as it
invariably sets specific state variables in the IEfferentCommand
. At
the termination of a command's run be sure to call the
completed(IEfferentCommand, Object)
or
aborted(IEfferentCommand, Object)
methods.Executor
to be InlineExecutor.get()
.Constructor and Description |
---|
EfferentCommandHandler(ISensor sensor) |
Modifier and Type | Method and Description |
---|---|
protected void |
abort(DeltaTracker<IMutableObject> efferentCommand)
when a command is abort, this is called.
|
void |
aborted(IEfferentCommand command,
java.lang.Object extraInfo)
called when a command is aborted on the sensor side (not at the request of
the agent).
|
protected void |
accept(DeltaTracker<IMutableObject> efferentCommand)
when a command is accepted, this is called.
|
void |
add(ICommandHandlerDelegate delegate) |
void |
completed(IEfferentCommand command,
java.lang.Object extraInfo)
called upon the completion of a command
|
java.util.Collection<ICommandHandlerDelegate> |
getDelegates() |
ISensor |
getSensor() |
void |
objectsAdded(IObjectEvent<IEfferentCommand,?> addEvent) |
void |
objectsRemoved(IObjectEvent<IEfferentCommand,?> removeEvent) |
void |
objectsUpdated(IObjectEvent<IEfferentCommand,?> updateEvent) |
void |
processNewEfferentCommand(IEfferentCommand command)
process a new efferent command, checking
shouldAccept(IEfferentCommand) and either
accept(DeltaTracker) or #reject(DeltaTracker) |
protected void |
reject(DeltaTracker<IMutableObject> efferentCommand,
java.lang.Object details)
when a command is rejected, this is called.
|
void |
remove(ICommandHandlerDelegate delegate) |
protected boolean |
shouldAbort(IEfferentCommand command)
check the command and be sure that it can be aborted.
|
protected java.lang.Object |
shouldAccept(IEfferentCommand command)
return true if this command should be accepted (state changed from
submitted to accepted).
Default impl preforms some security and consistency checks. |
protected java.lang.Object |
shouldStart(IEfferentCommand command)
check the command and be sure that it can be started.
|
protected void |
start(DeltaTracker<IMutableObject> efferentCommand)
when a command is started, this is called.
|
public EfferentCommandHandler(ISensor sensor)
public java.util.Collection<ICommandHandlerDelegate> getDelegates()
public void add(ICommandHandlerDelegate delegate)
public void remove(ICommandHandlerDelegate delegate)
public ISensor getSensor()
public void objectsAdded(IObjectEvent<IEfferentCommand,?> addEvent)
objectsAdded
in interface IObjectListener<IEfferentCommand>
public void objectsRemoved(IObjectEvent<IEfferentCommand,?> removeEvent)
objectsRemoved
in interface IObjectListener<IEfferentCommand>
public void objectsUpdated(IObjectEvent<IEfferentCommand,?> updateEvent)
objectsUpdated
in interface IObjectListener<IEfferentCommand>
public void processNewEfferentCommand(IEfferentCommand command)
shouldAccept(IEfferentCommand)
and either
accept(DeltaTracker)
or #reject(DeltaTracker)
command
- protected java.lang.Object shouldAccept(IEfferentCommand command)
IEfferentCommandTemplate
associated with the IEfferentObject
is consistent with the
IEfferentCommand
command
- protected void accept(DeltaTracker<IMutableObject> efferentCommand)
efferentCommand
- delta tracker that wraps the efferent commandprotected void reject(DeltaTracker<IMutableObject> efferentCommand, java.lang.Object details)
efferentCommand
- delta tracker that wraps the efferent commandprotected java.lang.Object shouldStart(IEfferentCommand command)
command
- protected void start(DeltaTracker<IMutableObject> efferentCommand)
efferentCommand
- delta tracker that wraps the efferent commandprotected boolean shouldAbort(IEfferentCommand command)
command
- protected void abort(DeltaTracker<IMutableObject> efferentCommand)
efferentCommand
- delta tracker that wraps the efferent commandpublic void aborted(IEfferentCommand command, java.lang.Object extraInfo)
command
- extraInfo
- will be stored under IEfferentCommand.RESULT
public void completed(IEfferentCommand command, java.lang.Object extraInfo)
command
- extraInfo
-