Share

From this page you can share Google Guice 2.0 Released to a social bookmarking site or email a link to the page.
Social WebE-mail
Enter multiple addresses on separate lines or separate them with commas.
Google Guice 2.0 Released
(Your Name) has forwarded a page to you from Ajaxonomy
(Your Name) thought you would like to see this page from the Ajaxonomy web site.

Google Guice 2.0 Released

Tagged:  

Java dependency injection just got better: Google Guice 2.0 has been released.

What's new:

  • Provider methods. You can now annotate methods in your Module so you avoid manually constructing dependencies.
  • Binding overrides. One Module can now override the bindings in another.
  • Private modules. You can now create bindings that are not externally visible, in order to encapsulate your dependency injections.
  • The ability to inject members of sets and maps using Multibinder and MapBinder respectively.
  • ServletModule now provides programmatic configuration of servlets and filters. GuiceServletContextListener can be used to help bootstrap a Guice application in a servlet container.
  • Custom injections. Guice now includes hooks that allow other frameworks to define custom injection annotations. This enables Guice to host other frameworks that have their own injection semantics or annotations.
  • A tree-like structure for Injectors, i.e., an Injector can have children that inherit all of its bindings.
  • An introspection API: like reflection but for Guice bindings.
  • Pluggable type converters that convert constant string bindings to other types, i.e., Dates, URLs, etc.
  • OSGi compatible. Guice now works well in OSGi managed environments, because AOP-generated classes use a bridge classloader.
  • AOP is now optional, so Guice will work on platforms that don't support bytecode generation (Android).

You can download the new release here. The new manual is here. Now all they have to do is update the public Maven repository.

javax.inject.Inject

On related news (Crazy) Bob Lee, the creator of Guice, and Rod Johnson, the creator of Spring, have gotten together to propose a standard set of annotations and interfaces for using dependency injection in Java under the banner of JSR-330: Dependency Injection for Java (still only a proposal, so JSR-330 is a tentative moniker). There is also a corresponding project over at Google Code. The standardization should greatly help the use of dependency injection in shared 3rd party libraries, allowing the application developer to avoid having to initialize more than one dependency injection framework.

These annotations are modelled closely on those currently in Google Guice:

  • @Inject - Identifies injectable constructors, methods, and fields
  • @Qualifier - Identifies qualifier annotations
  • @Scope - Identifies scope annotations
  • @Named - String-based qualifier
  • @Singleton - Identifies a type that the injector only instantiates once

The utility interface Provider is also in the proposed specification.