Guice で Guice Overriding Bindingの答えを見つけましたが、GWT で GIN に対して同じことを行う方法がわかりません。
前もって感謝します!
Guice で Guice Overriding Bindingの答えを見つけましたが、GWT で GIN に対して同じことを行う方法がわかりません。
前もって感謝します!
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);
@ImplementedBy
インターフェイスで注釈を使用します。
アノテーションで指定されたクラスがデフォルトの実装になります。
デフォルトを効果的にオーバーライドして、別の実装を指定できます。
例えば:
@ImplementedBy(MyWidgetImpl.class)
public interface MyWidget {
//...
}
public class MyWidgetImpl implements MyWidget {
//...
}