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.

    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)
    Definition Classes
    play
  • 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
    Definition Classes
    inject
  • ApplicationLifecycle
  • Binding
  • BindingKey
  • BindingKeyTarget
  • BindingTarget
  • BuiltinModule
  • ConfigProvider
  • ConfigurationProvider
  • ConstructionTarget
  • DefaultApplicationLifecycle
  • Injector
  • Module
  • Modules
  • NewInstanceInjector
  • ProviderConstructionTarget
  • ProviderTarget
  • QualifierAnnotation
  • QualifierClass
  • QualifierInstance
  • RoutesProvider
  • SimpleInjector
  • SimpleModule

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

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.

Source
Binding.scala
See also

The Module class for information on how to provide bindings.

Linear Supertypes
Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BindingKey
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new BindingKey(clazz: Class[T])
  2. new BindingKey(clazz: Class[T], qualifier: Option[QualifierAnnotation])

    clazz

    The class to bind.

    qualifier

    An optional qualifier.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def asJava: inject.BindingKey[T]
  6. val clazz: Class[T]
  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. def productElementNames: Iterator[String]
    Definition Classes
    Product
  16. def qualifiedWith(name: String): BindingKey[T]

    Qualify this binding key with the given name.

    Qualify this binding key with the given name.

    For example, you may have both a cached implementation, and a direct implementation of a service. To differentiate between them, you may decide to name the cached one:

    bind[Foo].qualifiedWith("cached").to[FooCached],
    bind[Foo].to[FooImpl]
    
    ...
    
    class MyController @Inject() (@Named("cached") foo: Foo) {
      ...
    }

    In the above example, the controller will get the cached Foo service.

  17. def qualifiedWith[A <: Annotation](implicit arg0: ClassTag[A]): BindingKey[T]

    Qualify this binding key with the given annotation.

    Qualify this binding key with the given annotation.

    For example, you may have both a cached implementation, and a direct implementation of a service. To differentiate between them, you may define a Cached annotation:

    import scala.annotation._
    
    @target.param
    class Cached extends StaticAnnotation
    
    ...
    
    bind[Foo].qualifiedWith[Cached].to[FooCached],
    bind[Foo].to[FooImpl]
    
    ...
    
    class MyController @Inject() (@Cached foo: Foo) {
      ...
    }

    In the above example, the controller will get the cached Foo service.

  18. def qualifiedWith[A <: Annotation](annotation: Class[A]): BindingKey[T]

    Qualify this binding key with the given annotation.

    Qualify this binding key with the given annotation.

    For example, you may have both a cached implementation, and a direct implementation of a service. To differentiate between them, you may define a Cached annotation:

    import scala.annotation._
    
    @target.param
    class Cached extends StaticAnnotation
    
    ...
    
    bind[Foo].qualifiedWith(classOf[Cached]).to[FooCached],
    bind[Foo].to[FooImpl]
    
    ...
    
    class MyController @Inject() (@Cached foo: Foo) {
      ...
    }

    In the above example, the controller will get the cached Foo service.

  19. def qualifiedWith[A <: Annotation](instance: A): BindingKey[T]

    Qualify this binding key with the given instance of an annotation.

    Qualify this binding key with the given instance of an annotation.

    This can be used to specify bindings with annotations that have particular values.

  20. val qualifier: Option[QualifierAnnotation]
  21. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  22. def to(key: BindingKey[_ <: T]): Binding[T]

    Bind this binding key to another binding key.

  23. def to[A <: T](instance: => A): Binding[T]

    Bind this binding key to the given instance.

  24. def to(provider: Provider[_ <: T]): Binding[T]

    Bind this binding key to the given provider instance.

    Bind this binding key to the given provider instance.

    This provider instance will be invoked to obtain the implementation for the key.

  25. def to[C <: T](implicit arg0: ClassTag[C]): Binding[T]

    Bind this binding key to the given implementation class.

    Bind this binding key to the given implementation class.

    This class will be instantiated and injected by the injection framework.

  26. def to(implementation: Class[_ <: T]): Binding[T]

    Bind this binding key to the given implementation class.

    Bind this binding key to the given implementation class.

    This class will be instantiated and injected by the injection framework.

  27. def toInstance(instance: T): Binding[T]

    Bind this binding key to the given instance.

  28. def toProvider[P <: Provider[_ <: T]](implicit arg0: ClassTag[P]): Binding[T]

    Bind this binding key to the given provider class.

    Bind this binding key to the given provider class.

    The dependency injection framework will instantiate and inject this provider, and then invoke its get method whenever an instance of the class is needed.

  29. def toProvider[P <: Provider[_ <: T]](provider: Class[P]): Binding[T]

    Bind this binding key to the given provider class.

    Bind this binding key to the given provider class.

    The dependency injection framework will instantiate and inject this provider, and then invoke its get method whenever an instance of the class is needed.

  30. def toSelf: Binding[T]

    Bind this binding key to itself.

  31. def toString(): String
    Definition Classes
    BindingKey → AnyRef → Any
  32. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  33. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  34. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped