play

api

package api

Contains the public API for Scala developers.

Access the current Play application
import play.api.Play.current
Read configuration
val poolSize = configuration.getInt("engine.pool.size")
Use the logger
Logger.info("Hello!")
Define a Plugin
class MyPlugin(app: Application) extends Plugin
Create adhoc applications (for testing)
val application = Application(new File("."), this.getClass.getClassloader, None, Play.Mode.DEV)
Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. api
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. trait Application extends AnyRef

    A Play application.

    A Play application.

    Application creation is handled by the framework engine.

    If you need to create an ad-hoc application, for example in case of unit testing, you can easily achieve this using:

    val application = new DefaultApplication(new File("."), this.getClass.getClassloader, None, Play.Mode.Dev)

    This will create an application using the current classloader.

    Annotations
    @implicitNotFound( ... )
  2. case class Configuration(underlying: Config) extends Product with Serializable

    A full configuration set.

    A full configuration set.

    The underlying implementation is provided by https://github.com/typesafehub/config.

    underlying

    the underlying Config implementation

  3. class DefaultApplication extends Application with WithDefaultConfiguration with WithDefaultGlobal with WithDefaultPlugins

  4. class GlobalPlugin extends Plugin

    The Global plugin executes application's globalSettings onStart and onStop.

  5. trait GlobalSettings extends AnyRef

    Defines an application’s global settings.

    Defines an application’s global settings.

    To define your own global settings, just create a Global object in the _root_ package.

    object Global extends GlobalSettings {
    
    override def onStart(app: Application) {
      Logger.info("Application is started!!!")
    }
    
    }
  6. class Logger extends LoggerLike

    A Play logger.

  7. trait LoggerLike extends AnyRef

    Typical logger interface.

  8. trait Plugin extends AnyRef

    A Play plugin.

    A Play plugin.

    A plugin must define a single argument constructor that accepts an play.api.Application. For example:

    class MyPlugin(app: Application) extends Plugin {
    override def onStart() = {
      Logger.info("Plugin started!")
    }
    }

    The plugin class must be declared in a play.plugins file available in the classpath root:

    1000:myapp.MyPlugin

    The associated int defines the plugin priority.

  9. case class UnexpectedException(message: Option[String] = None, unexpected: Option[Throwable] = None) extends PlayException with Product with Serializable

    Generic exception for unexpected error cases.

  10. trait WithDefaultConfiguration extends AnyRef

  11. trait WithDefaultGlobal extends AnyRef

  12. trait WithDefaultPlugins extends AnyRef

Value Members

  1. object Configuration extends Serializable

    This object provides a set of operations to create Configuration values.

    This object provides a set of operations to create Configuration values.

    For example, to load a Configuration in a running application:

    val config = Configuration.load()
    val foo = config.getString("foo").getOrElse("boo")

    The underlying implementation is provided by https://github.com/typesafehub/config.

  2. object DefaultGlobal extends GlobalSettings

    The default global settings if not defined in the application.

  3. object Logger extends LoggerLike

    High-level API for logging operations.

    High-level API for logging operations.

    For example, logging with the default application logger:

    Logger.info("Hello!")

    Logging with a custom logger:

    Logger("my.logger").info("Hello!")
  4. object Mode extends Enumeration

    Application mode, either DEV, TEST, or PROD.

  5. object Play

    High-level API to access Play global features.

    High-level API to access Play global features.

    Note that this API depends on a running application. You can import the currently running application in a scope using:

    import play.api.Play.current
  6. object Routes

    Helper utilities related to Router.

  7. package cache

    Contains the Cache access API.

  8. package data

    Contains data manipulation helpers (typically HTTP form handling)

    Contains data manipulation helpers (typically HTTP form handling)

    import play.api.data._
    import play.api.data.Forms._
    
    val taskForm = Form(
      tuple(
        "name" -> text(minLength = 3),
        "dueDate" -> date("yyyy-MM-dd"),
        "done" -> boolean
      )
    )
  9. package db

    Contains the JDBC database access API.

    Contains the JDBC database access API.

    Example, retrieving a connection from the 'customers' datasource:

    val conn = DB.getConnection("customers")
  10. package http

    Contains standard HTTP constants.

    Contains standard HTTP constants. For example:

    val text = ContentTypes.TEXT
    val ok = Status.OK
    val accept = HeaderNames.ACCEPT
  11. package i18n

    Contains the internationalisation API.

    Contains the internationalisation API.

    For example, translating a message:

    val msgString = Messages("items.found", items.size)
  12. package libs

    Contains various APIs that are useful while developing web applications.

  13. package mvc

    Contains the Controller/Action/Result API to handle HTTP requests.

    Contains the Controller/Action/Result API to handle HTTP requests.

    For example, a typical controller:

    object Application extends Controller {
    
    def index = Action {
      Ok("It works!")
    }
    
    }
  14. package templates

    Contains Template adapters for typical Play applications.

  15. package test

    Contains test helpers.

Inherited from AnyRef

Inherited from Any

Ungrouped