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.
Cheers,
Roscoe
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Allard,Thanks for your response I look forward to your feedback.Here is a heads up on what I am attempting, your input would be appreciated:I am writing a tool to generate domain model code, including Commands, Events & ARs.It is still in a foundation phase at the moment & consists of a JSON model definition that generates AXON code.The JSON file:{"apiPackage" : "com.zailab.user.domain.model.user.api.","aggregateRoot" : "User","aggregateIdentifier" : "UserId","commands" : [{"name" : "RegisterUser","constructorCommandHandler" : "true","properties" : ["userId", "username", "password", "confirmPassword", "email", "firstName", "surname"],"appliedEvents" :[{"name" : "UserRegistered","properties" : ["userId", "username", "password", "email", "firstName", "surname"]}]}]}This results in the Commands, Event & AR code. The commands handler methods are of the format:@CommandHandlerpublic User(RegisterUserCommand registerUserCommand, RegisterUserValidationSpec commandValidationSpec) {if (commandValidationSpec.isSatisfiedBy(registerUserCommand)) {apply(new UserRegisteredEvent(registerUserCommand.getUserId(), registerUserCommand.getUsername(), registerUserCommand.getPassword(), registerUserCommand.getEmail(), registerUserCommand.getFirstName(), registerUserCommand.getSurname()));} else {throw new ValidationException(("Could not process "+ registerUserCommand));}}The validation spec is injected at runtime & is a @Component implementation of the RegisterUserValidationSpec, therefore decoupling validation code from the AR. This works perfectly via the AggregateAnnotationCommandHandlerFactoryBean.I would like to do the same for aggregate event handler methods, and inject a event handler like:@EventSourcingHandlerpublic void handle(UserRegisteredEvent event, UserRegisteredEventHandler eventHandler) {eventHandler.handle(event, this);}The eventHandler would also be injected at runtime via a @Component implementation, thereby decoupling the event handling code from the AR as well.Entities & AR properties could then be manipulated in the eventHandler.The domain model could then be constantly scaffolded/regenerated from the model definition in the JSON file without overwriting command & event handling implementations.I would like to eventually add a UI to assist with modelling the domain & store the definition in a DB.Your thoughts on my attempt would be greatly appreciated.Regards,Roscoe Lotriet
--