Revision: 1082 Author: limpbizkit Date: Mon Sep 7 18:47:35 2009 Log: Created wiki page through web user interface. http://code.google.com/p/google-guice/source/detail?r=1082
Added: /wiki/JSR330.wiki ======================================= --- /dev/null +++ /wiki/JSR330.wiki Mon Sep 7 18:47:35 2009 @@ -0,0 +1,19 @@ +#summary One-sentence summary of this page. + +=JSR-330 Integration= +[http://code.google.com/p/atinject/ JSR-330] standardizes annotations like `...@inject` and the `Provider` interfaces for Java platforms. It doesn't currently specify how applications are configured, so it has no analog to Guice's modules. + +Guice implements a complete JSR-330 injector. This table summarizes the JSR-330 types and their Guice equivalents. + +|| *JSR-330*<br>javax.inject || *Guice* <br>com.google.inject || || +|| [http://atinject.googlecode.com/svn/trunk/javadoc/javax/inject/Inject.html @Inject] || [http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/Inject.html @Inject] || Interchangeable, but JSR-330 places additional constraints on injection points. Fields must be non-final. Methods must be non-abstract, return void, and not have type parameters of their own. || +|| [http://atinject.googlecode.com/svn/trunk/javadoc/javax/inject/Named.html @Named] || [http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/name/Named.html @Named] || *Not equivalent.* Be careful to inject the same `...@named` that you bind. || +|| [http://atinject.googlecode.com/svn/trunk/javadoc/javax/inject/Qualifier.html @Qualifier] || [http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/BindingAnnotation.html @BindingAnnotation] || Interchangeable. || +|| [http://atinject.googlecode.com/svn/trunk/javadoc/javax/inject/Scope.html @Scope] || [http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/ScopeAnnotation.html @ScopeAnnotation] || Interchangeable. || +|| [http://atinject.googlecode.com/svn/trunk/javadoc/javax/inject/Singleton.html @Singleton] || [http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/Singleton.html @Singleton] || Interchangeable. || +|| [http://atinject.googlecode.com/svn/trunk/javadoc/javax/inject/Provider.html Provider] || [http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/Provider.html Provider] || Guice's Provider extends JSR-330's Provider. Use Jsr330.guicify() to convert a JSR-330 provider into a Guice provider. || + +==Best Practices== +For now, stick with Guice's annotations and Provider interface. + +Mixing JSR-330 and Guice annotations is supported, but discouraged. In particular, using both `...@named` annotations can be quite clumsy, as it is impossible to identify whose `...@named` is applied to a particular field or parameter. Similarly, using both `Provider` interfaces can cause difficultly, since they are not mutually assignable. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-guice-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en -~----------~----~----~----~------~----~------~--~---
