Support 'required properties' precondition

Users may now call #setRequiredProperties(String...) against the
Environment (via its ConfigurablePropertyResolver interface) in order
to indicate which properties must be present.

Environment#validateRequiredProperties() is invoked by
AbstractApplicationContext during the refresh() lifecycle to perform
the actual check and a MissingRequiredPropertiesException is thrown
if the precondition is not satisfied.

Issue: SPR-8323

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4285 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Chris Beams
2011-05-11 07:36:04 +00:00
parent 26e6c9f1df
commit 3f7d5120c9
8 changed files with 170 additions and 1 deletions
@@ -488,6 +488,10 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
// Initialize any placeholder property sources in the context environment
initPropertySources();
// Validate that all properties marked as required are resolvable
// see ConfigurablePropertyResolver#setRequiredProperties
this.environment.validateRequiredProperties();
}
/**