Package org.refcodes.command
Interface Command<CTX,RET,E extends java.lang.Exception>
-
- Type Parameters:
CTX
- The context type to use, can by anyComponent
, service or POJO.RET
- The return type of theCommand
's proceedings.E
- The exception type of theCommand
's erroneous termination.
- All Known Subinterfaces:
Undoable<CTX,RET,E>
- All Known Implementing Classes:
AbstractCommand
,AbstractUndoable
- 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>
ACommand
(Command
) represents an (atomic) operation applied to a context returning a result encapsulated in an object (as of object oriented programming). AnUndoable
is a command which provides means to undo its operation applied before. TheCommand
is created by a client (e.g. the business logic) and passed to something like a command-bus or command-processor for execution.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RET
execute(CTX aContext)
The invoker executes aCommand
by providing it a context (being a service, aComponent
or a POJO).
-
-
-
Method Detail
-
execute
RET execute(CTX aContext) throws E extends java.lang.Exception
The invoker executes aCommand
by providing it a context (being a service, aComponent
or a POJO). The method works synchronously and waits (blocks the caller's thread) till a result is available.- Parameters:
aContext
- The target object (being a service, aComponent
or a POJO) which is used by theCommand
to perform its (atomic) operation.- Returns:
- The result of this
Command
after execution or Void in case thisCommand
does not process a result. - Throws:
E
- the eE extends java.lang.Exception
-
-