Basic usage of dependency injection is done by the annotations. When you need to tweak things a little bit, you need custom code to further specify how you want some classes to be instantiated and injected. This code goes in what is called a Module.
import com.google.inject.AbstractModule
// Play will automatically use any class called `Module` that is in the root package
class Module extends AbstractModule {
override def configure() = {
// Here you can put your customisation code.
// The annotations are still used, but you can override or complete them.
// Bind a class to a manual instantiation of it
// i.e. the FunkService needs not to have any annotation, but can still
// be injected in other classes
bind(classOf[FunkService]).toInstance(new FunkService)
// Bind an interface to a class implementing it
// i.e. the DiscoService interface can be injected into another class
// the DiscoServiceImplementation is the concrete class that will
// be actually injected.
bind(classOf[DiscoService]).to(classOf[DiscoServiceImplementation])
// Bind a class to itself, but instantiates it when the application starts
// Useful to executes code on startup
bind(classOf[HouseMusicService]).asEagerSingleton()
}
}