package org.jibeframework.core.app.request;
import java.util.Enumeration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
/**
*
* @author dhalupa
*
*/
public class JibeSpringMvcDispatcher extends DispatcherServlet implements ApplicationContextAware, ServletContextAware,
InitializingBean {
private static final long serialVersionUID = 1L;
private ApplicationContext applicationContext;
private ServletContext servletContext;
@Override
protected WebApplicationContext initWebApplicationContext() {
return (WebApplicationContext) applicationContext;
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
public void afterPropertiesSet() throws Exception {
super.setDetectAllHandlerMappings(false);
super.initServletBean();
}
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
@Override
public ServletConfig getServletConfig() {
return new ServletConfig() {
public String getServletName() {
return "JibeSpringMvcDispatcher";
}
public ServletContext getServletContext() {
return servletContext;
}
@SuppressWarnings("unchecked")
public Enumeration getInitParameterNames() {
return null;
}
public String getInitParameter(String name) {
return null;
}
};
}
}