Skip to content

ExternalDocumentation

Googler edited this page Apr 21, 2020 · 4 revisions

Blogs, articles, books on Guice.

External Documentation

Books

In a traditional object-oriented application, a primary program controls secondary pieces of code, such as classes in a module, library, or framework. Dependency Injection (DI) is a technique that inverts this control, using an external mechanism to insert—or inject—a reference to an implementation of a service into an object. This allows you to build complex OO applications in a more testable, maintainable, and business-focused manner.

Google Guice: Agile Lightweight Dependency Injection Framework will not only tell you “how,” it will also tell you “why” and “why not,” so that all the knowledge you gain will be as widely applicable as possible. Filled with examples and background information, this book is an invaluable addition to your knowledge of modern agile Java.

Videos

An introduction to Guice by Dhanji R. Prasanna and Jesse Wilson, at Google I/O 2009. Learn how Google uses the fast, lightweight Guice framework to power some of the largest and most complex applications in the world. Supporting scores of developers, and steep testing and scaling requirements for the web, Guice proves that there is still ample room for a simple, type-safe and dynamic programming model in Java. This session will serve as a simple introduction to Guice, its ecosystem and how we use it at Google. PDF slides

PDF slides from the sold-out technical session at !JavaOne 2009.

Articles

Guice is a dependency injection (DI) framework. I've suggested for years that developers use DI, because it improves maintainability, testability, and flexibility. By watching engineers react to Guice, I've learned that the best way to convince a programmer to adopt a new technology is to make it really easy. Guice makes DI really easy, and as a result, the practice has taken off at Google. I hope to continue in the same vein in this article by making it really easy for you to learn Guice.

This article examines the simplest and most obvious use case for the Guice container, for mocking or faking objects in unit tests.

Also available in Portuguese

It should be apparent that making Invoice something that Guice creates directly is an incorrect design decision. Instead, you can mix it with another pattern instead: Factory.

Blogs

Configure your serverside app to serve up a backend for GWT apps. Obtain the Guice JAR files, extend GWT’s RemoteServiceServlet, extend Guice’s GuiceServletContextListener, extend Guice’s ServletModule, set all RemoteService relative paths to GWT.rpc, and configure GuiceFilter and your context listener in web.xml.

Guide for migrating from factories to dependency injection. In this N-part series, I'm attempting to document some patterns for improving your code with Guice. In each example, I'll start with sample code, explain what I don't like about it, and then show how I clean it up.

The premise is simple. @Inject anything, even stuff you don't know at injector-creation time. So our DeLorean class would look exactly as it would if EnergySource was constant:

What the new methods on TypeLiteral do.

A brief discussion on contextual APIs.

  @Trace("note goes here")
  public void bye() {
    System.out.println("see you later");
  }

Explains a better way to integrate Guice and Wicket, using Guice 2.0 and ServletModule which allows you to get rid of even more XML in your projects!

Clone this wiki locally