---
title: 'Guice 3.0 ist raus'
url: 'https://www.tutego.de/blog/javainsel/2011/03/guice-3-0-ist-raus'
markdown: 'https://www.tutego.de/blog/javainsel/2011/03/guice-3-0-ist-raus.md'
date: '2011-03-25'
description: 'Nach laaaanger Wartezeit ist DI-Framework Guice 3.0 veröffentlicht worden. Von die Neuerungen: JSR 330 support New Persist extension ToConstructor Bindings Better OSGi support (and generally improved support for multiple classloaders) New methods in Binder: requireExplicitBindings & disableC…'
taxonomy:
  category:
    - 'Open Source'
    - Google
    - Guice
---

# Guice 3.0 ist raus

![Illustration einer tropischen Insel mit Palmen und einem hohen Berg](https://www.tutego.de/blog/javainsel/user/themes/tutego/images/insel-cover.jpg)# Java Blog für Programmierer

[Java Blog für Programmierer](https://www.tutego.de/blog/javainsel/)

## Guice 3.0 ist raus

25.03.2011 · [Christian Ullenboom](https://www.tutego.de/blog/javainsel/author/admin/)

Nach laaaanger Wartezeit ist DI-Framework Guice 3.0 veröffentlicht worden. Von die Neuerungen:

> - [JSR 330 support](http://code.google.com/p/google-guice/wiki/JSR330)
> - [New Persist extension](http://code.google.com/p/google-guice/wiki/GuicePersist)
> - [ToConstructor Bindings](http://code.google.com/p/google-guice/wiki/ToConstructorBindings)
> - Better OSGi support (and generally improved support for multiple classloaders)
> - New methods in Binder: `requireExplicitBindings` & `disableCircularProxies`
> - Much simpler stack traces when AOP is involved
> - Exact duplicate bindings are ignored (instead of an exception being thrown)
> - Repackaged cglib, asm & guava classes are now hidden from IDE auto-imports
> - Source can be built with Maven
> - General extension & SPI improvements: 
>     - [Extensions SPI](http://code.google.com/p/google-guice/wiki/ExtensionSPI), with support from the [Multibindings](http://code.google.com/p/google-guice/wiki/Multibindings), [ServletModule](http://code.google.com/p/google-guice/wiki/ServletModule) and [AssistedInject](http://code.google.com/p/google-guice/wiki/AssistedInject) extensions.
>     - `@Toolable`, for use by extensions in Stage.TOOL
>     - All binding implementations implement HasDependencies
> - Scope improvements: 
>     - Scopes.`isSingleton`
>     - `toInstance` bindings are considered eager singletons in the Scope SPI
>     - Singleton providers that return `null` are now scoped properly.
>     - Fail when circularly dependent singletons cannot be proxied (previously two instances may have been created)
> - Provider Method (`@Provides`) improvements: 
>     - Logger dependencies now use named instead of anonymous loggers
>     - Exceptions produce a simpler stack
> - Private Modules improvements: 
>     - If a single PrivateModule is passed to Modules.override, private elements can be overridden.
>     - If many modules are passed to Modules.override, exposed keys can be overridden.
> - Multibinder & MapBinder extension improvements: 
>     - `permitDuplicates` — allows MapBinder to inject a `Map`<K, `Set`<V>> and a `Map`<K, `Set`<Provider<V>> and Multibinder to silently ignore duplicate entries
>     - Expose dependencies in Stage.TOOL, and return a dependency on Injector (instead of `null`) when working with Elements.
>     - Co-exist nicely with Modules.override
>     - Work properly with marker (parameterless) annotations
>     - Expose details through the new extensions SPI
> - Servlet extension improvements: 
>     - Added `with(instance)` for servlet bindings.
>     - Support multiple injectors using [ServletModule](http://code.google.com/p/google-guice/wiki/ServletModule) in the same JVM.
>     - Support thread-continuations (allow background threads to process an HttpRequest)
>     - Support manually seeding a `@RequestScope`
>     - Expose details through new extensions SPI
>     - Fix request forwarding
>     - Performance improvements for the filter & servlet pipelines
>     - Expose the servlet context (ServletModule.`getServletContext`)
>     - Fixed so a single [ServletModule](http://code.google.com/p/google-guice/wiki/ServletModule) instance can be used twice (in, say Element.`getElements` & creating an Injector)
>     - Fix to work with context paths
> - [AssistedInject](http://code.google.com/p/google-guice/wiki/AssistedInject) extension improvements 
>     - New FactoryModuleBuilder for building assisted factories
>     - Injection is done through child injectors and can participate in AOP
>     - Performance improvements
>     - Multiple different implementations can be created from a single factory
>     - Incorrect implementations or factories are detected in Stage.TOOL, and more error-checking with better error messages
>     - Work better with parameterized types
>     - Expose details through new extensions SPI
> - [ThrowingProviders](http://code.google.com/p/google-guice/wiki/ThrowingProviders) extension improvements 
>     - Added a new CheckedProviders interface that allows more than one exception to be thrown.
>     - Added `@CheckedProvides` allowing `@Provides`-like syntax for CheckedProviders.
>     - Dependencies are checked at Injector-creation time and during Stage.TOOL, so they can fail early
>     - Bindings created by ThrowingProviderBinder now return proper dependencies instead of Injector.
> - [Struts2](http://code.google.com/p/google-guice/wiki/Struts2Integration)
>     - The Struts2 extension now works again! (It worked in Guice 1.0 and was somewhat broken in Guice 2.0)
> - Added to Injector: `getAllBindings`, `getExistingBinding`, `getScopeBindings`, `getTypeConverterBindings`.
> - Added to Key: `hasAttributes`, `ofType`, `withoutAttributes`
> - Various bug fixes / improvements: 
>     - Prevent child injectors from rebinding a parent just-in-time binding.
>     - Non-intercepted methods in a class with other intercepted methods no longer go through cglib (reducing total stack frames).
>     - Allow Guice to work on generated classes.
>     - Fix calling `Provider.get()` of an unrelated Provider in a scoping method.
>     - MoreTypes.`getRawTypes` returns the proper types for arrays (instead of `Object`.class)
>     - JIT bindings left in a parent injector when child injectors fail creating a JIT binding are now removed
>     - Overriding an `@Inject` method (if the subclass also annotates the method with `@Inject`) no longer injects the method twice
>     - You can now bind byte constants (using `ConstantBindingBuilder.to(byte)`)
>     - Better exceptions when trying to intercept final classes, using keys already bound in child or private module, and many other cases.
>     - ConvertedConstantBinding now exposes the TypeConverterBinding used to convert the constant.

Kategorien: [Open Source](https://www.tutego.de/blog/javainsel/category/open-source/), [Google](https://www.tutego.de/blog/javainsel/category/google/), [Guice](https://www.tutego.de/blog/javainsel/category/guice/)

[← Alle Beiträge](https://www.tutego.de/blog/javainsel/)

---

## Navigation

- Previous: [Inselupdate: Primitive Elemente in Datenstrukturen verwalten](https://www.tutego.de/blog/javainsel/2011/03/primitive-elemente-in-datenstrukturen-verwalten.md)
- Next: [Die JavaMail API (Teil 2)](https://www.tutego.de/blog/javainsel/2011/03/die-javamail-api-teil-2.md)
