Skip to content

Instantly share code, notes, and snippets.

@codingricky
Created January 9, 2014 04:43
Show Gist options
  • Save codingricky/8329508 to your computer and use it in GitHub Desktop.
Save codingricky/8329508 to your computer and use it in GitHub Desktop.
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import play.Application;
import play.GlobalSettings;
import services.GreetingService;
import services.RealGreetingService;
public class Global extends GlobalSettings {
private Injector injector;
@Override
public void onStart(Application application) {
injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(GreetingService.class).to(RealGreetingService.class);
}
});
}
@Override
public <T> T getControllerInstance(Class<T> aClass) throws Exception {
return injector.getInstance(aClass);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment