AbstractDispatcherServletInitializer allows for registering any FrameworkServlet subclass
Issue: SPR-13616
This commit is contained in:
parent
9bed389d1f
commit
c1c07bbeb2
|
|
@ -32,6 +32,7 @@ import org.springframework.util.ObjectUtils;
|
|||
import org.springframework.web.context.AbstractContextLoaderInitializer;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
import org.springframework.web.servlet.FrameworkServlet;
|
||||
|
||||
/**
|
||||
* Base class for {@link org.springframework.web.WebApplicationInitializer}
|
||||
|
|
@ -90,7 +91,7 @@ public abstract class AbstractDispatcherServletInitializer extends AbstractConte
|
|||
"createServletApplicationContext() did not return an application " +
|
||||
"context for servlet [" + servletName + "]");
|
||||
|
||||
DispatcherServlet dispatcherServlet = createDispatcherServlet(servletAppContext);
|
||||
FrameworkServlet dispatcherServlet = createDispatcherServlet(servletAppContext);
|
||||
dispatcherServlet.setContextInitializers(getServletApplicationContextInitializers());
|
||||
|
||||
ServletRegistration.Dynamic registration = servletContext.addServlet(servletName, dispatcherServlet);
|
||||
|
|
@ -132,9 +133,12 @@ public abstract class AbstractDispatcherServletInitializer extends AbstractConte
|
|||
protected abstract WebApplicationContext createServletApplicationContext();
|
||||
|
||||
/**
|
||||
* Create a {@link DispatcherServlet} with the specified {@link WebApplicationContext}.
|
||||
* Create a {@link DispatcherServlet} (or other kind of {@link FrameworkServlet}-derived
|
||||
* dispatcher) with the specified {@link WebApplicationContext}.
|
||||
* <p>Note: This allows for any {@link FrameworkServlet} subclass as of 4.2.3.
|
||||
* Previously, it insisted on returning a {@link DispatcherServlet} or subclass thereof.
|
||||
*/
|
||||
protected DispatcherServlet createDispatcherServlet(WebApplicationContext servletAppContext) {
|
||||
protected FrameworkServlet createDispatcherServlet(WebApplicationContext servletAppContext) {
|
||||
return new DispatcherServlet(servletAppContext);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue