-
Notifications
You must be signed in to change notification settings - Fork 8
Guice Compatibility
We have alternative types for:
-
Module
,AbstractModule
Injector
For Module
and AbtractModule
, use GinModule
and AbstractGinModule
. They work much like their counterparts, but lack some of the features. Note that there is a 100% one-way conversion from GWT to Guice using GinModuleAdapter
, so consider putting shared code in a GinModule
. Other than that, you could also copy paste bindings from existing modules (usually they'll work), but of course copy-pasting should be discouraged.
For Injector
, use the Ginjector
combined with the @GinModules
annotation. See the Gin Tutorial to learn how you can get started and Gin FAQ for more helpful hints.
For everything else, use the Guice types. Note that we do not support everything Guice does (and we never will), so keep in mind when you are developing with GIN. See the feature comparison below for more information.
Here we compare the current GIN trunk with Guice 1.0 and 2.0. The feature list is not complete, but should give you a rough idea about what works and what doesn't.
A = Available
N/A = Not Available (will probably never happen)
P = Planned (possible)
G = Guice (abbrev. to conserve space in MD)
Feature | G 1.0 | G 2.0 | G 3.0 | G 4.2 | Gin 1.0 | Gin 1.5 | Gin 2.0 | Gin 2.1 | Gin 3.0 |
---|---|---|---|---|---|---|---|---|---|
Modules | A | A | A | A | A* | A | A | A | A |
Provider bindings | A | A | A | A | A | A | A | A | A |
Provider methods | N/A | A | A | A | A | A | A | A | A |
toInstance bindings | A | A | A | A | N/A | N/A | N/A | N/A | N/A |
Constant bindings | A | A | A | A | A | A | A | A | A |
Binder.install | A | A | A | A | A | A | A | A | A |
Binder.requestInjection | N/A | A | A | A | N/A | N/A | N/A | N/A | N/A |
Binder.requestStaticInjection | A | A | A | A | A | A | A | A | A |
Binder.getProvider | N/A | A | A | A | P | P | P | P | P |
Binder.requireBinding | N/A | A | A | A | P | P | P | P | P |
(Custom) binding annotations | A | A | A | A | A | A | A | A | A |
@Named |
A | A | A | A | A | A | A | A | A |
Scopes | A | A | A | A | A | A | A | A | A |
Custom Scopes | A | A | A | A | N/A | N/A | N/A | N/A | N/A |
@Singleton class Foo{} |
A | A | A | A | A | A | A | A | A |
@ImplementedBy |
A | A | A | A | A | A | A | A | A |
@ProvidedBy |
A | A | A | A | A | A | A | A | A |
TypeLiteral |
A | A | A | A | A | A | A | A | A |
Circular dependencies | A | A | A | A | N/A | N/A | A | A | A |
Private modules | N/A | A | A | A | N/A | N/A | A | A | A |
@Optional injection |
N/A | A | A | A | A | A | A | A | A |
Assisted Inject | A | A | A | A | N/A | A | A | A | A |
JSR330 Support | N/A | N/A | A | A | N/A | A | A | A | A |
Binder.requireExplicitBindings | N/A | N/A | A | A | N/A | N/A | N/A | N/A | N/A |
toConstructor bindings | N/A | N/A | A | A | N/A | N/A | N/A | N/A | N/A |
Multi/Mapbinder | N/A | A | A | A | N/A | N/A | N/A | A | A |
Custom injections | N/A | A | A | A | N/A | N/A | N/A | N/A | N/A |
Throwing/checked provider | N/A | N/A | A | A | N/A | N/A | N/A | N/A | N/A |
Inject Package Private Types | A | A | A | A | N/A | N/A | A | N/A | N/A |
require@InjectOnConstructor | N/A | N/A | N/A | A | N/A | N/A | N/A | N/A | P |
DaggerAdapter |
N/A | N/A | N/A | A | N/A | N/A | N/A | N/A | P |
* using GinModule
Feature | G 1.0 | G 2.0 | G 3.0 | G 4.2 | Gin 1.0 | Gin 1.5 | Gin 2.0 | Gin 2.1 | Gin 3.0 |
---|---|---|---|---|---|---|---|---|---|
Constructor inj. | A | A | A | A | A | A | A | A | A |
Field inj. | A | A | A | A | A | A | A | A | A |
Method inj. | A | A | A | A | A | A | A | A | A |
Method intercep. (AOP) | A | A | A | A | N/A | N/A | N/A | N/A | N/A |
Injector.injectMembers | A | A | A | A | A | A | A | A | A |
Inj. of private members | A | A | A | A | A | A | A | A | A |