Add pre-execution checks with CommandHandlerExecutor to CommandHandler #242

Merged
lars.winzer merged 12 commits from feat/57-pre-execution-checks-for-commandhandler into main 2026-04-08 18:58:21 +02:00
Showing only changes of commit eb2a679868 - Show all commits
@@ -159,6 +159,9 @@ public class GreetHandler implements CommandHandler<GreetRequest> {
**Rules for the Handler class:**
- Declare all dependencies as `private final` fields, injected through the constructor.
- Use `addCheck(...)` to attach pre-execution checks that should run before `execute(...)`.
- If several handlers share the same trivial logic, such as verifying that the user is logged in,
extract that logic into a separate `HandlerCheck` and reuse it instead of duplicating the code.
- Always dispatch exactly one response per execution path. Every branch must end with a
`responseDispatcher.dispatch(...)` call.
- Use `ErrorResponse` for domain-level failures (e.g. entity not found, precondition not met).