Packages

  • package root
    Definition Classes
    root
  • package play

    Play framework.

    Play framework.

    Play

    http://www.playframework.com

    Definition Classes
    root
  • package api

    Contains the public API for Scala developers.

    Contains the public API for Scala developers.

    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)
    Definition Classes
    play
  • package cache

    Contains the Cache access API.

    Contains the Cache access API.

    Definition Classes
    api
  • package cluster
    Definition Classes
    api
  • package controllers
    Definition Classes
    api
  • 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
      )
    )
    Definition Classes
    api
  • 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")
    Definition Classes
    api
  • package http

    Contains standard HTTP constants.

    Contains standard HTTP constants. For example:

    val text = ContentTypes.TEXT
    val ok = Status.OK
    val accept = HeaderNames.ACCEPT
    Definition Classes
    api
  • package i18n

    Contains the internationalisation API.

    Contains the internationalisation API.

    For example, translating a message:

    val msgString = Messages("items.found", items.size)
    Definition Classes
    api
  • package inject

    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.

    Definition Classes
    api
    See also

    The Module class for information on how to provide bindings.

  • package guice
  • ApplicationLifecycle
  • Binding
  • BindingKey
  • BindingKeyTarget
  • BindingTarget
  • BuiltinModule
  • ConfigProvider
  • ConfigurationProvider
  • ConstructionTarget
  • DefaultApplicationLifecycle
  • Injector
  • Module
  • Modules
  • NewInstanceInjector
  • ProviderConstructionTarget
  • ProviderTarget
  • QualifierAnnotation
  • QualifierClass
  • QualifierInstance
  • RoutesProvider
  • SimpleInjector
  • SimpleModule
  • package internal
    Definition Classes
    api
  • package libs

    Contains various APIs that are useful while developing web applications.

    Contains various APIs that are useful while developing web applications.

    Definition Classes
    api
  • 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:

    class HomeController @Inject() (val controllerComponents: ControllerComponents) extends BaseController {
    
      def index = Action {
        Ok("It works!")
      }
    
    }
    Definition Classes
    api
  • package routing
    Definition Classes
    api
  • package templates
    Definition Classes
    api
  • package test

    Contains test helpers.

    Contains test helpers.

    Definition Classes
    api
p

play.api

inject

package inject

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.

Source
package.scala
See also

The Module class for information on how to provide bindings.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. inject
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Package Members

  1. package guice

Type Members

  1. trait ApplicationLifecycle extends AnyRef

    Application lifecycle register.

    Application lifecycle register.

    This is used to hook into Play lifecycle events, specifically, when Play is stopped. The reason Play only provides lifecycle callbacks for stopping is that constructors are considered the application start callback. This has several advantages:

    - It simplifies implementation, if you want to start something, just do it in the constructor. - It simplifies state, there's no transitional state where an object has been created but not started yet. Hence, as long as you have a reference to something, it's safe to use it. - It solves startup dependencies in a type safe manner - the order that components must be started is enforced by the order that they must be instantiated due to the component graph.

    Stop hooks are executed when the application is shutdown, in reverse from when they were registered. Due to this reverse ordering, a component can know that it is safe to use the components it depends on as long as it hasn't received a shutdown event.

    To use this, declare a dependency on ApplicationLifecycle, and then register the stop hook when the component is started. For example:

    import play.api.inject.ApplicationLifecycle
    import javax.inject.Inject
    
    class SomeDatabase @Inject() (applicationLifecycle: ApplicationLifecycle) {
    
      private val connectionPool = new SomeConnectionPool()
      applicationLifecycle.addStopHook { () =>
        Future.successful(connectionPool.shutdown())
      }
    
      ...
    }
  2. final case class Binding[T](key: BindingKey[T], target: Option[BindingTarget[T]], scope: Option[Class[_ <: Annotation]], eager: Boolean, source: AnyRef) extends Product with Serializable

    A binding.

    A binding.

    Bindings are used to bind classes, optionally qualified by a JSR-330 qualifier annotation, to instances, providers or implementation classes.

    Bindings may also specify a JSR-330 scope. If, and only if that scope is javax.inject.Singleton, then the binding may declare itself to be eagerly instantiated. In which case, it should be eagerly instantiated when Play starts up.

    key

    The binding key.

    target

    The binding target.

    scope

    The JSR-330 scope.

    eager

    Whether the binding should be eagerly instantiated.

    source

    Where this object was bound. Used in error reporting.

    See also

    The Module class for information on how to provide bindings.

  3. final case class BindingKey[T](clazz: Class[T], qualifier: Option[QualifierAnnotation]) extends Product with Serializable

    A binding key.

    A binding key.

    A binding key consists of a class and zero or more JSR-330 qualifiers.

    clazz

    The class to bind.

    qualifier

    An optional qualifier.

    See also

    The Module class for information on how to provide bindings.

  4. final case class BindingKeyTarget[T](key: BindingKey[_ <: T]) extends BindingTarget[T] with Product with Serializable

    A binding target that is provided by another key - essentially an alias.

  5. sealed trait BindingTarget[T] extends AnyRef

    A binding target.

    A binding target.

    This trait captures the four possible types of targets.

    See also

    The Module class for information on how to provide bindings.

  6. class BuiltinModule extends SimpleModule

    The Play BuiltinModule.

    The Play BuiltinModule.

    Provides all the core components of a Play application. This is typically automatically enabled by Play for an application.

  7. class ConfigProvider extends Provider[Config]
  8. class ConfigurationProvider extends Provider[Configuration]
  9. final case class ConstructionTarget[T](implementation: Class[_ <: T]) extends BindingTarget[T] with Product with Serializable

    A binding target that is provided by a class.

    A binding target that is provided by a class.

    See also

    The play.api.inject.Module class for information on how to provide bindings.

  10. class DefaultApplicationLifecycle extends ApplicationLifecycle

    Default implementation of the application lifecycle.

    Default implementation of the application lifecycle.

    Annotations
    @Singleton()
  11. trait Injector extends AnyRef

    An injector, capable of providing components.

    An injector, capable of providing components.

    This is an abstraction over whatever dependency injection is being used in Play. A minimal implementation may only call newInstance on the passed in class.

    This abstraction is primarily provided for libraries that want to remain agnostic to the type of dependency injection being used. End users are encouraged to use the facilities provided by the dependency injection framework they are using directly, for example, if using Guice, use com.google.inject.Injector instead of this.

  12. abstract class Module extends AnyRef

    A Play dependency injection module.

    A Play dependency injection module.

    Dependency injection modules can be used by Play plugins to provide bindings for JSR-330 compliant ApplicationLoaders. Any plugin that wants to provide components that a Play application can use may implement one of these.

    Providing custom modules can be done by appending their fully qualified class names to play.modules.enabled in application.conf, for example

    play.modules.enabled += "com.example.FooModule"
    play.modules.enabled += "com.example.BarModule"

    It is strongly advised that in addition to providing a module for JSR-330 DI, that plugins also provide a Scala trait that constructs the modules manually. This allows for use of the module without needing a runtime dependency injection provider.

    The bind methods are provided only as a DSL for specifying bindings. For example:

    def bindings(env: Environment, conf: Configuration) = Seq(
      bind[Foo].to[FooImpl],
      bind[Bar].to(new Bar()),
      bind[Foo].qualifiedWith[SomeQualifier].to[OtherFoo]
    )
  13. final case class ProviderConstructionTarget[T](provider: Class[_ <: Provider[_ <: T]]) extends BindingTarget[T] with Product with Serializable

    A binding target that is provided by a provider class.

    A binding target that is provided by a provider class.

    See also

    The Module class for information on how to provide bindings.

  14. final case class ProviderTarget[T](provider: Provider[_ <: T]) extends BindingTarget[T] with Product with Serializable

    A binding target that is provided by a provider instance.

    A binding target that is provided by a provider instance.

    See also

    The Module class for information on how to provide bindings.

  15. sealed trait QualifierAnnotation extends AnyRef

    A qualifier annotation.

    A qualifier annotation.

    Since bindings may specify either annotations, or instances of annotations, this abstraction captures either of those two possibilities.

    See also

    The Module class for information on how to provide bindings.

  16. final case class QualifierClass[T <: Annotation](clazz: Class[T]) extends QualifierAnnotation with Product with Serializable

    A qualifier annotation class.

    A qualifier annotation class.

    See also

    The Module class for information on how to provide bindings.

  17. final case class QualifierInstance[T <: Annotation](instance: T) extends QualifierAnnotation with Product with Serializable

    A qualifier annotation instance.

    A qualifier annotation instance.

    See also

    The Module class for information on how to provide bindings.

  18. class RoutesProvider extends Provider[Router]
    Annotations
    @Singleton()
  19. class SimpleInjector extends Injector

    A simple map backed injector.

    A simple map backed injector.

    This injector is intended for use by compile time injected applications in the transitional period between when Play fully supports dependency injection across the whole code base, and when some parts of Play still access core components through Play's global state. Since Play's global state requires that some components are still dynamically looked up from an injector, when using a compile time DI approach, there is typically no way to dynamically look up components, so this provides a simple implementation of the Injector trait to allow components that Play requires to be dynamically looked up.

    It is intended to just hold built in Play components, but may be used to add additional components by end users when required.

    The injector is an immutable structure, new components can be added using the + convenience method, which returns a new injector with that component included.

  20. class SimpleModule extends Module

    A simple Play module, which can be configured by passing a function or a list of bindings.

Value Members

  1. def bind[T](implicit arg0: ClassTag[T]): BindingKey[T]

    Create a binding key for the given class.

    Create a binding key for the given class.

    See also

    The Module class for information on how to provide bindings.

  2. def bind[T](clazz: Class[T]): BindingKey[T]

    Create a binding key for the given class.

    Create a binding key for the given class.

    See also

    The Module class for information on how to provide bindings.

  3. object BindingKey extends Serializable

    Constructor for a binding Key that doesn't have a qualifier.

    Constructor for a binding Key that doesn't have a qualifier.

    See also

    The Module class for information on how to provide bindings.

  4. object Modules

    Locates and loads modules from the Play environment.

  5. object NewInstanceInjector extends Injector

    An injector that simply creates a new instance of the passed in classes using the classes no-arg constructor.

  6. object RoutesProvider

Inherited from AnyRef

Inherited from Any

Ungrouped