-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Guice40
Googler edited this page Jan 15, 2020
·
19 revisions
Released April 28, 2015
Guice:
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0</version>
</dependency>
Guice (No AOP):
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0</version>
<classifier>no_aop</classifier>
</dependency>
Extensions:
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-${extension}</artifactId>
<version>4.0</version>
</dependency>
- Guice: guice-4.0.jar
- Guice (No AOP): guice-4.0-no_aop.jar
- Guice extensions are all directly downloadable from this search page. Just click on the "jar" link for the appropriate extension.
- Java8 runtime compatibility for Guice core & all extensions.
- Added testlib extension, initially with support for easily binding fields in tests using BoundFieldModule.
- Added dagger-adapter extension to allow using dagger2 modules with Guice (using DaggerAdapter).
- Added OptionalBinder to the Multibinder extension, to allow frameworks to depend on something that users may or may not bind. (Also allows a default value for a binding that users can change.)
- Provisioning can be intercepted with a ProvisionListener.
- Singletons can be initialized concurrently.
- Injecting objects without @Inject constructors can be disabled with Binder.requireAtInjectOnConstructors.
- Extensions can add bindings using @Provides-like methods, by binding a ModuleAnnotatedMethodScanner.
- Multibinder or MapBinder items can be bound using @ProvidesIntoSet or @ProvidesIntoMap by installing a MultibindingsScanner.
- The current
@RequestScope
can be detached & reattached later using ServletScopes.transferRequest. - Lots of new validation for @Provides methods (see details below).
- Changed validation on @Provides methods -- it is now forbidden to override them.
- Changed validation on null being passed into @Provides method parameters. Parameters must now be @Nullable to allow null (the same as injecting methods or constructors).
- Changed the way Singletons are initialized -- there is no system-wide lock anymore. Singletons can now be instantiated concurrently.
- Changed requireExplicitBindings on child injectors or PrivateModules so that implicit bindings aren't promoted to the parent injector/module, even if the parent doesn't have requireExplicitBindings set.
- Added ProvisionListener (installed with Binder.bindListener) to intercept provisioning.
- Added Binder.requireAtInjectOnConstructors to prevent Guice from creating instances of classes that have no-args public constructors w/o @Inject.
- Added Binder.requireExactBindingAnnotations to prevent Guice from allowing a binding for @Named Foo to fulfill a request for @Named("foo") Foo, if the latter was missing but the former existed. (This applies to all parameterized annotations, not just @Named.)
- Added ElementSource, returned from Binding.getSource when possible, to get more detailed information about the binding. This includes keeping track of all the modules in the path that led to the binding.
- Added an SPI for @Provides methods. Call Binding.acceptTargetVisitor with the new ProvidesMethodTargetVisitor.
- Added ModuleAnnotatedMethodScanner (installed by Binder.scanModulesForAnnotatedMethods) to allow extensions to hook into Modules, scanning for methods annotated with @Provides-like methods and creating bindings.
- Added the ability to to stop recording line numbers of bindings, which can
increase startup time drastically (at the expense of less useful error
messages). (Use the system property
guice_include_stack_traces
set toOFF
,ONLY_FOR_DECLARING_SOURCE
(the default), orCOMPLETE
). - Added LinkedBindingBuilder.toProvider(javax.inject.Provider), for better JSR330 compatibility.
- Added InjectionPoint.forMethod & Binder.getProvider(Dependency) to allow building injection points off arbitrary methods.
- Allowed duplicate listener, interceptor & scope bindings to be ignored (instead of failing or installing them twice).
- Allowed method interceptors to capture the intercepted method and invoke it later.
- Allowed
@ProvidedBy
to work with enums (issue 295). - Improved error messages to list out all modules that led to a failed binding.
- Improved error messages when requestStaticInjection is called on an interface.
- Fixed the way Key works with annotations, so that it considers
@Annotation
is equal toAnnotation.class
if the annotation has all optional methods. - Fixed interceptors to allow intercepting bridge methods that javac automatically creates sometimes.
- Fixed circular dependencies between providers (issue 626).
- Fixed classloader leak relating to AOP (issue 643).
- Fixed anonymous TypeLiteral/Key instances so they don't retain references to the enclosing Module (issue 910).
- Fixed exceptions when encountering circular just-in-time bindings, when scopes cached proxies for circular dependencies, and when requestInjection (and others) try to inject the same object more than once in a different order than they were bound.
- Fixed
currentStage()
when used inModules.override
. - Fixed internal calls to
System.getProperty
so exceptions are ignored. - Optimized memory required when dealing with child injectors (issue 756).
- Optimized @Provides methods (by invoking them through cglib, saving ~200-300ns per method invocation).
- Optimized memory required for keeping binding source information.
- Optimized TypeConverters.
- Added ServletScopes.transferRequest to allow the current scope to be transferred to a different callable.
- Added ServletScopes.isRequestScoped to see if a binding is request scoped.
- Added the Key being requested into OutOfScopeException's message.
- Added a
@ScopingOnly GuiceFilter
that can be injected to provide scoping functionality without the dispatching. - Fixed ordering of filter processing -- the first binding is processed first. (It could have been in an arbitrary order if filters were set by different modules.)
- Fixed the request/response passed to filters & servlets so they get the latest request/response (even if it's wrapped by an earlier filter).
- Fixed manipulation of the servlet path info (issue 372).
- Fixed manipulation of the context path.
- Fixed pattern matching to ignore the query portion of the URI (issue 379).
- Fixed to decode the PathInfo (issue 745).
- Fixed exception when getCookies returned null.
- Fixed to work with requireExplicitBindings.
- Optimized the stack size when calling filters and trimmed excessive calls to doFilter from exception stack traces.
- Optimized performance per served request.
- Optimized
scopeRequest
.
- Changed Multibinder to also bind a
Collection<Provider<T>> and Collection<javax.inject.Provider<T>>
. - Changed MapBinder to also bind a
Map<K, javax.inject.Provider<V>>
. - Added OptionalBinder, to allow frameworks to depend on something that users may or may not bind. (Also allows a default value for a binding that users can change.)
- Added MultibindingsScanner to allow using @ProvidesIntoSet, @ProvidesIntoMap and @ProvidesIntoOptional on methods in modules.
- Fixed Multibinder/MapBinder to work better with Modules.override, ignoring exact same bindings instead of binding them twice. (Most usages of permitDuplicates should be unnecessary now.)
- Fixed Multibinder & MapBinder so they can't conflict with each other (issue 670).
- Improved error messages for duplicate bindings so it tells you what the duplicates were and where they were bound.
- Changed the validation on assisted injected classes to fail if the class has a scoping annotation.
- Added ThrowingProviderBinder.SecondaryBinder.providing(Class|TypeLiteral), which creates a proxy CheckedProvider that will construct the given class.
- Added a CheckedProviders(scopeExceptions) method, to allow turning off exception scoping.
- Improved exception messages when more than one underlying dependency fails.
- Allowed injecting non-scoped graphers.
- Fixed the way PrivateModules are handled to show exposed nodes (issue 489).
- Fix corrupt/bad looking graphs (issue 663).
- Fix incorrect grapher config (issue 755).
- Fixed so that log4j.properties file is not in the jar.
- Fixed to remove the entityManager even if
close()
throw an exception (issue 597). - Allowed JPA properties to be arbitrary Objects (in addition to Strings).
See the JDiff change report for complete details.
-
User's Guide
-
Integration
-
Extensions
-
Internals
-
Releases
-
Community