Does SpringResourceInjector support constructor injection?

59 views
Skip to first unread message

Patrick Hancke

unread,
Jan 16, 2017, 5:02:11 AM1/16/17
to Axon Framework Users
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?

Allard Buijze

unread,
Jan 22, 2017, 2:28:26 PM1/22/17
to Axon Framework Users
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.

Cheers,

Allard

--
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.
Reply all
Reply to author
Forward
0 new messages