0%

Book Description

Over 60 incredibly effective recipes to take you under the hood and leverage advanced concepts of the Play framework

  • Make your application more modular, by introducing you to the world of modules.
  • Keep your application up and running in production mode, from setup to monitoring it appropriately.
  • Integrate play applications into your CI environment
  • Keep performance high by using caching
  • Learn how to leverage external APIs without letting your application go down on problems
  • Use the play framework as a provider for your API systems
  • Implement your own authorization mechanisms, and different output formats

In Detail

The Play framework is the new kid on the block of Java frameworks. By breaking with existing standards the play framework tries not to abstract away from HTTP as most web frameworks do, but tightly integrates with it. This means quite a shift for Java programmers. Understanding these concepts behind the play framework and its impact on web development with Java are crucial for fast development of applications.

The Play Framework Cookbook starts where the beginner documentation ends. It shows you how to utilize advanced features of the Play framework – piece by piece and completely outlined with working applications!

The reader will be taken through all layers of the Play Framework and provided with in-depth knowledge from as many examples and applications as possible. Leveraging the most from the Play framework means to think simple again in a java environment. Implement your own renderers, integrate tightly with HTTP, use existing code, improve site performance with caching and integrate with other web services and interfaces. Learn about non-functional issues like modularity or integration into production and testing environments. In order to provide the best learning experience during reading Play Framework Cookbook, almost every example is provided with source code, so you can start immediately to integrate recipes into your own play applications.

Table of Contents

  1. Play Framework Cookbook
    1. Table of Contents
    2. Play Framework Cookbook
    3. Credits
    4. Foreword
      1. Why Play is a small revolution in the Java world
        1. Prerequisites
        2. What is missing: A Scala chapter
    5. About the Author
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Basics of the Play Framework
      1. Introduction
      2. Downloading and installing the Play framework
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Creating a new application
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Support for various IDEs
      4. Defining routes as the entry point to your application
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Configuring your application via application.conf
        1. How to do it...
        2. How it works...
        3. See also
      6. Defining your own controllers
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using POJOs for HTTP mapping
          2. Using HTTP redirects
          3. Thread safety
        5. See also
      7. Defining your own models
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using finders
          2. Never be anemic
          3. Learning from the existing examples
          4. Regarding JPA and transactions
        5. See also
      8. Using fixtures to provide initial data
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Using a bootstrap job to load seed data
          2. More information about YAML
          3. Using lists in YAML
      9. Defining your own views
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Check out more possible template tags
          2. Check out more predefined variables
          3. Supporting multiple formats
        4. See also
      10. Writing your own tags
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using parameters and more inside tags
          2. Higher rendering performance by using FastTags
        5. See also
      11. Using Java Extensions to format data in your views
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using parameters in extensions
          2. Check for more built in Java Extensions
          3. Check for internationalization on plurals
      12. Adding modules to extend your application
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Module documentation
          2. Updating modules
          3. More on the search module
        5. See also
      13. Using Oracle or other databases with Play
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Using application server datasources
          2. Using connection pools
          3. Configuring your JPA dialect
      14. Understanding suspendable requests
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More about promises
          2. More about jobs
          3. More information about execution times
        5. See also
      15. Understanding session management
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Configuring different cache types
          2. Using the cache to offload database load
        4. See also
    10. 2. Using Controllers
      1. Introduction
      2. URL routing using annotation-based configuration
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Mixing the configuration file and annotations is possible
      3. Basics of caching
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More information in the ActionInvoker
          2. Be thoughtful with ETag calculation
          3. Use a plugin instead of a job
        5. See also
      4. Using HTTP digest authentication
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Get more info about HTTP digest authentication
        5. See also
      5. Generating PDFs in your controllers
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More about Apache FOP
          2. Using other solutions to create PDFs
        5. See also
      6. Binding objects using custom binders
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Using type binders on objects
          2. Be careful with JPA using model classes
      7. Validating objects using annotations
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using the configure() method for setup
          2. Annotations can be used in models as well
      8. Adding annotation-based right checks to your controller
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Be flexible with roles instead of rights
          2. More speed with caching
          3. Increased complexity with context-sensitive rights
          4. Check out the deadbolt module
      9. Rendering JSON output
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More about Google gson
          2. Alternatives to Google gson
      10. Writing your own renderRSS method as controller output
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using annotations to make your code more generic
          2. Using ROME modules
          3. Cache at the right place
    11. 3. Leveraging Modules
      1. Introduction
      2. Dependency injection with Spring
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Use the component scanning feature
          2. Have Spring configurations per ID
          3. Direct access to the application context
        5. See also
      3. Dependency injection with Guice
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Default @Inject support of play
          2. Creating own injectors
      4. Using the security module
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Declare only one security class
          2. Implementing rights per controller with the secure module
      5. Adding security to the CRUD module
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Changing the design of the CRUD user interface
          2. Checking out the scaffold module
      6. Using the MongoDB module
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Check out the Yabe example in the Morphia directory
          2. Use long based data types as unique IDs
          3. Aggregation and grouping via map reduce
      7. Using MongoDB/GridFS to deliver files
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using MongoDB's REST API
          2. Resizing images on the fly
    12. 4. Creating and Using APIs
      1. Introduction
      2. Using Google Chart API as a tag
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Getting request data inside a fast tag
          2. The Google Chart API
          3. Make a graceful and more performant implementation
          4. Considering privacy when transmitting data
      3. Including a Twitter search in your application
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Make it a client side API
          2. Add caching to your code late
          3. Be fast with asynchronous queries
      4. Managing different output formats
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Integrating arbitrary formats
          2. Getting out AMF formats
        5. See also
      5. Binding JSON and XML to objects
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Add the XML annotations via byte code enhancement
          2. Put plugins where they belong
          3. Change your render methods to use JAXB for rendering
        5. See also
    13. 5. Introduction to Writing Modules
      1. Introduction
      2. Creating and using your own module
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Cleaning up after creating your module
          2. Supporting Eclipse IDE
      3. Building a flexible registration module
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Think about when to write a module
      4. Understanding events
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Think about multi-node environments
      5. Managing module dependencies
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Learn more about dependency management with play
          2. Search for jar files in Maven repositories
        5. See also
      6. Using the same model for different applications
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Learn more about bytecode enhancers
          2. Check the modules for even more enhancers
        4. See also
      7. Understanding bytecode enhancement
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Overriding toString() via annotation
        5. See also
      8. Adding private module repositories
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Check the official documentation
          2. Repositories with older versions
      9. Preprocessing content by integrating stylus
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More information about CSS preprocessing
      10. Integrating Dojo by adding command line options
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More about Dojo
          2. Create operating system independent modules
          3. More ideas for command support
    14. 6. Practical Module Examples
      1. Introduction
      2. Adding annotations via bytecode enhancement
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Javassist documentation
      3. Implementing your own persistence layer
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Check the JPA and Morphia plugins
      4. Integrating with messaging queues
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More info about AMQP
      5. Using Solr for indexing
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More information about SolrJ
          2. More complex queries
          3. Support for other search engines
      6. Writing your own cache implementation
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More about Hazelcast
          2. Try building a Redis cache
    15. 7. Running in Production
      1. Introduction
      2. Test automation with Jenkins
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Other plugins might be useful
          2. Check out the new play Jenkins plugin
      3. Test automation with Calimoucho
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using git with Calimoucho
          2. Using mercurial with Calimoucho
          3. Using subversion with Calimoucho
      4. Creating a distributed configuration service
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More on memcached
        5. See also
      5. Running jobs in a distributed environment
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Solving the locking problem
          2. Changing cache clear times
      6. Running one Play instance for several hosts
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Implementing multi tenant applications using hibernate
          2. A virtual hosting module
          3. Using properties to be more flexible
      7. Forcing SSL for chosen controllers
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. Implementing own monitoring points
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More about JAMon
        5. See also
      9. Configuring log4j for log rotation
        1. How to do it...
        2. How it works...
        3. There's more...
          1. More about log4j
          2. Default log levels of others frameworks
      10. Integrating with Icinga
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Find out more about Icinga
        5. See also
      11. Integrating with Munin
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Find out more about Munin and its plugins
          2. Add and graph hit counts, tag runtimes, running jobs, and so on
      12. Setting up the Apache web server with Play
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Transparent upgrade of your application
      13. Setting up the Nginx web server with Play
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More information about Nginx
          2. Better load balancing
          3. Transparent upgrade of your application
      14. Setting up the Lighttpd web server with Play
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Learn more about lighttpd
      15. Multi-node deployment introduction
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Add centralized logging to your multi node installation
          2. Distributing configuration files in a different way
    16. A. Further Information About the Play Framework
      1. Further information
        1. Links
        2. Twitter
    17. Index
3.14.142.194