Does SpringResourceInjector support constructor injection?

I have the impression that *org.axonframework.spring.saga.*SpringResourceInjector does not support Saga constructor injection, is that right? Personally I prefer to declare all dependencies as constructor arguments. When I do this however and annotate the constructor with @Autowired, the Axon framework complains it can’t find the no-args constructor for my Saga.

This works fine when I annotate the field itself with @Autowired and provide a default no-args constructor.

Are there any plans to support constructor injection for Sagas?

Hi Patrick,

that’s correct. Axon’s injection mechanism isn’t as sophisticated as Spring’s.

There is a plan to better integrate with Spring and have Spring create instances of Sagas instead of using the no-arg constructor. That will allow you to use constructor injection. However, Saga instances are stored in their serialized form. The serializer needs to be able to reconstruct these instances as well. Depending on the implementation, they might need a default constructor as well.