Learning Google Guice

Learning Google Guice
eBook: $17.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $47.98    Print cover: $29.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Detailed coverage of the various features of Guice such as the Injector, Bindings, Providers, TypeLiterals, Scoping, Multibinders, and so on
  • Learn how to use the various Guice-throwing providers, Guice-multibinder, Guice-servlet, Guice-struts2, and Guice-persist in various areas of application development
  • Focus on web application development using Struts 2, Hiberate 3, and JPA 2 while managing dependencies using Guice
  • Coverage of advanced topics such as extending Guice to cater for your specific requirements

Book Details

Language : English
Paperback : 126 pages [ 235mm x 191mm ]
Release Date : September 2013
ISBN : 1783281898
ISBN 13 : 9781783281893
Author(s) : Hussain Pithawala
Topics and Technologies : All Books, Web Development, Open Source

Table of Contents

Chapter 1: Getting Started with Guice
Chapter 2: Exploring Google Guice
Chapter 3: Diving Deeper in Guice
Chapter 4: Guice in Web Development
Chapter 5: Integrating Guice with Struts 2
Chapter 6: Integrating Guice with JPA 2
Chapter 7: Developing Plugins and Extensions using Guice
Chapter 8: AOP with Guice
Appendix: Prerequisites
  • 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

                    Hussain Pithawala

                    Hussain Pithawala is a polyglot programmer, a technical blogger, open source enthusiast, and a certified scrum master. At present he is a working as technical lead at Synerzip Softech India Pvt. Ltd, a leading dual-shore agile software product development company located in Pune, India. For the past seven years, he has been working in I.T. industry in various domains such as, office productivity suite, telecom provisioning, travel, and E-commerce. He holds expertise in software tooling, BPMN-based workflow engines, scripting languages, enterprise application development, mobile application development, and data analytics. LinkedIn Profile: http://in.linkedin.com/in/hussainpithawala Twitter: https://twitter.com/hussainpw Blog: http://hussainpithawala.wordpress.com
                    Sorry, we don't have any reviews for this title yet.

                    Code Downloads

                    Download the code and support files for this book.

                    Submit Errata

                    Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

                    Sample chapters

                    You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                    Frequently bought together

                    Learning Google Guice +    CentOS 6 Linux Server Cookbook =
                    50% Off
                    the second eBook
                    Price for both: £22.15

                    Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                    What you will learn from this book

                    • Optimize dependency injection using Guice as a solution
                    • Develop a fictitious application harnessing the advanced features of Guice
                    • Learn the intricacies of Binding, Scoping, and Injection
                    • Master the various aspects of Guice pertaining to different areas of application development in Java
                    • Learn how to harness the Guice-servlet extension for web development using Struts 2, JSP, Servlets, and Hibernate 3
                    • Leverage AOP using Guice implementation of aopalliance.
                    • Learn how to develop extensions using the Guice SPI

                    In Detail

                    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.

                    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.

                    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.


                    This book is a practical, hands-on guide that covers everything you need to know about application development in Java with dependency injection using Google Guice.

                    Who this book is for

                    Learning Google Guice is for anyone having a minimal understanding of application development in Java and keen to learn dependency injection using Guice. Architects and Lead programmers, who are into designing structure of the application would benefit from various recipes to be leveraged during developing infrastructure pieces.  It is assumed that readers will have a basic knowledge of dependency injection; however, this is not an obligation.

                    Code Download and Errata
                    Packt Anytime, Anywhere
                    Register Books
                    Print Upgrades
                    eBook Downloads
                    Video Support
                    Contact Us
                    Awards Voting Nominations Previous Winners
                    Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                    Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software