Interface DocumentBus

  • All Known Implementing Classes:
    DocumentBusImpl

    public interface DocumentBus
    The DocumentBus class combines the functionality of the QueryResolver, the ConstraintEnforcer, and the EventBus. All of their methods have been extended with conditions and automatic unsubscribing.
    See Also:
    EventMaid Documentation
    • Method Detail

      • answer

        <T extends Query<?>> AnswerStep1Builder<T> answer​(Class<T> queryClass)
        Entry point of the defining process, how and when to answer a Query.
        Type Parameters:
        T - the type of the Query
        Parameters:
        queryClass - the class of the Query to answer
        Returns:
        a builder to define further aspects of the answer
      • ensure

        <T> AnswerStep1Builder<T> ensure​(Class<T> constraintClass)
        Entry point of the defining process, how and when to enforce a constraint.
        Type Parameters:
        T - the type of the constraint
        Parameters:
        constraintClass - the class of the constraint to enforce
        Returns:
        a builder to define further aspects of the enforcement
      • reactTo

        <T> AnswerStep1Builder<T> reactTo​(Class<T> event)
        Entry point of the defining process, how an when to react to an event.
        Type Parameters:
        T - the type of the event
        Parameters:
        event - the class of the event to react to
        Returns:
        a builder to define further aspects of the reactin
      • query

        <T> Optional<T> query​(Query<T> query)
        Executes the Query.
        Type Parameters:
        T - the type of the Query
        Parameters:
        query - the Query to execute
        Returns:
        an Optional containing the result
      • queryRequired

        <T> T queryRequired​(Query<T> query)
        Executes the Query and expects a result.
        Type Parameters:
        T - the type of the Query
        Parameters:
        query - the Query to execute
        Returns:
        the result of the query
        Throws:
        UnsupportedOperationException - if no result could be obtained
      • enforce

        void enforce​(Object constraint)
        Enforces to given constraint.
        Parameters:
        constraint - the constraint to enforce
      • publish

        void publish​(Object event)
        Publishes the given event.
        Parameters:
        event - the event to publish
      • unsubscribe

        void unsubscribe​(SubscriptionId subscriptionId)
        Removes the subscription for the given SubscriptionId independent of whether it was for a Query, a constraint or an event.
        Parameters:
        subscriptionId - the SubscriptionId to remove