Sorry I made a small mistake in my code (caused by copy/paste) so below now 
hopefully without bugs:


class NinjaAppModule extends AbstractModule {
    @Inject
    Injector injector;

    configure() {
        
bind(ServerConfig.class).toProvider(ServerConfigProvider.class).asEagerSingleton();
        
bind(EbeanServer.class).toProvider(EbeanServerProvider.class).asEagerSingleton();
        *CurrentUserProviderImpl userProvider = new 
CurrentUserProviderImpl(injector);*
*        bind(CurrentUserProvider.class).toInstance(userProvider);*
   }
}


class CurrentUserProviderImpl implements *CurrentUserProvider* {   //* 
CurrentUserProvide is 
Ebean's interface that does not know anything about Guice*
    Injector injector; 
    
    public CurrentUserProviderImpl(*Injector injector*) {
        this.injector = injector;
    }

    @Override 
    public Long currentUser() {
        RequestSession session = 
*injector.getInstance(RequestSession.class);*
        return session.get("userID");
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/07fc0b67-5db4-4c89-beb1-c00552e128f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to