When an adapter injects each use case directly, its dependencies grow and changes to use cases ripple through its wiring. A command handler owns one write use case; an adapter can send its command through a command bus without knowing which handler executes it. section 4.5 section 4.6.1
The handler contract accepts a command and returns Either<E, Void>. A write handler coordinates loading an aggregate, invoking domain behavior, and persisting state; it does not share a handler with a query path. section 4.5.2 section 4.6.1
Listing 4.12 CommandHandler from the Architecture Kernel
public interface CommandHandler<E, C extends Command> #A Either<E, Void> handle(final C command); #B }
The interface captures the handler’s command input and result contract. section 4.5.2
In Spring, the command bus can discover handler beans through the application context. A handler can also remain directly injectable; bus routing adds an option rather than replacing that path. A transaction can group the write use case so failure rolls back state and success commits it. section 4.5.2 section 4.5.3 section 6.3.5
