Build fix

- Fix handling of legacy dev-context.xml style property configuration
- LegacyConfigPostProcessor has to be given the maximum precendence so that it runs before PropertyPlaceHolderConfigurer
- Also has to fix up the live repository-properties bean that would already have been constructed before post-processing
- Include log4.properties in unit test classpath so we can tell what the heck is going on!


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15994 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward 2009-08-29 17:09:02 +00:00
parent 200bf8d3a0
commit f820643c7d

View File

@ -26,6 +26,7 @@ package org.alfresco.repo.management.subsystems;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.apache.commons.logging.Log; 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.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanReference; import org.springframework.beans.factory.config.BeanReference;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 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.RuntimeBeanReference;
import org.springframework.beans.factory.config.TypedStringValue; import org.springframework.beans.factory.config.TypedStringValue;
import org.springframework.beans.factory.support.ManagedList; 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 * 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 * @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 */ /** The name of the bean that, in new configurations, holds all properties */
private static final String BEAN_NAME_GLOBAL_PROPERTIES = "global-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 // Fix up additional properties to enforce correct order of precedence
hibernateProperties.addPropertyValue("localOverride", Boolean.TRUE); 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) catch (NoSuchBeanDefinitionException e)
{ {
@ -205,4 +222,11 @@ public class LegacyConfigPostProcessor implements BeanFactoryPostProcessor
} }
return beanProperties; return beanProperties;
} }
public int getOrder()
{
// This has to run before any other post-processor
return Ordered.HIGHEST_PRECEDENCE;
}
} }