문제

I find the answer for Guice Overriding Binding in Guice but don't know how to do the same for GIN in GWT.

Thanks in advance!

도움이 되었습니까?

해결책

As far as I know, it's not supported.

To answer your comment:

If you're running "pure" JUnit tests (not GWTTestcases) you don't use GIN, you use Guice, and in Guice you can override modules. If you want to reuse GIN modules, then wrap them using GinModuleAdapter. So you can do something like this:

static class MyGinModule extends GinModule {
  ...
}
static class MyGuiceModule extends AbstractModule {
  ...
}

// And somewhere in your code, here's 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);

다른 팁

Use the @ImplementedBy annotation in your interface.

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

You can specify another implementation, effectively overriding the default.

For example:

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

public class MyWidgetImpl implements MyWidget {
  //...
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top