Package

play

api

Permalink

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
Visibility
  1. Public
  2. All

Type Members

  1. trait Application extends AnyRef

    Permalink

    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. trait ApplicationLoader extends AnyRef

    Permalink

    Loads an application.

    Loads an application. This is responsible for instantiating an application given a context.

    Application loaders are expected to instantiate all parts of an application, wiring everything together. They may be manually implemented, if compile time wiring is preferred, or core/third party implementations may be used, for example that provide a runtime dependency injection framework.

    During dev mode, an ApplicationLoader will be instantiated once, and called once, each time the application is reloaded. In prod mode, the ApplicationLoader will be instantiated and called once when the application is started.

    Out of the box Play provides a Java and Scala default implementation based on Guice. The Scala implementation is the play.api.inject.guice.GuiceApplicationLoader.

    A custom application loader can be configured using the application.loader configuration property. Implementations must define a no-arg constructor.

  3. trait BuiltInComponents extends AnyRef

    Permalink

    Helper to provide the Play built in components.

  4. abstract class BuiltInComponentsFromContext extends BuiltInComponents

    Permalink

    Helper that provides all the built in components dependencies from the application loader context

  5. case class Configuration(underlying: Config) extends Product with Serializable

    Permalink

    A full configuration set.

    A full configuration set.

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

    underlying

    the underlying Config implementation

  6. class DefaultApplication extends Application

    Permalink
    Annotations
    @Singleton()
  7. case class Environment(rootPath: File, classLoader: ClassLoader, mode: Mode.Mode) extends Product with Serializable

    Permalink

    The environment for the application.

    The environment for the application.

    Captures concerns relating to the classloader and the filesystem for the application.

    rootPath

    The root path that the application is deployed at.

    classLoader

    The classloader that all application classes and resources can be loaded from.

    mode

    The mode of the application.

  8. class Logger extends LoggerLike

    Permalink

    A Play logger.

  9. trait LoggerConfigurator extends AnyRef

    Permalink

    Runs through underlying logger configuration.

  10. trait LoggerLike extends AnyRef

    Permalink

    Typical logger interface.

  11. class OptionalSourceMapper extends AnyRef

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

    Permalink

    Generic exception for unexpected error cases.

  13. trait GlobalSettings extends AnyRef

    Permalink

    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!!!")
      }
    
    }
    Annotations
    @deprecated
    Deprecated

    (Since version 2.5.0) Use dependency injection

Value Members

  1. object Application

    Permalink
  2. object ApplicationLoader

    Permalink
  3. object Configuration extends Serializable

    Permalink

    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.

  4. object DefaultGlobal extends Deprecated

    Permalink

    The default global settings if not defined in the application.

  5. object Environment extends Serializable

    Permalink
  6. object GlobalSettings

    Permalink
  7. object Logger extends LoggerLike

    Permalink

    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!")
  8. object LoggerConfigurator

    Permalink
  9. object Mode extends Enumeration

    Permalink

    Application mode, either DEV, TEST, or PROD.

  10. object Play

    Permalink

    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
  11. package cache

    Permalink

    Contains the Cache access API.

  12. package data

    Permalink

    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
      )
    )
  13. package db

    Permalink

    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")
  14. package http

    Permalink

    Contains standard HTTP constants.

    Contains standard HTTP constants. For example:

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

    Permalink

    Contains the internationalisation API.

    Contains the internationalisation API.

    For example, translating a message:

    val msgString = Messages("items.found", items.size)
  16. package inject

    Permalink

    Play's runtime dependency injection abstraction.

    Play's runtime dependency injection abstraction.

    Play's runtime dependency injection support is built on JSR-330, which provides a specification for declaring how dependencies get wired to components. JSR-330 however does not address how components are provided to or located by a DI container. Play's API seeks to address this in a DI container agnostic way.

    The reason for providing this abstraction is so that Play, the modules it provides, and third party modules can all express their bindings in a way that is not specific to any one DI container.

    Components are bound in the DI container. Each binding is identified by a BindingKey, which is typically an interface that the component implements, and may be optionally qualified by a JSR-330 qualifier annotation. A binding key is bound to a BindingTarget, which describes how the implementation of the interface that the binding key represents is constructed or provided. Bindings may also be scoped using JSR-330 scope annotations.

    Bindings are provided by instances of Module.

    Out of the box, Play provides an implementation of this abstraction using Guice.

    See also

    The Module class for information on how to provide bindings.

  17. package libs

    Permalink

    Contains various APIs that are useful while developing web applications.

  18. package mvc

    Permalink

    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!")
      }
    
    }
  19. package routing

    Permalink
  20. package templates

    Permalink
  21. package test

    Permalink

    Contains test helpers.

Inherited from AnyRef

Inherited from Any

Ungrouped