Annotation Interface Handler
AnnotatedCommandHandler or AnnotatedEventHandler.Depending on which class you extend the rules that apply to each method may be different.
Common for all is that the method accessibility can be any combination of private, protected, public, etc.
AnnotatedCommandHandler
Rules when applied to single argument method inside AnnotatedCommandHandler
Each annotated method will be a candidate for command message handling.
The single method argument type is matched against the concrete command type using Class.isAssignableFrom(Class).
The method MAY return a value or void.
public class OrdersCommandHandler extends AnnotatedCommandHandler {
@Handler
private OrderId handle(CreateOrder cmd) {
...
}
@Handler
private void someMethod(ReimburseOrder cmd) {
...
}
}
AnnotatedEventHandler
Rules when applied to single argument method inside AnnotatedEventHandler
Each annotated method will be a candidate for event message handling.
Each method must accept a single Event argument, return void and be annotated with the EventHandler annotation.
The method argument type is matched against the concrete event type using Class.isAssignableFrom(Class).
The method MUST return void.
public class OrderEventsHandler extends AnnotatedEventHandler {
@Handler
void handle(OrderCreated event) {
}
@Handler
void handle(OrderCancelled event) {
}
}