Book Image

Learning Google Guice

By : Hussain Pithawala
Book Image

Learning Google Guice

By: Hussain Pithawala

Overview of this book

<p>Google Guice is an open source software framework for the Java platform released by Google under the Apache License. It provides support for dependency injection using annotations to configure Java objects.</p> <p>Learning Google Guice is a concise, hands-on book that covers the various areas of dependency injection using the features provided by the latest version of Google Guice. It focuses on core functionalities as well as the various extensions surrounding Guice that make it useful in other areas like web development, integration with frameworks for web development, and persistence.</p> <p>Learning Google Guice covers Guice extensions which avoid complex API usage. You will start by developing a trivial application and managing dependencies using Guice. As the book gradually progresses, you will continue adding complexity to the application while simultaneously learning how to use Guice features such as the Injector, Provider, Bindings, Scopes, and so on. Finally, you will retrofit the application for the Web, using Guice not only to manage dependencies, but also to solve configuration related problems.</p>
Table of Contents (17 chapters)
Learning Google Guice
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Developing a plugin


A Guice plugin is simply a JAR file which separates commonly used functionalities. Developing a separate plugin could provide us a variety of benefits. Few of these could be like grouping various initialization tasks, preparing factories to instantiate objects, and so on. A separate plugin could also be used to develop interfaces and classes, which could help us to analyze bindings and write custom extensions.

In our case, we find it a good option to separate functionality of initializing and loading our custom modules. Separating the functions, which are not dependent on application logic increases reusability. We will separate MainModule, which loads other modules and make it a part of plugin, guice-analyst. This plugin then could be used in any different project; in our case, it is used as flights-struts-jpa-ext.

Note

The Guice plugin dependency is available as the guice-analyst-1.0-SNAPSHOT.jar. This dependency is included in the pom.xml for chapter_7/flights-struts...