Learning Google Guice Book TOC – Free Books Download PDF

Learning Google Guice Book TOC – Free Books Download PDF Book

TOC

Table of Content

Learning Google Guice Book TOC – Free Books Download PDF

Chapter 1: Getting Started with Guice

Wiring dependencies

Resolving dependencies directly

Inverting the dependencies

Understanding Inversion of Control

Inverting the control using the Dependency injection

Comparing two approaches

Initializing dependencies directly

Refactoring to use Guice

Building and Running the examples

Compiling the sample code

Running Unit tests

Running the main application

Summary

Chapter 2: Exploring Google Guice

Meet the injector

Various kinds of injections

Field injection

Method injection

Constructor injection

Configuring a module to write bindings

Bindings

Linked bindings

Instance bindings

Untargeted bindings

Constructor bindings

Binding annotations

Binding constants

Binding properties

Just in time bindings

By default constructors

@Inject annotated constructors

Interfaces annotated with @ImplementedBy

Static injection

Summary

Chapter 3: Diving Deeper in Guice

Going the extra mile with Providers

Need for a Provider

Working of a Provider

Rolling your own Provider

Injecting dependencies in Providers

Advantages of a Provider

@Provides

CheckedProviders

@CheckedProvides

AssistedInject

Binding collections

Using TypeLiteral

Using MultiBinder

Scoping

Singletons with Guice

Eager Singletons

Custom Scopes

Motivation to write a custom scope

Modifying our Provider

Defining our own scope

Changes in Module

Observations

Summary

Chapter 4: Guice in Web Development

Structure of flightsweb application

Using GuiceFilter

Rolling out our ServletContextListener interface

ServletModule – the entry point for configurations

Binding language

Mapping servlets

Mapping filters

Web scopes

@RequestScoped

@SessionScoped

@RequestParameters

Exercising caution while scoping

Summary

Chapter 5: Integrating Guice with Struts 2

Introducing Struts 2

Guice 3 and Struts 2 integration

Struts2GuicePluginModule

Struts2Factory

FlightSearch application with Struts 2

FlightServletContexListener

Index page

FlightSearchAction

Response page

Summary

Chapter 6: Integrating Guice with JPA 2

Introduction to JPA 2 and Hibernate 3

Persistence Unit

PersistenceContext

EntityManagerFactory

EntityManager

Session Strategies

Guice 3 with JPA 2

PersistService

UnitOfWork

JpaPersistService

PersistFilter

@Transactional

JpaLocalTxnInterceptor

JpaPersistModule

FlightSearch application with JPA 2 and Hibernate 3

Persistence.xml

Client

SearchResponse

FlightEngineModule

FlightJPASupplier

FlightServletContextListener

Summary

Chapter 7: Developing Plugins and Extensions using Guice

Developing a plugin

Guice SPI (Service Provider Interface)

Quick introduction to Visitor Design pattern

Elements SPI

Implementing Elements SPI

Uses of Elements SPI

Extensions SPI

Exploring a custom extension, guice-multibinder

Important classes and interfaces in guice-multibinder

Multibinder in action

Summary

Chapter 8: AOP with Guice

What is AOP?

How AOP works?

How Guice supports AOP?

Implementing a LoggingInterceptor

Understanding Matchers

Limitations

Concerns related to performance

Summary

Appendix: Prerequisites

Getting the sample code

Installing Git

Cloning the repository

JDK

Installing Maven

Mac OSX and Linux

Microsoft Windows

Installing Eclipse

Installing the m2eclipse plugin

Installing Apache Tomcat

Installing MySQL

Microsoft Windows

Mac OSX

Linux

Importing MySQL data

Index