What is the correct means to inject Spring beans into my Aggregate @EventSourcedHandler methods? I am aware of the registerParameterResolverFactory method on the aggregate but am not sure when & how to register the SpringBeanParameterResolver.
@CommandHandler methods are injected successfully & are configured via AnnotationCommandHandlerFactoryBean.
My aggregate @EventSourcedHandler methods are not called on applying events within a @CommandHandler.
I am injecting Spring Beans into all @CommandHandler & @EventSourcedHandler methods.
how did you define the EventSourcingRepository in the Spring context? If
you use the namespace support (axon:event-sourcing-repository), it defaults
to a parameter resolver factory that also looks at Spring beans. However, a
Spring bean is only eligible for autowiring if only a single bean of the
specified type is available. Otherwise, another parameter resolver should
provide a value.
Regarding the code generation, I'm not totally convinced that using
separate "EventHandler"s and "ValidationSpec"s are really going to make
aggregate design fundamentally easier. One will end up with many more
classes, that unless they are completely generated and maintained from some
UI, will complicate things more than they simplify. One of the situations,
for example is where a single command generates multiple events in between,
where subsequent events depend on the state after the first is applied. I
don't see how the current design/implementation could handle these events.
Maybe it's just my reluctance when it comes to code generation.
Thanks for your feedback on the implementation, I will take all points into consideration. The end goal is to have the aggregate designed in a UI & be flexible, we’ll see if that is achievable For now it’s more of a scaffolding tool for axon apps.
Any feedback on the @EventSourcingHandler issue would be appreciated.
once AXON-265 is fixed, that will definitely be possible. If you don’t use the (xml) namespace support, there is a littlebit of configuration you need to add. As soon as the fix is done, I will let you know what that is.