I have an architectural conundrum. I am using Guice in a project that is following CQRS. The Query side of the system is fine.
For the command side of the system I have chosen to use a queue to store the commands as they are received along with their arguments. The commands all implement a common interface with an execute method. The idea is that the commands are later executed in sequence by a worker thread which calls execute() on each Command in turn. The classes that implement Command contain the command arguments as fields which vary depending on which implementation the command represents. The commands only require injection once they are taken off the queue ready for execution (this is mostly because I would like to be able to serialize commands, but also because the execution of commands needs different modules to the part of the application that receives and queues them) My problem is this: Because the commands need to wait until they are taken off the queue to get their dependencies, I end up passing a lightly wrapped Injector to their 'execute' method so they can create themselves an object graph. This feels more like the Service Locator pattern than Dependency Injection. I've not been using Guice (or DI) long so if I've utterly missed the point please forgive me and give me a gentle nudge in the right direction. Thanks, Dave -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
