GWT 3 and gin

683 views
Skip to first unread message

jchimene

unread,
Jun 15, 2015, 3:24:40 PM6/15/15
to googl...@googlegroups.com
Hi -

I cannot remember the last time I wrote NEW

Maybe it's too soon to ask this question, or maybe it's been asked and answered...

With removing generators from GWT 3, what happens to gin?

tia,
jec

Filipe Sousa

unread,
Jun 16, 2015, 4:16:05 AM6/16/15
to googl...@googlegroups.com
From what I've read, the solution is to use dagger

David

unread,
Jun 16, 2015, 4:16:14 AM6/16/15
to googl...@googlegroups.com
Docker2 might be an alternative, but it is less complete than GIN.
But I guess someone could update GIN to use an annotation processor instead of generators.

--
You received this message because you are subscribed to the Google Groups "google-gin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-gin+...@googlegroups.com.
To post to this group, send email to googl...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-gin.
For more options, visit https://groups.google.com/d/optout.

David

unread,
Jun 16, 2015, 4:30:29 AM6/16/15
to googl...@googlegroups.com
That's what I meant::-s Dagger 2 ... should sleep more!

Thomas Broyer

unread,
Jun 16, 2015, 4:54:02 AM6/16/15
to googl...@googlegroups.com


On Tuesday, June 16, 2015 at 10:16:14 AM UTC+2, David Nouls wrote:
[Dagger 2] might be an alternative, but it is less complete than GIN.

Out of curiosity: what are you missing in Dagger 2 that GIN does?
Automatic fallback to `GWT.create()` and knowledge of GWT-RPC? They won't make GWT 3.0 anyway.
Static injection? While I (kind of) agree, that was left out on-purpose, as it's considered an anti-pattern.
@ImplementedBy / @ProvidedBy ? I'd tend to agree, but also think it's a code smell, a sign of over-engineering in many cases (at least wrt @ImplementedBy)
Circular dependencies through Provider<> ? It's being worked on: https://github.com/google/dagger/issues/200
Private modules?

David

unread,
Jun 16, 2015, 9:10:12 AM6/16/15
to googl...@googlegroups.com
I do indeed rely a lot on GWT.create fallback (GWT-RPC, CssResources, UiBinder files, ... etc) which also makes it easier to mock. But indeed, that part won't survive.

Static injection I only use for very special cases, for tracing purpose I use static injection. But OK, I could live without.

In UiBinder based classes I also use method injection - although that can be an anti-pattern (and in fact I filed a bug on it that there is a order issue when subclassing)

ImplementedBy/ProvidedBy I never use

AutoFactory seems interesting as a replacement for Assisted inject, I did not look into that one.

The last one that I would mis is custom injections. But that is not supported in GIN (it is in Guice). But again, I don't use it that often, I'm sure I could live without.

Hey you just convinced me to start migrating :-) But we have a lot of Guice code, including some Guice extensions (custom scopes, binding extensions, ... ). I'm not sure if I can convince my team.

--

Thomas Broyer

unread,
Jun 16, 2015, 9:54:50 AM6/16/15
to googl...@googlegroups.com


On Tuesday, June 16, 2015 at 3:10:12 PM UTC+2, David Nouls wrote:
I do indeed rely a lot on GWT.create fallback (GWT-RPC, CssResources, UiBinder files, ... etc) which also makes it easier to mock. But indeed, that part won't survive.

FWIW, I don't consider ClientBundle (in most cases, but not all) or UiBinder to be "dependencies". For those cases where ClientBundle is indeed a dependency, that means it's a shared bundle; there aren't that many so an explicit binding would be OK.
When I want to mock those for tests, to avoid a GWT.create(), I generally just create 2 constructors: one that takes only "dependencies" as arguments, and another that also takes the same plus de GWT.create()d objects, the first ctor delegating to the second one and calling GWT.create() explicitly. The first ctor is the one annotated with @Inject, the second ctor is the one used in tests.
But admittedly we don't write enough tests, so YMMV.
 
Static injection I only use for very special cases, for tracing purpose I use static injection. But OK, I could live without.

In UiBinder based classes I also use method injection - although that can be an anti-pattern (and in fact I filed a bug on it that there is a order issue when subclassing)

Dagger 2 supports method injection.
 
ImplementedBy/ProvidedBy I never use

AutoFactory seems interesting as a replacement for Assisted inject, I did not look into that one.

The last one that I would mis is custom injections. But that is not supported in GIN (it is in Guice). But again, I don't use it that often, I'm sure I could live without.
 
Hey you just convinced me to start migrating :-) But we have a lot of Guice code, including some Guice extensions (custom scopes, binding extensions, ... ). I'm not sure if I can convince my team.

Those extensions are not supported by GIN either, so it shouldn't be a problem. And Guice 4 comes with a DaggerAdapter, similar to GinModuleAdapter, but that unfortunately doesn't support "multibindings".

One GIN-specific feature I missed in my previous mail are AsyncProviders.

David

unread,
Jun 17, 2015, 3:32:40 AM6/17/15
to googl...@googlegroups.com
I didn't know about the Adapter, that should really ease the migration, thanks for the info!

--
Reply all
Reply to author
Forward
0 new messages