Doing what you want is actually quite difficult, because your common injector interface, which is annotated by your Gin module, cannot point to an abstract Gin module. The Gin module that your Ginjector interface points to must be specific. A particular module cannot perform multiple configurations at once.
So what do you do: (a) Build your Ginjector interface, say ClientGinjector and your ClientModule for the desktop application.
(b) Create a second Ginjector interface, say ClientGinjectorTablet, adding the one you created in (a) but with a GinModule annotation pointing to another module, such as ClientModuletablet.
- Now you have two default Ginjecor interfaces, and the second one for tablets, each of which points to a module with its own Configure () implementations.
(c) Now you want to create a Factory to get an implementation of the Right Ginjector. You can do this because the Ginjector that you studied in (a) and (b) has a common daemon, which is the default interface created in (a). Thus, you create an abstract factoria using a method such as: public annotation ClientGinjector getInjector (); You create two children of specific classes. One to get the Ginjector Desktop / Default, and the other to get the Ginjector Tablet.
(d) Now you configure your gwt.xml module in the same way as Google IO on youtube, explain that you need to get the desired factor at runtime using delayed GWT bindings for each of your Ginjector factory.
(e) At your entry point, you will not receive a Ginjector, but your Factory for Ginjectors using a delayed GWT binding. You call the abstract method that ClientGinjector returns, your set.
(f) Epic failure at the end. Guice will not allow you to bind the same key twice (class plus annotation), even if you use different injectors (one for the desktop and one for the tablet). The key bindings seem to be global once you have two modules redefining the same keys as the end of the adventure.
99 sono
source share