Several business rules tend not to be a part of the main flow of a certain compenent, but rather policies or rules enforced by components on side. This is already supported by Axon by command interceptors but to not have edit the spring config of the command bus for every such component added, we created an IntercepterRegistry which in itself is a CommandInterceptor that other interceptor may register with. Since an interceptor might want to intercept several types of commands we also added annotation support, much like the @EventHandler annotation for event handlers.
This makes it possible a component plugged in to the main spring context to get a hold of the InterceptorRegistry, register itself and then intercept the commands that are handled by its @CommandInterceptor annotated-methods. Wouldn’t it be even cooler if this support was build in to Axon? : ) So that you only had to worry about annotating your interceptors…
Any thought on this?
If you would be interested in incorporating it into Axon I would be glad to give it a shot.