play.api

inject

package inject

Visibility
  1. Public
  2. All

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.

    Stop hooks are executed when the application is shutdown, in reverse from when they were registered.

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

  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.

  3. final case class BindingKey[T](clazz: Class[T], qualifier: Option[QualifierAnnotation] = None) 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.

  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.

  6. class BuiltinModule extends Module

  7. final case class ConstructionTarget[T](implementation: Class[_ <: T]) extends BindingTarget[T] with Product with Serializable

    A binding target that is provided by a class.

  8. class DefaultApplicationLifecycle extends ApplicationLifecycle

    Default implementation of the application lifecycle.

    Default implementation of the application lifecycle.

    Annotations
    @Singleton()
  9. 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.

  10. 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 creating a resource on the classpath called play.modules. This file is expected to contain a list of module classes, one class per line. For example:

    com.example.FooModule
    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]
    )
  11. class PluginsProvider extends Provider[Plugins]

    Annotations
    @Singleton()
  12. 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.

  13. 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.

  14. 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.

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

    A qualifier annotation class.

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

    A qualifier annotation instance.

  17. class RoutesProvider extends Provider[core.Router.Routes]

    Annotations
    @Singleton()
  18. class SimpleInjector extends Injector

    A simple map backed injector.

    A simple map backed injector.

    This injector is intended for use 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.

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

Value Members

  1. object Modules

  2. object NewInstanceInjector extends Injector

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

  3. package guice

Ungrouped