Module org.refcodes.command
Package org.refcodes.command
This package provides means to implement your custom commands as of the
command pattern:
"... (in) the command pattern ... an object is used to represent and encapsulate all the information needed to call a method at a later time. This ... includes the ... method parameters ..." [Command pattern, see http://en.wikipedia.org/wiki/Command_pattern (Wikipedia)]
A command can be seen as a method and its context (variables1) all transformed to an object (e.g a method turned inside out).
Given you define a command's interface with an “execute” and an “undo” method and you strictly make use of commands: Then you easily can provide undo functionality by putting your executed commands onto a stack ...
Command:
ACommand
(respectively an
Undoable
) represents an (atomic) operation
applied to a context encapsulated in an object (as of object oriented
programming). Usually a command (Undoable
) also
provides means to undo its operation applied before. The
Command
(Undoable
)
is created by a client (e.g. the business logic) and passed e.g. to a command
bus for execution (or executed "manually" at required / desired time). (a
command bus implementation you can find in the "refcodes-jobbus
"
artifact, see org.refcodes.jobbus.JobBus
).
Client:
The client may be the business logic creating aUndoable
(job) to be executed.
Context:
The context can be a service, a service-bus (providing a handful of services), a component or a plain POJO (this depends on your requirements and your implementation).-
Interface Summary Interface Description Command<CTX,RET,E extends Exception> CommandAccessor<CTX,R,E extends Exception> Provides an accessor for a command property.CommandAccessor.CommandBuilder<CTX,R,E extends Exception,B extends CommandAccessor.CommandBuilder<CTX,R,E,B>> Provides a builder method for a name property returning the builder for applying multiple build operations.CommandAccessor.CommandMutator<CTX,R,E extends Exception> Provides a mutator for a command property.CommandAccessor.CommandProperty<CTX,R,E extends Exception> Provides a command property.Undoable<CTX,RET,E extends Exception> UndoableAccessor<CTX,R,E extends Exception> Provides an accessor for a command property.UndoableAccessor.UndoableBuilder<CTX,R,E extends Exception,B extends UndoableAccessor.UndoableBuilder<CTX,R,E,B>> Provides a builder method for a name property returning the builder for applying multiple build operations.UndoableAccessor.UndoableMutator<CTX,R,E extends Exception> Provides a mutator for a undoable property.UndoableAccessor.UndoableProperty<CTX,R,E extends Exception> Provides a undoable property.Worker<CTX,E extends Exception> WorkerAccessor<CTX,E extends Exception> Provides an accessor for a command property.WorkerAccessor.WorkerBuilder<CTX,E extends Exception,B extends WorkerAccessor.WorkerBuilder<CTX,E,B>> Provides a builder method for a name property returning the builder for applying multiple build operations.WorkerAccessor.WorkerMutator<CTX,E extends Exception> Provides a mutator for a worker property.WorkerAccessor.WorkerProperty<CTX,E extends Exception> Provides a worker property. -
Class Summary Class Description AbstractCommand<CTX,RET,E extends Exception> TheAbstractCommand
implements theUndoable
interface.AbstractUndoable<CTX,RET,E extends Exception> TheAbstractUndoable
implements theUndoable
interface. -
Exception Summary Exception Description CommandRuntimeException The Class CommandRuntimeException.NoExceptionAvailableRuntimeException The Class NoExceptionAvailableRuntimeException.NoResultAvailableRuntimeException The Class NoResultAvailableRuntimeException.NotUndoableRuntimeException The Class NotUndoableRuntimeException.NotYetExecutedRuntimeException The Class NotYetExecutedRuntimeException.