In association with heise online

08 February 2013, 12:10

Play 2.1 adds modular routing and builds on Scala 2.1

  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit

Play Framework logo

Version 2.1 of web application framework Play has been upgraded to work with Scala 2.10, so developers can now use the features provided by the language update. One important feature, the Futures and Promises API of Scala 2.1, provides a non-blocking asynchronous model for services which is ideal for a web framework such as Play. Play is now migrating to using scala.concurrent.Future and future datastore drivers will also use the new API.

While the framework has moved to the new version of Scala, the developers have ensured there is no dependency between the Scala version at build time and at runtime, which should open the way for testing Play on future Scala versions.

The Play project itself has been broken down into a set of modules which can be selected according to application needs. A play core module can, with limited dependencies, act as an asynchronous, high performance HTTP server without the other modules.

To enable Play projects, as they grow, to be easily broken down into sub-projects, the Play developers have added the ability for Play route files to include the routing of a run-project with a simple "->" syntax. This means, for example, if a coder wants the routes of project xyz under the URL prefix "/tests", they could add "-> /tests xyz.Routes" to the master routes file to include it.

For architectural reasons, the previous major release had a problem retaining the HTTP context in the Java API during asynchronous callbacks. These run on different threads to the HTTP requests, a problem which has been resolved in Play 2.1 by having Http.Context propagated via a stack. The asynchronous model has also pushed the developers to improve callback execution synchronisation at a framework level.

Another new feature, in addition to being able to call static methods on a controller, is the ability, via a new routes syntax, to implement dependency injection for controllers. To do this, the controller method in the route files is simply prefixed with @. Instances can then be returned in the Global class using getControllerInstance. A sample application for this is available on GitHub.

Other new features include a Scala JSON API, a filter API and improved content negotiation. All of the changes are described in the documentation. The framework and source code are available from the download area on the Play web site and on GitHub. Play is licensed under the Apache 2.0 License.

(fab)

Print Version | Send by email | Permalink: http://h-online.com/-1800585
 


  • July's Community Calendar





The H Open

The H Security

The H Developer

The H Internet Toolkit