I’m giving Axon a try with a small test project but I’ve hit a roadblock.
My domain object “Game” has different behavior depending on what level number is being played. This would usually be handled using the Strategy pattern and passing the strategy via the constructor to the domain object. It seems that would be incorrect when using Axon because I might only know the level number after object initialization (when replaying events). So I think I should pass in a StrategyFactory and let the @EventSourcingHandler annotated method instantiate a strategy. But I still have no clue as to how to pass in this factory object. Can’t be via constructor because Axon calls the constructor, not me.
Putting the factory object inside the event also makes no sense, as it would be persisted and propagated to all listeners. All the listeners should get is the level number (an integer).