From: <fg...@us...> - 2009-03-15 15:34:45
|
Revision: 1095 http://openutils.svn.sourceforge.net/openutils/?rev=1095&view=rev Author: fgiust Date: 2009-03-15 15:34:35 +0000 (Sun, 15 Mar 2009) Log Message: ----------- added processing of annotations Modified Paths: -------------- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java trunk/openutils-deployment/src/site/changes/changes.xml Added Paths: ----------- trunk/openutils-deployment/src/main/java/com/ trunk/openutils-deployment/src/main/java/com/sinapsi/ trunk/openutils-deployment/src/main/java/com/sinapsi/spikes/ trunk/openutils-deployment/src/main/java/com/sinapsi/spikes/ecom/ trunk/openutils-deployment/src/main/java/com/sinapsi/spikes/ecom/utils/ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/Property.java trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/PropertyAnnotationsUtils.java trunk/openutils-deployment/src/test/java/it/openutils/deployment/ trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/ trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/TestBean.java trunk/openutils-deployment/src/test/resources/ trunk/openutils-deployment/src/test/resources/environment.properties trunk/openutils-deployment/src/test/resources/log4j.dtd trunk/openutils-deployment/src/test/resources/log4j.xml trunk/openutils-deployment/src/test/resources/spring-tests.xml 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 2009-03-15 15:30:30 UTC (rev 1094) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java 2009-03-15 15:34:35 UTC (rev 1095) @@ -15,8 +15,10 @@ */ package it.openutils.deployment.spring; +import java.beans.PropertyDescriptor; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Constructor; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.URL; @@ -30,8 +32,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; +import org.springframework.beans.PropertyValues; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; +import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.core.io.Resource; @@ -44,7 +48,10 @@ * @author fgiust * @version $Id: $ */ -public class EnvironmentPropertyConfigurer extends PropertyPlaceholderConfigurer implements ApplicationContextAware +public class EnvironmentPropertyConfigurer extends PropertyPlaceholderConfigurer + implements + ApplicationContextAware, + SmartInstantiationAwareBeanPostProcessor { /** @@ -336,4 +343,47 @@ // ignore, we are not in a web project or spring web is not available } } + + public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException + { + PropertyAnnotationsUtils.autowireProperties(bean, properties); + return true; + } + + public Class predictBeanType(Class beanClass, String beanName) + { + return null; + } + + public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException + { + return null; + } + + public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException + { + return bean; + } + + public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException + { + return null; + } + + public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, + String beanName) throws BeansException + { + + return pvs; + } + + public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException + { + return bean; + } + + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException + { + return bean; + } } Added: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/Property.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/Property.java (rev 0) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/Property.java 2009-03-15 15:34:35 UTC (rev 1095) @@ -0,0 +1,38 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.deployment.spring; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Autowire a property value in a field. + * @author fgiust + * @version $Id$ + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Property { + + /** + * The property key + * @return The property key + */ + String value(); +} \ No newline at end of file Property changes on: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/Property.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/PropertyAnnotationsUtils.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/PropertyAnnotationsUtils.java (rev 0) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/PropertyAnnotationsUtils.java 2009-03-15 15:34:35 UTC (rev 1095) @@ -0,0 +1,69 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.deployment.spring; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Properties; + +import org.springframework.beans.SimpleTypeConverter; +import org.springframework.util.ReflectionUtils; + + +/** + * Utility class for doing property replacement in fields. + * @author fgiust + * @version $Id$ + */ +public final class PropertyAnnotationsUtils +{ + + private static SimpleTypeConverter typeConverter = new SimpleTypeConverter(); + + private PropertyAnnotationsUtils() + { + // don't instantiate + } + + public static void autowireProperties(final Object bean, final Properties properties) + { + ReflectionUtils.doWithFields(bean.getClass(), new ReflectionUtils.FieldCallback() + { + + public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException + { + Property annotation = field.getAnnotation(Property.class); + if (annotation != null) + { + if (Modifier.isStatic(field.getModifiers())) + { + throw new IllegalStateException( + "PropertyAutowired annotation is not supported on static fields"); + } + + Object strValue = properties.get(annotation.value()); + + if (strValue != null) + { + Object value = typeConverter.convertIfNecessary(strValue, field.getType()); + ReflectionUtils.makeAccessible(field); + field.set(bean, value); + } + } + } + }); + } +} Property changes on: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/PropertyAnnotationsUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-deployment/src/site/changes/changes.xml =================================================================== --- trunk/openutils-deployment/src/site/changes/changes.xml 2009-03-15 15:30:30 UTC (rev 1094) +++ trunk/openutils-deployment/src/site/changes/changes.xml 2009-03-15 15:34:35 UTC (rev 1095) @@ -8,6 +8,10 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="2.1" date="2009-03-15" description=""> + <action type="add" dev="fgiust">EnvironmentPropertyConfigurer now also inject properties in fields annotated with + the @Property annotation.</action> + </release> <release version="2.0.2" date="2008-09-18" description=""> <action type="fix" dev="fgiust"> Added debug logs to DeploymentResolver, and solved resolution of webapp root when the root real path returned by the container ends with "/".</action> Added: trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java =================================================================== --- trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java (rev 0) +++ trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java 2009-03-15 15:34:35 UTC (rev 1095) @@ -0,0 +1,48 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.deployment.spring; + +import junit.framework.Assert; + +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; + + +/** + * @author fgiust + * @version $Id$ + */ +@ContextConfiguration(locations = {"/spring-tests.xml" }) +public class PropertyInjectBeanPostProcessorTest extends AbstractJUnit4SpringContextTests +{ + + @Autowired(required = true) + private TestBean testBean; + + @Test + public void testIntProperty() + { + Assert.assertEquals(new Integer(2), testBean.getIntProperty()); + } + + @Test + public void testStringProperty() + { + Assert.assertEquals("property", testBean.getStringProperty()); + } +} Property changes on: trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/TestBean.java =================================================================== --- trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/TestBean.java (rev 0) +++ trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/TestBean.java 2009-03-15 15:34:35 UTC (rev 1095) @@ -0,0 +1,52 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.deployment.spring; + +import org.springframework.stereotype.Component; + + +/** + * @author fgiust + * @version $Id$ + */ +@Component +public class TestBean +{ + + @Property("intProperty") + private Integer intProperty; + + @Property("stringProperty") + private String stringProperty; + + /** + * Returns the intProperty. + * @return the intProperty + */ + public Integer getIntProperty() + { + return intProperty; + } + + /** + * Returns the stringProperty. + * @return the stringProperty + */ + public String getStringProperty() + { + return stringProperty; + } +} Property changes on: trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/TestBean.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-deployment/src/test/resources/environment.properties =================================================================== --- trunk/openutils-deployment/src/test/resources/environment.properties (rev 0) +++ trunk/openutils-deployment/src/test/resources/environment.properties 2009-03-15 15:34:35 UTC (rev 1095) @@ -0,0 +1,2 @@ +intProperty=2 +stringProperty=property Property changes on: trunk/openutils-deployment/src/test/resources/environment.properties ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-deployment/src/test/resources/log4j.dtd =================================================================== --- trunk/openutils-deployment/src/test/resources/log4j.dtd (rev 0) +++ trunk/openutils-deployment/src/test/resources/log4j.dtd 2009-03-15 15:34:35 UTC (rev 1095) @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!-- Authors: Chris Taylor, Ceki Gulcu. --> + +<!-- Version: 1.2 --> + +<!-- A configuration element consists of optional renderer +elements,appender elements, categories and an optional root +element. --> + +<!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?, + categoryFactory?)> + +<!-- The "threshold" attribute takes a level value such that all --> +<!-- logging statements with a level equal or below this value are --> +<!-- disabled. --> + +<!-- Setting the "debug" enable the printing of internal log4j logging --> +<!-- statements. --> + +<!-- By default, debug attribute is "null", meaning that we not do touch --> +<!-- internal log4j logging settings. The "null" value for the threshold --> +<!-- attribute can be misleading. The threshold field of a repository --> +<!-- cannot be set to null. The "null" value for the threshold attribute --> +<!-- simply means don't touch the threshold field, the threshold field --> +<!-- keeps its old value. --> + +<!ATTLIST log4j:configuration + xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/" + threshold (all|debug|info|warn|error|fatal|off|null) "null" + debug (true|false|null) "null" +> + +<!-- renderer elements allow the user to customize the conversion of --> +<!-- message objects to String. --> + +<!ELEMENT renderer EMPTY> +<!ATTLIST renderer + renderedClass CDATA #REQUIRED + renderingClass CDATA #REQUIRED +> + +<!-- Appenders must have a name and a class. --> +<!-- Appenders may contain an error handler, a layout, optional parameters --> +<!-- and filters. They may also reference (or include) other appenders. --> +<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)> +<!ATTLIST appender + name ID #REQUIRED + class CDATA #REQUIRED +> + +<!ELEMENT layout (param*)> +<!ATTLIST layout + class CDATA #REQUIRED +> + +<!ELEMENT filter (param*)> +<!ATTLIST filter + class CDATA #REQUIRED +> + +<!-- ErrorHandlers can be of any class. They can admit any number of --> +<!-- parameters. --> + +<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)> +<!ATTLIST errorHandler + class CDATA #REQUIRED +> + +<!ELEMENT root-ref EMPTY> + +<!ELEMENT logger-ref EMPTY> +<!ATTLIST logger-ref + ref IDREF #REQUIRED +> + +<!ELEMENT param EMPTY> +<!ATTLIST param + name CDATA #REQUIRED + value CDATA #REQUIRED +> + + +<!-- The priority class is org.apache.log4j.Level by default --> +<!ELEMENT priority (param*)> +<!ATTLIST priority + class CDATA #IMPLIED + value CDATA #REQUIRED +> + +<!-- The level class is org.apache.log4j.Level by default --> +<!ELEMENT level (param*)> +<!ATTLIST level + class CDATA #IMPLIED + value CDATA #REQUIRED +> + + +<!-- If no level element is specified, then the configurator MUST not --> +<!-- touch the level of the named category. --> +<!ELEMENT category (param*,(priority|level)?,appender-ref*)> +<!ATTLIST category + class CDATA #IMPLIED + name CDATA #REQUIRED + additivity (true|false) "true" +> + +<!-- If no level element is specified, then the configurator MUST not --> +<!-- touch the level of the named logger. --> +<!ELEMENT logger (level?,appender-ref*)> +<!ATTLIST logger + name ID #REQUIRED + additivity (true|false) "true" +> + + +<!ELEMENT categoryFactory (param*)> +<!ATTLIST categoryFactory + class CDATA #REQUIRED> + +<!ELEMENT appender-ref EMPTY> +<!ATTLIST appender-ref + ref IDREF #REQUIRED +> + +<!-- If no priority element is specified, then the configurator MUST not --> +<!-- touch the priority of root. --> +<!-- The root category always exists and cannot be subclassed. --> +<!ELEMENT root (param*, (priority|level)?, appender-ref*)> + + +<!-- ==================================================================== --> +<!-- A logging event --> +<!-- ==================================================================== --> +<!ELEMENT log4j:eventSet (log4j:event*)> +<!ATTLIST log4j:eventSet + xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/" + version (1.1|1.2) "1.2" + includesLocationInfo (true|false) "true" +> + + + +<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?, + log4j:locationInfo?) > + +<!-- The timestamp format is application dependent. --> +<!ATTLIST log4j:event + logger CDATA #REQUIRED + level CDATA #REQUIRED + thread CDATA #REQUIRED + timestamp CDATA #REQUIRED +> + +<!ELEMENT log4j:message (#PCDATA)> +<!ELEMENT log4j:NDC (#PCDATA)> + +<!ELEMENT log4j:throwable (#PCDATA)> + +<!ELEMENT log4j:locationInfo EMPTY> +<!ATTLIST log4j:locationInfo + class CDATA #REQUIRED + method CDATA #REQUIRED + file CDATA #REQUIRED + line CDATA #REQUIRED +> Property changes on: trunk/openutils-deployment/src/test/resources/log4j.dtd ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:eol-style + native Added: trunk/openutils-deployment/src/test/resources/log4j.xml =================================================================== --- trunk/openutils-deployment/src/test/resources/log4j.xml (rev 0) +++ trunk/openutils-deployment/src/test/resources/log4j.xml 2009-03-15 15:34:35 UTC (rev 1095) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> +<log4j:configuration> + <!-- log4j test configuration --> + <appender name="test-appender" class="org.apache.log4j.ConsoleAppender"> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%-5p %c.%M(%C{1}.java:%L) %m%n" /> + </layout> + </appender> + <category name="org"> + <priority value="WARN" /> + </category> + <category name="com"> + <priority value="WARN" /> + </category> + <category name="net"> + <priority value="WARN" /> + </category> + <category name="info"> + <priority value="WARN" /> + </category> + <category name="it"> + <priority value="WARN" /> + </category> + <root> + <priority value="debug" /> + <appender-ref ref="test-appender" /> + </root> +</log4j:configuration> \ No newline at end of file Property changes on: trunk/openutils-deployment/src/test/resources/log4j.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-deployment/src/test/resources/spring-tests.xml =================================================================== --- trunk/openutils-deployment/src/test/resources/spring-tests.xml (rev 0) +++ trunk/openutils-deployment/src/test/resources/spring-tests.xml 2009-03-15 15:34:35 UTC (rev 1095) @@ -0,0 +1,13 @@ +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-2.5.xsd"> + <bean id="environmentProperties" class="it.openutils.deployment.spring.EnvironmentPropertyConfigurer"> + <property name="fileLocation" value="classpath:environment.properties" /> + <property name="ignoreUnresolvablePlaceholders" value="true" /> + </bean> + <context:annotation-config /> + <context:component-scan base-package="it.openutils.deployment.spring" /> +</beans> \ No newline at end of file Property changes on: trunk/openutils-deployment/src/test/resources/spring-tests.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-03-25 14:28:34
|
Revision: 1104 http://openutils.svn.sourceforge.net/openutils/?rev=1104&view=rev Author: fgiust Date: 2009-03-25 14:28:23 +0000 (Wed, 25 Mar 2009) Log Message: ----------- added exposeSystemProperties flag Modified Paths: -------------- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java trunk/openutils-deployment/src/site/changes/changes.xml trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java trunk/openutils-deployment/src/test/resources/spring-tests.xml 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 2009-03-24 11:20:47 UTC (rev 1103) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java 2009-03-25 14:28:23 UTC (rev 1104) @@ -23,6 +23,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.UnknownHostException; +import java.util.Iterator; import java.util.Properties; import javax.servlet.ServletContext; @@ -90,6 +91,11 @@ private boolean inherit = true; /** + * Set all the properties configured as system properties. + */ + private boolean exposeSystemProperties; + + /** * Setter for <code>fileLocation</code>. * @param fileLocation The fileLocation to set. */ @@ -119,6 +125,15 @@ } /** + * Set all the properties configured as system properties. + * @param exposeSystemProperties <code>true</code> if you want to set configured properties as system properties. + */ + public void setExposeSystemProperties(boolean exposeSystemProperties) + { + this.exposeSystemProperties = exposeSystemProperties; + } + + /** * {@inheritDoc} */ @Override @@ -228,6 +243,18 @@ this.properties = props; super.setProperties(props); + if (exposeSystemProperties) + { + Iterator<Object> i = props.keySet().iterator(); + while (i.hasNext()) + { + String key = (String) i.next(); + String value = (String) props.get(key); + System.setProperty(key, value); + } + + } + } super.postProcessBeanFactory(beanFactory); Modified: trunk/openutils-deployment/src/site/changes/changes.xml =================================================================== --- trunk/openutils-deployment/src/site/changes/changes.xml 2009-03-24 11:20:47 UTC (rev 1103) +++ trunk/openutils-deployment/src/site/changes/changes.xml 2009-03-25 14:28:23 UTC (rev 1104) @@ -8,6 +8,9 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="2.1.1" date="2009-03-25" description=""> + <action type="add" dev="fgiust">New "exposeSystemProperties" flag added to EnvironmentPropertyConfigurer</action> + </release> <release version="2.1" date="2009-03-15" description=""> <action type="add" dev="fgiust">EnvironmentPropertyConfigurer now also inject properties in fields annotated with the @Property annotation.</action> Modified: trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java =================================================================== --- trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java 2009-03-24 11:20:47 UTC (rev 1103) +++ trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java 2009-03-25 14:28:23 UTC (rev 1104) @@ -45,4 +45,11 @@ { Assert.assertEquals("property", testBean.getStringProperty()); } + + @Test + public void testSystemProperty() + { + Assert.assertEquals("property", System.getProperty("stringProperty")); + } + } Modified: trunk/openutils-deployment/src/test/resources/spring-tests.xml =================================================================== --- trunk/openutils-deployment/src/test/resources/spring-tests.xml 2009-03-24 11:20:47 UTC (rev 1103) +++ trunk/openutils-deployment/src/test/resources/spring-tests.xml 2009-03-25 14:28:23 UTC (rev 1104) @@ -7,6 +7,7 @@ <bean id="environmentProperties" class="it.openutils.deployment.spring.EnvironmentPropertyConfigurer"> <property name="fileLocation" value="classpath:environment.properties" /> <property name="ignoreUnresolvablePlaceholders" value="true" /> + <property name="exposeSystemProperties" value="true" /> </bean> <context:annotation-config /> <context:component-scan base-package="it.openutils.deployment.spring" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-08-14 08:18:25
|
Revision: 1265 http://openutils.svn.sourceforge.net/openutils/?rev=1265&view=rev Author: fgiust Date: 2009-08-14 08:18:13 +0000 (Fri, 14 Aug 2009) Log Message: ----------- EnvironmentLog4jConfigListener now exposes a "server" System property also when log4jExposeWebAppRoot is set to false Modified Paths: -------------- trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java trunk/openutils-deployment/src/site/changes/changes.xml Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java 2009-08-13 16:22:41 UTC (rev 1264) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java 2009-08-14 08:18:13 UTC (rev 1265) @@ -56,13 +56,13 @@ if (exposeWebAppRoot(servletContext)) { WebUtils.setWebAppRootSystemProperty(servletContext); + } - String servername = DeploymentResolver.resolveServerName(); - if (servername != null) - { - System.setProperty("server.name", servername); - System.setProperty("server", servername); - } + String servername = DeploymentResolver.resolveServerName(); + if (servername != null) + { + System.setProperty("server.name", servername); + System.setProperty("server", servername); } String locationList = servletContext.getInitParameter("log4jConfigLocation"); Modified: trunk/openutils-deployment/src/site/changes/changes.xml =================================================================== --- trunk/openutils-deployment/src/site/changes/changes.xml 2009-08-13 16:22:41 UTC (rev 1264) +++ trunk/openutils-deployment/src/site/changes/changes.xml 2009-08-14 08:18:13 UTC (rev 1265) @@ -8,6 +8,10 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="2.1.2" date="in svn" description=""> + <action type="update" dev="fgiust">EnvironmentLog4jConfigListener now exposes a "server" System property also when + log4jExposeWebAppRoot is set to false</action> + </release> <release version="2.1.1" date="2009-03-25" description=""> <action type="add" dev="fgiust">New "exposeSystemProperties" flag added to EnvironmentPropertyConfigurer</action> </release> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mmu...@us...> - 2010-02-09 11:54:18
|
Revision: 1867 http://openutils.svn.sourceforge.net/openutils/?rev=1867&view=rev Author: mmunaretto Date: 2010-02-09 11:54:10 +0000 (Tue, 09 Feb 2010) Log Message: ----------- added license to source code Modified Paths: -------------- trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/DeploymentResolver.java trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/DatabaseEnvironmentPropertyConfigurer.java trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/Property.java trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/PropertyAnnotationsUtils.java trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/SampleBean.java Added Paths: ----------- trunk/openutils-deployment/src/main/etc/ trunk/openutils-deployment/src/main/etc/header.txt Added: trunk/openutils-deployment/src/main/etc/header.txt =================================================================== --- trunk/openutils-deployment/src/main/etc/header.txt (rev 0) +++ trunk/openutils-deployment/src/main/etc/header.txt 2010-02-09 11:54:10 UTC (rev 1867) @@ -0,0 +1,15 @@ + +${name} (${url}) +Copyright(C) ${year}, Openmind S.r.l. http://www.openmindonline.it + + 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. \ No newline at end of file Property changes on: trunk/openutils-deployment/src/main/etc/header.txt ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/DeploymentResolver.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/DeploymentResolver.java 2010-02-09 11:41:47 UTC (rev 1866) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/DeploymentResolver.java 2010-02-09 11:54:10 UTC (rev 1867) @@ -1,18 +1,21 @@ -/* - * Copyright Openmind http://www.openmindonline.it +/** * - * 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 + * openutils deployment tools (http://www.openmindlab.com/lab/products/deployment.html) + * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 it.openutils.deployment.log4j; import java.io.File; Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java 2010-02-09 11:41:47 UTC (rev 1866) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/log4j/EnvironmentLog4jConfigListener.java 2010-02-09 11:54:10 UTC (rev 1867) @@ -1,18 +1,21 @@ -/* - * Copyright Openmind http://www.openmindonline.it +/** * - * 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 + * openutils deployment tools (http://www.openmindlab.com/lab/products/deployment.html) + * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 it.openutils.deployment.log4j; import java.io.FileNotFoundException; Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/DatabaseEnvironmentPropertyConfigurer.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/DatabaseEnvironmentPropertyConfigurer.java 2010-02-09 11:41:47 UTC (rev 1866) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/DatabaseEnvironmentPropertyConfigurer.java 2010-02-09 11:54:10 UTC (rev 1867) @@ -1,18 +1,21 @@ -/* - * Copyright Openmind http://www.openmindonline.it +/** * - * 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 + * openutils deployment tools (http://www.openmindlab.com/lab/products/deployment.html) + * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 it.openutils.deployment.spring; import java.io.IOException; 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 2010-02-09 11:41:47 UTC (rev 1866) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/EnvironmentPropertyConfigurer.java 2010-02-09 11:54:10 UTC (rev 1867) @@ -1,18 +1,21 @@ -/* - * Copyright Openmind http://www.openmindonline.it +/** * - * 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 + * openutils deployment tools (http://www.openmindlab.com/lab/products/deployment.html) + * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 it.openutils.deployment.spring; import java.beans.PropertyDescriptor; Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/Property.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/Property.java 2010-02-09 11:41:47 UTC (rev 1866) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/Property.java 2010-02-09 11:54:10 UTC (rev 1867) @@ -1,18 +1,21 @@ -/* - * Copyright Openmind http://www.openmindonline.it +/** * - * 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 + * openutils deployment tools (http://www.openmindlab.com/lab/products/deployment.html) + * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 it.openutils.deployment.spring; import java.lang.annotation.ElementType; Modified: trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/PropertyAnnotationsUtils.java =================================================================== --- trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/PropertyAnnotationsUtils.java 2010-02-09 11:41:47 UTC (rev 1866) +++ trunk/openutils-deployment/src/main/java/it/openutils/deployment/spring/PropertyAnnotationsUtils.java 2010-02-09 11:54:10 UTC (rev 1867) @@ -1,18 +1,21 @@ -/* - * Copyright Openmind http://www.openmindonline.it +/** * - * 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 + * openutils deployment tools (http://www.openmindlab.com/lab/products/deployment.html) + * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 it.openutils.deployment.spring; import java.lang.reflect.Field; Modified: trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java =================================================================== --- trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java 2010-02-09 11:41:47 UTC (rev 1866) +++ trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/PropertyInjectBeanPostProcessorTest.java 2010-02-09 11:54:10 UTC (rev 1867) @@ -1,18 +1,21 @@ -/* - * Copyright Openmind http://www.openmindonline.it +/** * - * 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 + * openutils deployment tools (http://www.openmindlab.com/lab/products/deployment.html) + * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 it.openutils.deployment.spring; import junit.framework.Assert; Modified: trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/SampleBean.java =================================================================== --- trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/SampleBean.java 2010-02-09 11:41:47 UTC (rev 1866) +++ trunk/openutils-deployment/src/test/java/it/openutils/deployment/spring/SampleBean.java 2010-02-09 11:54:10 UTC (rev 1867) @@ -1,18 +1,21 @@ -/* - * Copyright Openmind http://www.openmindonline.it +/** * - * 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 + * openutils deployment tools (http://www.openmindlab.com/lab/products/deployment.html) + * Copyright(C) null-2010, Openmind S.r.l. http://www.openmindonline.it * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 it.openutils.deployment.spring; import org.springframework.stereotype.Component; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |