开发者

Where I should put glue?

开发者 https://www.devze.com 2023-02-13 18:25 出处:网络
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 devi

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());
0

精彩评论

暂无评论...
验证码 换一张
取 消