google-code-export / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
2 stars 1 forks source link

JSR 330 support #424

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm going to add this today.

The first controversial issue I've run into: should we coalesce @Named and 
@Named? It would be 
quite frustrating to bind one @Named and inject another; and the error message 
wouldn't be very 
easy to parse.

Original issue reported on code.google.com by limpbizkit on 7 Sep 2009 at 5:57

GoogleCodeExporter commented 9 years ago
I've made Guice's Provider extend the JSR 330 class. This should make it easier 
to interoperate with the new API. 
We could also change the code where we accept a com.google.inject.Provider to 
instead accept a 
javax.inject.Provider, but that would break binary compatibility.

As a compromise, I'll make it so that Guice:
 - always returns com.google.inject.Provider
 - accepts javax.inject.Provider, wherever it does not break binary compatibility.

Original comment by limpbizkit on 7 Sep 2009 at 7:52

GoogleCodeExporter commented 9 years ago
From the commit log of r1077:

This checkin supports:
   @javax.inject.Inject to mark classes
   @javax.inject.Qualifier to identify binding annotations
   javax.inject.Provider injections
   A new Jsr330 utility class

Still outstanding:
   JSR 330 is more strict about where its annotations are applied. These
restrictions are not yet enforced.
   @Scope
   @Singleton

Notable change:
   When the user injects a javax.inject.Provider<T>, we canonicalize the
dependency, and treat it exactly as if they injected a
com.google.inject.Provider<T>. This is slightly weird! For example, these two
keys are equal:
Key.get(new TypeLiteral<javax.inject.Provider<String>>() {})
Key.get(new TypeLiteral<com.google.inject.Provider<String>>() {})
   This is convenient, particularly for SPI users. And it means we don't need a
linked binding between the Providers. But it could be quite surprising. I'm
still trying to decide the right long term solution here...

Original comment by limpbizkit on 7 Sep 2009 at 9:02

GoogleCodeExporter commented 9 years ago
r1078, r1079 and r1080 complete the implementation. I've opened issue 425 to 
address the @Named problem; I 
believe everything else is in place.

Original comment by limpbizkit on 8 Sep 2009 at 12:36

GoogleCodeExporter commented 9 years ago
Why has this not officially been released ? Only 2.0 and a 3.0 snapshot are 
available...tehre is no 2.1.

Original comment by miroslav...@gmail.com on 6 Dec 2010 at 8:49