View Javadoc

1   /***
2    * 
3    */
4   package hu.elte.tribus.util;
5   
6   import java.util.Properties;
7   
8   import javax.servlet.ServletContext;
9   
10  import org.apache.log4j.Logger;
11  import org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer;
12  
13  /***
14   * @author kocka
15   *
16   */
17  public class ServletContextPostProcessor extends ServletContextPropertyPlaceholderConfigurer {
18  
19  	private final static Logger logger = Logger.getLogger(ServletContextPostProcessor.class);
20  
21  	private String webinf = null;
22  	
23  	@Override
24  	protected String resolvePlaceholder(String placeholder, Properties props) {
25  		if("APP-HOME".equals(placeholder)) {
26  			return webinf;
27  		}
28  		String value = super.resolvePlaceholder(placeholder, props);
29  		if(value == null) {
30  			logger.warn("Not specified context param:"+placeholder);
31  		}
32  		return value;
33  	}
34  
35  	public void setServletContext(ServletContext servletContext) {
36  		super.setServletContext(servletContext);
37  		webinf = servletContext.getRealPath("WEB-INF");
38  	}
39  
40  }