Google Guice

Rate Google Guice:
Community:1 Star2 Stars3 Stars4 Stars5 Stars (2 votes)
Loading ... Loading …Maturity:1 Star2 Stars3 Stars4 Stars5 Stars (3 votes)
Loading ... Loading …Documentation:1 Star2 Stars3 Stars4 Stars5 Stars (3 votes)
Loading ... Loading …Resources:1 Star2 Stars3 Stars4 Stars5 Stars (3 votes)
Loading ... Loading … Customization:1 Star2 Stars3 Stars4 Stars5 Stars (3 votes)
Loading ... Loading …Integration:1 Star2 Stars3 Stars4 Stars5 Stars (3 votes)
Loading ... Loading …

Google Guice is a light java dependency inversion framework using annotations. It is developed by Google(Bob Lee and Kevin Bourrillion) and it is used internally by Google for their applications. Google Guice is sometimes considered an Inversion of Control Container but as their authors state it’s not a container, it’s just an Dependency Injector, being too light to be considered a container. Beside Dependency injection Google Guice does some more AOP stuff.

Google Guice consists from a set of classes:
Guice - this is the starting point for all the operations. It is a singleton and the the class which provides the injector.
Binder, Binding - classes responsible for keeping the mapping between interfaces and the implementations that has to be used.
Injector - Fulfills requests for the object instances that make up your application, always ensuring that these instances are properly injected before they are returned.
Module - defines sets of bindings. Modules classes can be used to create injectors (passing a reference to the injector constructor) so the injector uses the binding defined in this.
Provider - provides instances of the applications and can encapsulate some logic to provide one type of implementation or another depending on a context
Scope - helps defining the scope of different injected instanced. By scoping Guice offer the option to reuse object instances inside a defined scope (for example reusing objects inside the scope of a session).

Licence: Apache License 2.0
Links: Homepage, Download, Javadocs, Wiki, Sourcecode

Here are a few internet resources to find out more about Google Guice:
Guice Tutorial - This is a small tutorial introducing Guice in a easy to understand way, covering topics such as:

  • Injecting Using Guice
  • Defining Default Bindings Using Annotations
  • Constructor Injection, Field Injection, Method Injection
  • Adding new Bindings Using Module Class

Guice Introduction - An introduction to Guice with a simple example, explaining the main entities in Guice.

Here is a video from Google Tech sessions introducing Guice (about 1 hour, presentation is available here):

This is the second session on Google Guice, analyzing it in more depth(about 1 hour):

Leave a comment