Interface Command<CTX,RET,E extends java.lang.Exception>
- Type Parameters:
CTX- The context type to use, can by any
Component, service or POJO.
RET- The return type of the
E- The exception type of the
Command's erroneous termination.
- All Known Subinterfaces:
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Command<CTX,RET,E extends java.lang.Exception>A
Command) represents an (atomic) operation applied to a context returning a result encapsulated in an object (as of object oriented programming). An
Undoableis a command which provides means to undo its operation applied before. The
Commandis created by a client (e.g. the business logic) and passed to something like a command-bus or command-processor for execution.
executeThe invoker executes a
Commandby providing it a context (being a service, a
Componentor a POJO). The method works synchronously and waits (blocks the caller's thread) till a result is available.
aContext- The target object (being a service, a
Componentor a POJO) which is used by the
Commandto perform its (atomic) operation.
- The result of this
Commandafter execution or Void in case this
Commanddoes not process a result.
E- the e
E extends java.lang.Exception