/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache license, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.internna.iwebmvc.spring.jee;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
/**
* Loads framework default XML configuration files automatically.
*
* @author Jose Noheda
* @since 2.0
*/
public class IWebMvcDispatcherServlet extends DispatcherServlet {
private static final long serialVersionUID = 4760661649753249363L;
public static final String IWEBMVC_MAPPED_PATH = "iwebmvc";
protected static final String RESOLVER = "propertyResolver";
protected static final String DISPATCHER_CONTEXT = "classpath*:spring/dispatcher-servlet.xml classpath*:spring/jcaptcha.xml /WEB-INF/spring/dispatcher-servlet.xml";
@Override public String getContextConfigLocation() {
return IWebMvcDispatcherServlet.DISPATCHER_CONTEXT;
}
@Override protected void postProcessWebApplicationContext(ConfigurableWebApplicationContext wac) {
wac.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
BeanFactoryPostProcessor pp = (BeanFactoryPostProcessor) beanFactory.getBean(IWebMvcDispatcherServlet.RESOLVER, PropertyPlaceholderConfigurer.class);
pp.postProcessBeanFactory(beanFactory);
}
});
}
}