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

Chapter 5. Integrating Guice with Struts 2

This chapter demonstrates integration of Guice 3 with Struts 2. It is an action oriented, web framework based on MVC architecture. Guice integrates easily to provide dependency injection facility into the application developed. We will discuss the special modules and classes, which accomplish the task of integration. On top of it we would retrofit our application developed in the last chapter to be based on Struts 2. While doing so we will avoid writing servlets and filters and instead use Struts 2 provided classes.

It is desired that the reader is familiar with Struts 2, as primarily we are interested in injecting dependencies in Struts 2-based applications and not exploring Struts 2 itself. However, for the sake of completion of the subject matter, we will begin with a gentle introduction of the framework and go forward.

Tip

To begin development with Struts 2 we need struts2-core-2.3.14.jar file in our classpath. Also, for integrating it along with...