Interface Worker<CTX,E extends java.lang.Exception>

  • Type Parameters:
    CTX - The context type to use, can by any Component, service or POJO.
    E - The exception type of the Worker's erroneous termination.
    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 Worker<CTX,E extends java.lang.Exception>
    A Worker represents an (atomic) operation applied to a context and (in contrast to a Command) not returning any result, all of which encapsulated in an object (as of object oriented programming). A Worker is created by a client (e.g. the business logic) and passed to something like a command-bus or command-processor for execution.
    • Method Detail

      • execute

        void execute​(CTX aContext)
              throws E extends java.lang.Exception
        The invoker executes a Worker by providing it a context (being a service, a Component or a POJO). The method works synchronously and waits (blocks the caller's thread) till it is finished.
        Parameters:
        aContext - The target object (being a service, a Component or a POJO) which is used by the Worker to perform its (atomic) operation.
        Throws:
        E - the e
        E extends java.lang.Exception