I have application written with Java and Guice. For this application I have several views. Some of them use Guice, other - doesn't. Now I want to separate my code into independent modules. I can devide application logic, viewers interfaces and viewers implementations. In which module should I put Guice configuration per each view variant? I think there is two possible answers - into viewers module (in this case all viewers will depend from Guice) or contribute such ModuleConfiguration separately from module. What is the right way开发者_如何学编程? If separably, what is the best way for such contribution?
Just split the configuration into several Guice Modules near the code that they are wiring. Then use composition to construct an injector.
Injector injector = Guice.createInjector(new ModuleA(), new ModuleB());
精彩评论