Hi there,
first of, congratulations to the whole SAS team on the RC1 release, awesome work guys.
When I started playing around with it in a fairly complex project of mine, I noticed several things:
There's a race condition when loading placeholders from multiple property files.
In 50% of all cases the PropertyPlaceholderConfigurer won't be able to satisfy the placeholder requirements of the object definitions, resulting in an error when ignoreUnresolvablePlaceholders is set to false (default):
Some way around this might be to merge all properties from all PropertyPlaceholderConfigurersCode:Exception fault: Error: Could not resolve placeholder '${username}' at org.springextensions.actionscript.utils::PropertyPlaceholderResolver/replacePropertyPlaceholder()
(POC code illustrating the basics):
AbstractApplicationContext.as:Code:public interface IPropertyPlaceholderConfigurer extends IObjectFactoryPostProcessor { function get properties():Properties; function set ignoreUnresolvablePlaceholders(value:Boolean):void; }
Of course something like this does not allow a per-node definition of the ignoreUnresolvablePlaceholders, but that's fine for me since I usually only have external properties that are mandatory anyway.Code:protected function invokeObjectFactoryPostProcessors():void { var propertyPostProcessors:Array = []; var nonPropertyPostProcessors:Array = []; for each (var postProcessor:IObjectFactoryPostProcessor in _objectFactoryPostProcessors) { if (postProcessor is IPropertyPlaceholderConfigurer) { propertyPostProcessors.push(postProcessor); } else { nonPropertyPostProcessors.push(postProcessor); } } var previousPropertyProcessor:IPropertyPlaceholderConfigurer; while(propertyPostProcessors.length > 0) { var propertyPostProcessor:IPropertyPlaceholderConfigurer = propertyPostProcessors.shift(); LOGGER.debug("Post processing object factory with PROPERTY post-processor '{0}'", propertyPostProcessor); if (propertyPostProcessors.length > 0) { // there are more PropertyPlaceholderConfigurers after this one // so we can defer the failing part to the very last one propertyPostProcessor.ignoreUnresolvablePlaceholders = true; } else { // this is the last one, so we'll set the ignoreUnresolvable explicitly to false propertyPostProcessor.ignoreUnresolvablePlaceholders = false; } if (previousPropertyProcessor) { // merge the properties with the previous property preprocessor propertyPostProcessor.properties.merge(previousPropertyProcessor.properties); } // do the actual postprocessing propertyPostProcessor.postProcessObjectFactory(this); // set the previousPropertyProcessor reference previousPropertyProcessor = propertyPostProcessor; } // invoke the rest of the IObjectFactoryPostProcessors for each (var nonPropertyPostProcessor:IObjectFactoryPostProcessor in nonPropertyPostProcessors) { LOGGER.debug("Post processing object factory with post-processor '{0}'", nonPropertyPostProcessor); nonPropertyPostProcessor.postProcessObjectFactory(this); } }
Walking through the code I noted some differences from the behaviour in the docs:
a) currently the properties file is loaded from a path relative to the .swf instead of the context
b) the xml preprocessor for external files (PropertyImportPreprocessor) does not allow switching off the caching mechanism by setting "prevent-cache=false", as this property is never handled and the loader operations don't support this property (will be invoked by default with true).
I'll create some jira tickets later on for these.
Cheers
herb


Reply With Quote
