From ae74a2158a5df9de3ac1fb4b6309b053bbd4ed27 Mon Sep 17 00:00:00 2001 From: Carson McDonald Date: Fri, 15 Mar 2013 13:18:43 -0400 Subject: [PATCH 01/56] Fix typo {explictly => explicitly} - cherry-pick of pull request #257, which originally applied to 3.2.x --- .../springframework/aop/target/CommonsPoolTargetSource.java | 4 ++-- .../springframework/remoting/rmi/RmiRegistryFactoryBean.java | 4 ++-- .../org/springframework/orm/jdo/JdoTransactionManager.java | 2 +- .../org/springframework/orm/jpa/JpaTransactionManager.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPoolTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPoolTargetSource.java index 08f16258a1..9b44df6217 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPoolTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPoolTargetSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -38,7 +38,7 @@ import org.springframework.core.Constants; * of configuration properties that are relevant to your chosen implementation. * *

The {@code testOnBorrow}, {@code testOnReturn} and {@code testWhileIdle} - * properties are explictly not mirrored because the implementation of + * properties are explicitly not mirrored because the implementation of * {@code PoolableObjectFactory} used by this class does not implement * meaningful validation. All exposed Commons Pool properties use the corresponding * Commons Pool defaults: for example, diff --git a/spring-context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java b/spring-context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java index 0a6ded9114..b7107934b3 100644 --- a/spring-context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -181,7 +181,7 @@ public class RmiRegistryFactoryBean implements FactoryBean, Initializi throws RemoteException { if (registryHost != null) { - // Host explictly specified: only lookup possible. + // Host explicitly specified: only lookup possible. if (logger.isInfoEnabled()) { logger.info("Looking for RMI registry at port '" + registryPort + "' of host [" + registryHost + "]"); } diff --git a/spring-orm/src/main/java/org/springframework/orm/jdo/JdoTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/jdo/JdoTransactionManager.java index f2086038ca..296582f2eb 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jdo/JdoTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jdo/JdoTransactionManager.java @@ -154,7 +154,7 @@ public class JdoTransactionManager extends AbstractPlatformTransactionManager * The DataSource should match the one used by the JDO PersistenceManagerFactory: * for example, you could specify the same JNDI DataSource for both. *

If the PersistenceManagerFactory uses a DataSource as connection factory, - * the DataSource will be autodetected: You can still explictly specify the + * the DataSource will be autodetected: You can still explicitly specify the * DataSource, but you don't need to in this case. *

A transactional JDBC Connection for this DataSource will be provided to * application code accessing this DataSource directly via DataSourceUtils diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java index 49d2cea7cc..1f424977a4 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java @@ -216,7 +216,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager * The DataSource should match the one used by the JPA EntityManagerFactory: * for example, you could specify the same JNDI DataSource for both. *

If the EntityManagerFactory uses a known DataSource as connection factory, - * the DataSource will be autodetected: You can still explictly specify the + * the DataSource will be autodetected: You can still explicitly specify the * DataSource, but you don't need to in this case. *

A transactional JDBC Connection for this DataSource will be provided to * application code accessing this DataSource directly via DataSourceUtils @@ -258,7 +258,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager * Set the JPA dialect to use for this transaction manager. * Used for vendor-specific transaction management and JDBC connection exposure. *

If the EntityManagerFactory uses a known JpaDialect, it will be autodetected: - * You can still explictly specify the DataSource, but you don't need to in this case. + * You can still explicitly specify the DataSource, but you don't need to in this case. *

The dialect object can be used to retrieve the underlying JDBC connection * and thus allows for exposing JPA transactions as JDBC transactions. * @see EntityManagerFactoryInfo#getJpaDialect() From d7ec20a286608fcfa466c96538f7e0bf961aeac0 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 3 Jun 2013 09:37:43 -0700 Subject: [PATCH 02/56] Test for property placeholder with defaults Test property placeholder with multiple locations and default values. Issue: SPR-10619 --- ...ertySourcesPlaceholderConfigurerTests.java | 19 +++++++++++++++++++ .../context/support/placeholder.properties | 1 + 2 files changed, 20 insertions(+) diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index f8f13285c8..9da942c3ed 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -265,4 +265,23 @@ public class PropertySourcesPlaceholderConfigurerTests { thrown.expect(IllegalStateException.class); ppc.getAppliedPropertySources(); } + + @Test + public void multipleLocationsWithDefaultResolvedValue() throws Exception { + // SPR-10619 + PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); + ClassPathResource doesNotHave = new ClassPathResource("test.properties", getClass()); + ClassPathResource setToTrue = new ClassPathResource("placeholder.properties", getClass()); + ppc.setLocations(new Resource[] { doesNotHave, setToTrue }); + ppc.setIgnoreResourceNotFound(true); + ppc.setIgnoreUnresolvablePlaceholders(true); + DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); + bf.registerBeanDefinition("testBean", + genericBeanDefinition(TestBean.class) + .addPropertyValue("jedi", "${jedi:false}") + .getBeanDefinition()); + ppc.postProcessBeanFactory(bf); + assertThat(bf.getBean(TestBean.class).isJedi(), equalTo(true)); + } + } diff --git a/spring-context/src/test/java/org/springframework/context/support/placeholder.properties b/spring-context/src/test/java/org/springframework/context/support/placeholder.properties index 6c9d097621..11f0d7f030 100644 --- a/spring-context/src/test/java/org/springframework/context/support/placeholder.properties +++ b/spring-context/src/test/java/org/springframework/context/support/placeholder.properties @@ -1,3 +1,4 @@ targetName=wrappedAssemblerOne logicName=logicTwo realLogicName=realLogic +jedi=true From 4d3383242e5655631e44dee48ca7060add84f957 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 3 Jun 2013 12:15:47 -0700 Subject: [PATCH 03/56] Support EnvironmentAware ImportSelector/Registrar Add support for the EnvironmentAware interface with ImportSelector and ImportBeanDefinitionRegistrar implementations. Issue: SPR-10602 --- .../annotation/ConfigurationClassParser.java | 4 + .../ImportBeanDefinitionRegistrar.java | 3 +- .../context/annotation/ImportSelector.java | 1 + .../ImportBeanDefinitionRegistrarTests.java | 20 +++-- .../annotation/ImportSelectorTests.java | 80 ++++++++++++++++--- 5 files changed, 92 insertions(+), 16 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index 294d94bb04..0ac8c31e82 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -47,6 +47,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionReader; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanNameGenerator; +import org.springframework.context.EnvironmentAware; import org.springframework.context.ResourceLoaderAware; import org.springframework.core.NestedIOException; import org.springframework.core.annotation.AnnotationAttributes; @@ -486,6 +487,9 @@ class ConfigurationClassParser { */ private void invokeAwareMethods(Object importStrategyBean) { if (importStrategyBean instanceof Aware) { + if (importStrategyBean instanceof EnvironmentAware) { + ((EnvironmentAware) importStrategyBean).setEnvironment(this.environment); + } if (importStrategyBean instanceof ResourceLoaderAware) { ((ResourceLoaderAware) importStrategyBean).setResourceLoader(this.resourceLoader); } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.java b/spring-context/src/main/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.java index 648a8e9211..6795d6172c 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -33,6 +33,7 @@ import org.springframework.core.type.AnnotationMetadata; * {@link org.springframework.beans.factory.Aware Aware} interfaces, and their respective * methods will be called prior to {@link #registerBeanDefinitions}: *