-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JSR330
sameb edited this page Jul 7, 2014
·
7 revisions
New in Guice 3.0
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 javax.inject |
Guice com.google.inject |
|
---|---|---|
@Inject | @Inject | Interchangeable, but JSR-330 places additional constraints on injection points. Fields must be non-final. Optional injection is not supported. Methods must be non-abstract and not have type parameters of their own. Additionally, method overriding differs in a key way: If a class being injected overrides a method where the superclass' method was annotated with javax.inject.Inject, but the subclass method is not annotated, then the method will not be injected. |
@Named | @Named | Interchangeable. |
@Qualifier | @BindingAnnotation | Interchangeable. |
@Scope | @ScopeAnnotation | Interchangeable. |
@Singleton | @Singleton | Interchangeable. |
Provider | Provider | Guice's Provider extends JSR-330's Provider. Use Providers.guicify() to convert a JSR-330 provider into a Guice provider. |
Prefer JSR-330's annotations and Provider interface.
-
User's Guide
-
Integration
-
Extensions
-
Internals
-
Releases
-
Community