diff --git a/source/java/org/alfresco/repo/management/subsystems/LegacyConfigPostProcessor.java b/source/java/org/alfresco/repo/management/subsystems/LegacyConfigPostProcessor.java index 60752ecb57..1c48e08345 100644 --- a/source/java/org/alfresco/repo/management/subsystems/LegacyConfigPostProcessor.java +++ b/source/java/org/alfresco/repo/management/subsystems/LegacyConfigPostProcessor.java @@ -26,6 +26,7 @@ package org.alfresco.repo.management.subsystems; import java.util.Collection; import java.util.LinkedHashSet; +import java.util.Properties; import java.util.Set; import org.apache.commons.logging.Log; @@ -37,9 +38,11 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanReference; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.config.TypedStringValue; import org.springframework.beans.factory.support.ManagedList; +import org.springframework.core.Ordered; /** * A {@link BeanFactoryPostProcessor} that upgrades old-style Spring overrides that add location paths to the @@ -49,7 +52,7 @@ import org.springframework.beans.factory.support.ManagedList; * * @author dward */ -public class LegacyConfigPostProcessor implements BeanFactoryPostProcessor +public class LegacyConfigPostProcessor implements BeanFactoryPostProcessor, Ordered { /** The name of the bean that, in new configurations, holds all properties */ private static final String BEAN_NAME_GLOBAL_PROPERTIES = "global-properties"; @@ -118,6 +121,20 @@ public class LegacyConfigPostProcessor implements BeanFactoryPostProcessor }); // Fix up additional properties to enforce correct order of precedence hibernateProperties.addPropertyValue("localOverride", Boolean.TRUE); + + // Because Spring gets all post processors in one shot, the bean may already have been created. Let's try to + // fix it up! + PropertyPlaceholderConfigurer repositoryConfigurer = (PropertyPlaceholderConfigurer) beanFactory + .getSingleton(LegacyConfigPostProcessor.BEAN_NAME_REPOSITORY_PROPERTIES); + if (repositoryConfigurer != null) + { + repositoryConfigurer.setIgnoreUnresolvablePlaceholders(true); + repositoryConfigurer.setLocalOverride(false); + repositoryConfigurer.setSystemPropertiesModeName("SYSTEM_PROPERTIES_MODE_NEVER"); + // At this point we're going to have to resolve the actual global properties bean and reference it! + repositoryConfigurer.setProperties((Properties) beanFactory + .getBean(LegacyConfigPostProcessor.BEAN_NAME_GLOBAL_PROPERTIES)); + } } catch (NoSuchBeanDefinitionException e) { @@ -205,4 +222,11 @@ public class LegacyConfigPostProcessor implements BeanFactoryPostProcessor } return beanProperties; } + + public int getOrder() + { + // This has to run before any other post-processor + return Ordered.HIGHEST_PRECEDENCE; + } + }