How to override binding in GIN

I find the answer for Guice Overriding bindings in Guice , but donโ€™t know how to do the same for GIN in GWT.

Thanks in advance!

+6
source share
2 answers

As far as I know, it is not supported.

To respond to your comment:

If you use pure JUnit tests (and not GWTTestcases), you do not use GIN, you use Guice, and in Guice you can override modules. If you want to reuse GIN modules, wrap them with the GinModuleAdapter . So you can do something like this:

 static class MyGinModule extends GinModule { ... } static class MyGuiceModule extends AbstractModule { ... } // And somewhere in your code, here how you could create the Injector Module myWrappedGinModule = new GinModuleAdapter(new MyGinModule()); Module myModule = Modules.override(myWrappedGinModule).with(new MyGuiceModule()); Injector injector = Guice.createInjector(myModule); 
+5
source

Use the @ImplementedBy annotation in your interface.

The class specified in the annotation will be the default implementation.

You can specify a different implementation, effectively overriding the default value.

For example:

 @ImplementedBy(MyWidgetImpl.class) public interface MyWidget { //... } public class MyWidgetImpl implements MyWidget { //... } 
0
source

All Articles