core (no spring) configuration of axon-system (Saga/EventHandler/Queryhandler)

I am building a plain simple Java-SE only system based on axon and in-memory storage to learn and experiment with some “advanced” features …

Besides the GiftCard example in the getting started docs, I only find spring based examples on the web. I have several questions regarding the configuration of DI without spring:

  1. my projection implements an eventHandler that fills a hashMap and a queryHandler to answer queries.

I can do:

MyProjection p = new MyProjection();

configurer
   .registerModule(new EventHandlingConfiguration().registerEventHandler(c -> projection))
   .registerQueryHandler(c -> projection)

But what if my projection requires injection of additional components? I only see configurer(c -> new MyProjection(c.getXXX());  but that would register different instances for event- and query handling.


2.) I need  the commandGateway in my Saga. I tried but how can I make the SagaManager "inject" the commandGateay in a saga instance? I tried constructor and setter without success ... I do not have @Inject nor @Autowired on the classpath.


Is this missing in the SE axon-core? Or how can this be done? Can you point me to a core-example using sagas and (non-trivial) event handlers?


Thanks!
Jan

Hi Jan,

Let me try to answer your questions:

  1. We noticed the same issue as you did. You can track its progress here.

  2. When it comes to injecting resources into a Saga, ResourceInjector comes into play. You need to configure one within your configuration (the default is NoResourceInjector). There are several implementations (you can provide your own of course). You can use ConfigurationResourceInjector to have configuration components injected into your Saga, or you can use SimpleResourceInjector where you provide a Collection of your resources.

Hope this helps!

Cheers,
Milan

Thanks, perfect. with 1) I can wait and with 2) I now have an idea. cool.