Interface DocumentBus
-
- All Known Implementing Classes:
DocumentBusImpl
public interface DocumentBusTheDocumentBusclass combines the functionality of theQueryResolver, theConstraintEnforcer, and theEventBus. All of their methods have been extended with conditions and automatic unsubscribing.- See Also:
- EventMaid Documentation
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends Query<?>>
AnswerStep1Builder<T>answer(Class<T> queryClass)Entry point of the defining process, how and when to answer aQuery.voidenforce(Object constraint)Enforces to given constraint.<T> AnswerStep1Builder<T>ensure(Class<T> constraintClass)Entry point of the defining process, how and when to enforce a constraint.voidpublish(Object event)Publishes the given event.<T> Optional<T>query(Query<T> query)Executes theQuery.<T> TqueryRequired(Query<T> query)Executes theQueryand expects a result.<T> AnswerStep1Builder<T>reactTo(Class<T> event)Entry point of the defining process, how an when to react to an event.voidunsubscribe(SubscriptionId subscriptionId)Removes the subscription for the givenSubscriptionIdindependent of whether it was for aQuery, a constraint or an event.
-
-
-
Method Detail
-
answer
<T extends Query<?>> AnswerStep1Builder<T> answer(Class<T> queryClass)
Entry point of the defining process, how and when to answer aQuery.- Type Parameters:
T- the type of theQuery- Parameters:
queryClass- the class of theQueryto 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 theQuery.- Type Parameters:
T- the type of theQuery- Parameters:
query- theQueryto execute- Returns:
- an
Optionalcontaining the result
-
queryRequired
<T> T queryRequired(Query<T> query)
Executes theQueryand expects a result.- Type Parameters:
T- the type of theQuery- Parameters:
query- theQueryto 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 givenSubscriptionIdindependent of whether it was for aQuery, a constraint or an event.- Parameters:
subscriptionId- theSubscriptionIdto remove
-
-