[java-identity-provider COMMIT] /trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationConte...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Oct 15 13:06:30 EDT 2015
Author: tzeller
Date: Thu Oct 15 13:06:30 2015
New Revision: 7829
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7829&view=rev
Log:
IDP-788 - Some work on cleaning up the application context initializer.
Modified:
trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java
Modified: trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java?rev=7829&r1=7828&r2=7829&view=diff
==============================================================================
--- trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java (original)
+++ trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java Thu Oct 15 13:06:30 2015
@@ -68,7 +68,6 @@
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(IdPPropertiesApplicationContextInitializer.class);
-// Checkstyle: CyclomaticComplexity|MethodLength OFF
/** {@inheritDoc} */
@Override public void initialize(@Nonnull final ConfigurableApplicationContext applicationContext) {
log.debug("Initializing application context '{}'", applicationContext);
@@ -79,9 +78,9 @@
log.debug("Prepending idp.home property value '{}' to well-known search locations", homeProperty);
searchLocations.add(homeProperty);
}
-
+
searchLocations.addAll(Arrays.asList(getSearchLocations()));
-
+
log.debug("Attempting to find '{}' at search locations '{}'", getSearchTarget(), searchLocations);
for (final String searchLocation : searchLocations) {
@@ -108,36 +107,12 @@
setIdPHomeProperty(searchLocationAbsolutePath, properties);
}
}
-
- // Load any additional property sources.
- final String additionalSources = properties.getProperty(IDP_ADDITIONAL_PROPERTY);
- if (additionalSources != null) {
- final String[] sources = additionalSources.split(",");
- for (final String source : sources) {
- final String trimmedSource = StringSupport.trimOrNull(source);
- if (trimmedSource == null) {
- continue;
- }
- log.debug("Attempting to load properties from resource '{}'", trimmedSource);
- final String pathifiedSource = searchLocation + trimmedSource;
- final Resource additionalResource = applicationContext.getResource(pathifiedSource);
- if (additionalResource.exists()) {
- log.debug("Found resource '{}' at search path '{}'", additionalResource, pathifiedSource);
- if (loadProperties(properties, additionalResource) == null) {
- log.warn("Unable to load properties from resource '{}'", additionalResource);
- continue;
- }
- } else {
- log.warn("Unable to find resource '{}'", additionalResource);
- }
- }
- }
+
+ loadAdditionalPropertySources(applicationContext, searchLocation, properties);
logProperties(properties);
- final PropertiesPropertySource propertySource =
- new PropertiesPropertySource(resource.toString(), properties);
-
- applicationContext.getEnvironment().getPropertySources().addLast(propertySource);
+
+ addPropertySourceToApplicationContext(applicationContext, resource.toString(), properties);
return;
}
@@ -145,7 +120,6 @@
log.warn("Unable to find '{}' at well known locations '{}'", getSearchTarget(), getSearchLocations());
}
-// Checkstyle: CyclomaticComplexity|MethodLength ON
/**
* Get the target resource to be searched for {@link #IDP_PROPERTIES}.
@@ -188,6 +162,42 @@
return null;
}
}
+
+ /**
+ * Load additional property sources.
+ *
+ * File names of additional property sources are defined by {@link #IDP_ADDITIONAL_PROPERTY}, and are resolved
+ * relative to the given search location.
+ *
+ * @param applicationContext the application context
+ * @param searchLocation the location from which additional property sources are resolved
+ * @param properties the properties to be filled with additional property sources
+ */
+ public void loadAdditionalPropertySources(@Nonnull final ConfigurableApplicationContext applicationContext,
+ @Nonnull final String searchLocation, @Nonnull final Properties properties) {
[... 47 lines stripped ...]
More information about the commits
mailing list