Chapter 13. Writing Play Plugins

In order to make our applications manageable, we break them down into independent modules. These modules can also be extracted into individual projects/libraries.

A Play plugin is nothing but another module with an additional ability—of binding tasks before starting, on starting and/or stopping a Play application. In this chapter, we will see how to write custom plugins.

In this chapter, we will cover the following topics:

  • Plugin definition
  • Plugin declaration
  • Exposing services through plugins
  • Tips for writing a plugin

Plugin definition

A Play plugin can be defined by extending play.api.plugin, which is defined as follows:

trait Plugin { //Called when the application starts. def onStart() {} // Called when the application ...

Get Mastering Play Framework for Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.