From: <fg...@us...> - 2008-02-03 21:02:47
|
Revision: 594 http://openutils.svn.sourceforge.net/openutils/?rev=594&view=rev Author: fgiust Date: 2008-02-03 13:02:50 -0800 (Sun, 03 Feb 2008) Log Message: ----------- try to avoid spring-web dependency Modified Paths: -------------- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java 2008-02-01 10:59:57 UTC (rev 593) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java 2008-02-03 21:02:50 UTC (rev 594) @@ -17,17 +17,19 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; import org.springframework.core.io.Resource; import org.springframework.core.io.UrlResource; import org.springframework.util.ResourceUtils; -import org.springframework.web.context.ServletContextAware; +import org.springframework.web.context.WebApplicationContext; /** * @author fgiust * @version $Id: $ */ -public class EnvironmentPropertyConfigurer extends PropertyPlaceholderConfigurer implements ServletContextAware +public class EnvironmentPropertyConfigurer extends PropertyPlaceholderConfigurer implements ApplicationContextAware { /** @@ -66,14 +68,6 @@ private boolean inherit = true; /** - * {@inheritDoc} - */ - public void setServletContext(ServletContext servletContext) - { - this.servletContext = servletContext; - } - - /** * Setter for <code>fileLocation</code>. * @param fileLocation The fileLocation to set. */ @@ -309,4 +303,21 @@ return properties.getProperty(key); } + /** + * {@inheritDoc} + */ + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + { + try + { + if (applicationContext instanceof WebApplicationContext) + { + this.servletContext = ((WebApplicationContext) applicationContext).getServletContext(); + } + } + catch (NoClassDefFoundError e) + { + // ignore, we are not in a web project or spring web is not available + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |