Fix for requireExplicitBindings bug with ManagedFilterPipeline. Added a testcase too.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1174 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/servlet/src/com/google/inject/servlet/GuiceFilter.java b/servlet/src/com/google/inject/servlet/GuiceFilter.java
index 1ad863d..bd2a773 100644
--- a/servlet/src/com/google/inject/servlet/GuiceFilter.java
+++ b/servlet/src/com/google/inject/servlet/GuiceFilter.java
@@ -75,9 +75,8 @@
+ " ServletModule in your web application. While you may "
+ "have more than one injector, you should only configure"
+ " guice-servlet in one of them. (Hint: look for legacy "
- + "ServetModules or multiple calls to Servlets.configure())."
- + "You typically see this error if are not using."
- + GuiceServletContextListener.class.getSimpleName()
+ + "ServetModules). You typically see this error if are not"
+ + " using " + GuiceServletContextListener.class.getSimpleName()
+ " as described in the documentation.";
//VisibleForTesting
diff --git a/servlet/src/com/google/inject/servlet/InternalServletModule.java b/servlet/src/com/google/inject/servlet/InternalServletModule.java
index c58ca99..f3a9981 100644
--- a/servlet/src/com/google/inject/servlet/InternalServletModule.java
+++ b/servlet/src/com/google/inject/servlet/InternalServletModule.java
@@ -2,8 +2,6 @@
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
-import static com.google.inject.servlet.ServletScopes.REQUEST;
-import static com.google.inject.servlet.ServletScopes.SESSION;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
@@ -12,6 +10,9 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import static com.google.inject.servlet.ServletScopes.REQUEST;
+import static com.google.inject.servlet.ServletScopes.SESSION;
+
/**
* This is a left-factoring of all ServletModules installed in the system.
* In other words, this module contains the bindings common to all ServletModules,
@@ -32,6 +33,7 @@
// Unfortunate staticness... =(
requestStaticInjection(GuiceFilter.class);
+ bind(ManagedFilterPipeline.class);
bind(ManagedServletPipeline.class);
bind(FilterPipeline.class).to(ManagedFilterPipeline.class).asEagerSingleton();
}
diff --git a/servlet/test/com/google/inject/servlet/EdslTest.java b/servlet/test/com/google/inject/servlet/EdslTest.java
index 2fffd01..9774a3d 100644
--- a/servlet/test/com/google/inject/servlet/EdslTest.java
+++ b/servlet/test/com/google/inject/servlet/EdslTest.java
@@ -16,8 +16,11 @@
package com.google.inject.servlet;
import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.InjectorBuilder;
import com.google.inject.Key;
import com.google.inject.Module;
+import com.google.inject.Singleton;
import com.google.inject.Stage;
import java.util.HashMap;
import junit.framework.TestCase;
@@ -29,6 +32,18 @@
*/
public class EdslTest extends TestCase {
+ public final void testExplicitBindingsWorksWithGuiceServlet() {
+ Injector injector = new InjectorBuilder().requireExplicitBindings()
+ .addModules(new ServletModule() {
+ @Override protected void configureServlets() {
+ bind(DummyServlet.class).in(Singleton.class);
+ serve("/*").with(DummyServlet.class);
+ }
+ }).build();
+
+ assertNotNull(injector.getInstance(DummyServlet.class));
+ }
+
public final void testConfigureServlets() {
//the various possible config calls--