My favorites | Sign in
Google
                
Search
for
Updated Sep 29, 2009 by aragos
GuiceCompatibility  
It looks like Guice, it walks like Guice, so it must be Guice?

Guice Compatibility

API

We have alternative types for:

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 conbined with the @GinModules annotation. See the GinTutorial to learn how you can get started and GinFaq for more helpful hints.

For everything else, use the Guice types. Note that we don 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.

Features

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)

Configuration

Feature Guice 1.0 Guice 2.0 GIN
Modules A A A (GinModule)
Provider bindings A A A
Provider method bindings N/A A A
toInstance bindings A A P (?)
Constant bindings A A A
Binder.install A A A
Binder.requestInjection N/A A N/A
Binder.requestStaticInjection A A A
Binder.getProvider() N/A A P
Binder.requireBinding() N/A A P
(Custom) binding annotations A A A
@Named A A A
Scopes A A A
Custom Scopes A A P (?)
@Singleton class Blah{} A A A
@ImplementedBy A A A
@ProvidedBy A A A
TypeLiteral A A A
Circular dependencies A A P
Private modules N/A A P
@Optional injection N/A A A

Runtime

Feature Guice 1.0 Guice 2.0 GIN
Constructor injection A A A
Field injection A A A
Method injection A A A
Method interception (AOP) A A P (?)
Injector.injectMembers A A A
Injection of private members A A A


Comment by thebravedave, Jul 25, 2009

When's the official release? EVERYONE wants to start using this ASAP

Comment by dobesv, Jul 26, 2009

Why not support toInstance() by having the runtime code set the instances up after creating the Ginjector. For example:

class MyModule? extends AbstractGinModue? { configure() {

bind(Foo.class).toInstance("foo");
} }

interface MyGinjector? extends Ginjector {

@Instance("foo") public void setFoo(Foo foo); @Instance("bar") public void setBar(Bar bar);
}

class MyEntryPoint? implements EntryPoint? { onModuleCreate() { MyGinjector? injector = GWT.create(MyGinjector?); injector.setFooInstance(foo); injector.setBarInstance(bar); } }

You'd have to throw an error if an instance was not set before it was injected, but this approach seems quite straightforward to implement to me...

Comment by arthur.kalm, Jul 27, 2009

@thebravedave

We've been using it off of trunk for many months now. It works great.

Comment by thebravedave, Jul 29, 2009

Just a note for those trying to compile the Gin.jar from the trunk. It DOES work, you just have to make sure everything is configured correctly. Im a newbie, and just managed it myself.


Sign in to add a comment