SimpleInjector

play.api.inject.SimpleInjector
class SimpleInjector(fallback: Injector, components: Map[Class[_], Any]) extends 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.

Value parameters

components

The components that this injector provides.

fallback

The injector to fallback to if no component can be found.

Attributes

Graph
Supertypes
trait Injector
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def +[T](component: T)(implicit ct: ClassTag[T]): SimpleInjector

Add a component to the injector.

Add a component to the injector.

Attributes

def add[T](clazz: Class[T], component: T): SimpleInjector

Add a component to the injector.

Add a component to the injector.

Attributes

def instanceOf[T](implicit ct: ClassTag[T]): T

Get an instance of the given class from the injector.

Get an instance of the given class from the injector.

Attributes

def instanceOf[T](clazz: Class[T]): T

Get an instance of the given class from the injector.

Get an instance of the given class from the injector.

Attributes

def instanceOf[T](key: BindingKey[T]): T

Get an instance bound to the given binding key.

Get an instance bound to the given binding key.

Attributes

Inherited methods

def asJava: Injector

Get as an instance of the Java injector.

Get as an instance of the Java injector.

Attributes

Inherited from:
Injector