Mastering Play Framework for Scala

Book description

Leverage the awesome features of Play Framework to build scalable, resilient, and responsive applications

In Detail

Play Framework is an open source web application framework that is written in Java and Scala. It follows the Model-View-Controller architectural pattern and enables the user to employ Scala for application development, while keeping key properties and features of Play Framework intact.

Starting off by building a basic application with minimal features, you get a detailed insight into handling data transactions and designing models in Play. Next, you venture into the concepts of Actors and WebSockets, the process of manipulating data streams, and testing and debugging an application in Play. Finally, you gain an insight into extending the framework by writing custom modules or plugins in Play. Each chapter has a troubleshooting section that helps you out by discussing the causes of, and solutions to, some commonly faced issues.

What You Will Learn

  • Customize your framework to accommodate the specific requirements of an application
  • Develop responsive, reliable, and highly scalable applications using Play Framework
  • Build and customize Play Framework plugins that can be used in multiple Play applications
  • Familiarize yourself with third-party APIs to avoid rewriting existing code
  • Gain an insight into the various aspects of testing and debugging in Play to successfully test your apps
  • Get to know all about the concepts of WebSockets and Actors to process messages based on events

Table of contents

  1. Mastering Play Framework for Scala
    1. Table of Contents
    2. Mastering Play Framework for Scala
    3. Credits
    4. About the Author
    5. Acknowledgments
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    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. Getting Started with Play
      1. Venturing into the world of Play
        1. A sample Play app
          1. Building a Play application using Activator
            1. The build definition
            2. The source code
            3. Request handling process
        2. Creating a TaskTracker application
          1. Adding a new task
          2. Deleting a task
      2. Summary
    10. 2. Defining Actions
      1. A dummy Artist model
      2. Actions
        1. Actions with parameters
      3. Request body parsers
      4. Extending a parser
      5. Exploring the results
      6. Asynchronous Actions
      7. Content negotiation
      8. Filters
      9. Action composition
        1. The need for an Action composition
        2. Differentiating between Action composition and filters
        3. Customized requests
        4. The need for a user object
      10. Troubleshooting
      11. Summary
    11. 3. Building Routes
      1. Introduction to Play routes
        1. Automatic generation of routes_routing.scala
      2. Reverse routing
        1. JavaScript reverse routing
      3. Assets
        1. Client-side libraries
      4. Configuring route definitions
        1. Dynamic paths
        2. Static paths
      5. Configuring request parameters
      6. Troubleshooting
      7. Summary
    12. 4. Exploring Views
      1. Diving into Scala templates
        1. Building a view
      2. Generating forms
        1. Adding constraints on data
        2. Handling errors
        3. Form-field helpers
      3. Internationalization
        1. Supporting views in multiple languages
        2. Understanding internationalization
      4. Scala templating in Play
        1. Understanding the working of Twirl
      5. Troubleshooting
      6. Summary
    13. 5. Working with Data
      1. Introducing models
      2. JDBC
      3. Anorm
      4. Slick
      5. ReactiveMongo
      6. The Cache API
      7. Troubleshooting
      8. Summary
    14. 6. Reactive Data Streams
      1. Basics of handling data streams
      2. Iteratees
      3. Enumerator
        1. Using the Concurrent object
          1. Unicast
          2. Broadcast
      4. Enumeratees
        1. Binding an Enumeratee to an Enumerator
        2. Binding an Enumeratee to an Iteratee
      5. Summary
    15. 7. Playing with Globals
      1. GlobalSettings
      2. The life cycle of an application
        1. Meddling with an application's life cycle
      3. The request-response life cycle
        1. Fiddling with the request-response life cycle
          1. Manipulating requests and their responses
          2. Tackling errors and exceptions
      4. Summary
    16. 8. WebSockets and Actors
      1. An introduction to WebSockets
      2. WebSockets in Play
      3. Actor Model
      4. Introducing Akka Actors
      5. WebSocket using Iteratee
      6. WebSocket using Actors without Iteratees
      7. Closing a WebSocket
        1. Using FrameFormatter
      8. Troubleshooting
      9. Summary
    17. 9. Testing
      1. The setup for writing tests
      2. Unit testing
      3. Dissecting PlaySpecification
      4. Unit testing a controller
        1. Using traits for controllers
        2. Using dependency injection
      5. Functional testing
        1. Using Specs2
        2. Using ScalaTest
      6. Summary
    18. 10. Debugging and Logging
      1. Debugging a Play application
        1. Configuring an IDE for debugging
      2. Experimenting in a Scala console
      3. Logging
      4. Play's logging API
      5. Log configuration in Play
        1. Log levels
      6. Summary
    19. 11. Web Services and Authentication
      1. Calling web services
      2. OpenID
      3. OAuth
      4. Summary
    20. 12. Play in Production
      1. Deploying a Play application
        1. Using the start command
        2. Using a distribution
          1. Universal distribution
          2. Debian distribution
          3. The rpm distribution
          4. Windows distribution
      2. Configuring for production
      3. Enabling SSL
      4. Using a load balancer
        1. Apache HTTP
        2. The nginx server
        3. lighttpd
        4. High Availability Proxy
      5. Troubleshooting
      6. Summary
    21. 13. Writing Play Plugins
      1. Plugin definition
      2. Plugin declaration
      3. Exposing services through plugins
      4. Tips for writing a plugin
      5. Summary
    22. Index

Product information

  • Title: Mastering Play Framework for Scala
  • Author(s): Shiti Saxena
  • Release date: May 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781783983803