public void testGuiceInjectionWithResources()
throws Exception
{
final DummyServlet servlet = new DummyServlet();
Bootstrap app = new Bootstrap(
new TestingNodeModule(),
new TestingHttpServerModule(),
new Module()
{
@Override
public void configure(Binder binder)
{
binder.bind(Servlet.class).annotatedWith(TheServlet.class).toInstance(servlet);
binder.bind(new TypeLiteral<Map<String, String>>() {}).annotatedWith(TheServlet.class).toInstance(ImmutableMap.<String, String>of());
httpServerBinder(binder).bindResource("/", "webapp/user").withWelcomeFile("user-welcome.txt");
httpServerBinder(binder).bindResource("/", "webapp/user2");
httpServerBinder(binder).bindResource("path", "webapp/user").withWelcomeFile("user-welcome.txt");
httpServerBinder(binder).bindResource("path", "webapp/user2");
}
});
Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.initialize();
LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);