[spring-extensions] 01/05: Migrate some IdP code down.
Scott Cantor
cantor.2 at osu.edu
Tue Jun 21 15:01:36 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch dev/JSPS-1
in repository spring-extensions.
View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=1301b59c0b1f3645d8a0b4f308147f7b73d11ae1
commit 1301b59c0b1f3645d8a0b4f308147f7b73d11ae1
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu May 12 13:17:47 2022 -0400
Migrate some IdP code down.
---
pom.xml | 24 ++++++--
.../ext/spring/util/ApplicationContextBuilder.java | 72 ++++++++++++++++++++--
2 files changed, 86 insertions(+), 10 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0df50ea..cbf1eb1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,11 @@
<properties>
<automatic.module.name>net.shibboleth.ext.spring</automatic.module.name>
+<<<<<<< Upstream, based on origin/main
<java-support.version>9.0.0-SNAPSHOT</java-support.version>
+=======
+ <java-support.version>8.3.2-SNAPSHOT</java-support.version>
+>>>>>>> bb5853e Migrate some IdP code down.
<shibboleth.site.deploy.url>//shibboleth.net/home/javasites/staging/</shibboleth.site.deploy.url>
</properties>
@@ -127,6 +131,20 @@
<!-- Required if you're using classes from the velocity package -->
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <scope>compile</scope><!-- normally runtime -->
+ <!-- Required if you're using the LogginService implementation. -->
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>compile</scope><!-- normally runtime -->
+ <!-- Required if you're using the LogginService implementation. -->
+ <optional>true</optional>
+ </dependency>
<!-- Provided dependencies -->
<dependency>
@@ -146,12 +164,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
-
<dependency>
<groupId>${spring.groupId}</groupId>
<artifactId>spring-test</artifactId>
diff --git a/src/main/java/net/shibboleth/ext/spring/util/ApplicationContextBuilder.java b/src/main/java/net/shibboleth/ext/spring/util/ApplicationContextBuilder.java
index 6c32c55..895c63a 100644
--- a/src/main/java/net/shibboleth/ext/spring/util/ApplicationContextBuilder.java
+++ b/src/main/java/net/shibboleth/ext/spring/util/ApplicationContextBuilder.java
@@ -17,6 +17,7 @@
package net.shibboleth.ext.spring.util;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -68,6 +69,9 @@ public class ApplicationContextBuilder {
/** Context name. */
@Nullable @NotEmpty private String contextName;
+ /** Unresolved configuration sources for this service. */
+ @Nullable @NonnullElements private List<String> configurationSources;
+
/** Configuration resources for this service. */
@Nullable @NonnullElements private List<Resource> configurationResources;
@@ -93,6 +97,9 @@ public class ApplicationContextBuilder {
/** Application context owning this engine. */
@Nullable private ApplicationContext parentContext;
+ /** Whether to install a JVM shutdown hook. */
+ private boolean installShutdownHook;
+
/**
* Set the name of the context.
*
@@ -131,7 +138,25 @@ public class ApplicationContextBuilder {
return this;
}
-
+
+ /**
+ * Set the unresolved configurations for this context.
+ *
+ * <p>This method is used to allow the context to resolve the resources.</p>
+ *
+ * @param configs unresolved configurations for this context
+ *
+ * @return this builder
+ *
+ * @since 7.0.0
+ */
+ @Nonnull public ApplicationContextBuilder setUnresolvedServiceConfigurations(
+ @Nonnull @NonnullElements final Collection<String> configs) {
+ configurationSources = List.copyOf(Constraint.isNotNull(configs, "Service configurations cannot be null"));
+
+ return this;
+ }
+
/**
* Set the configurations for this context.
*
@@ -285,7 +310,24 @@ public class ApplicationContextBuilder {
return this;
}
-// Checkstyle: CyclomaticComplexity OFF
+ /**
+ * Set whether to install a JVM shutdown hook.
+ *
+ * <p>Defaults to false.</p>
+ *
+ * @param flag flag to set
+ *
+ * @return this builder
+ *
+ * @since 7.0.0
+ */
+ @Nonnull public ApplicationContextBuilder installShutdownHook(final boolean flag) {
+ installShutdownHook = flag;
+
+ return this;
+ }
+
+// Checkstyle: CyclomaticComplexity|MethodLength OFF
/**
* Build a {@link GenericApplicationContext} context.
*
@@ -333,9 +375,31 @@ public class ApplicationContextBuilder {
context.getEnvironment().setPlaceholderPrefix("%{");
context.getEnvironment().setPlaceholderSuffix("}");
}
+
+ if (installShutdownHook) {
+ context.registerShutdownHook();
+ }
final SchemaTypeAwareXMLBeanDefinitionReader beanDefinitionReader =
new SchemaTypeAwareXMLBeanDefinitionReader(context);
+
+ if (configurationSources != null && !configurationSources.isEmpty()) {
+ configurationSources.stream().forEachOrdered(
+ s -> {
+ try {
+ final Resource[] loaded = context.getResources(s);
+ if (loaded != null && loaded.length > 0) {
+ log.debug("Resolved resources: {}", Arrays.asList(loaded));
+ beanDefinitionReader.loadBeanDefinitions(loaded);
+ } else {
+ log.debug("No resources resolved from {}", s);
+ }
+ } catch (final IOException e) {
+ log.warn("Error loading beans from {}", s, e);
+ }
+ }
+ );
+ }
if (configurationResources != null && !configurationResources.isEmpty()) {
final List<Resource> filtered = configurationResources.stream()
@@ -351,7 +415,7 @@ public class ApplicationContextBuilder {
beanDefinitionReader.loadBeanDefinitions(filtered.toArray(new Resource[] {}));
}
}
-
+
if (contextInitializers != null) {
contextInitializers.forEach(i -> i.initialize(context));
}
@@ -359,5 +423,5 @@ public class ApplicationContextBuilder {
context.refresh();
return context;
}
-// Checkstyle: CyclomaticComplexity ON
+// Checkstyle: CyclomaticComplexity|MethodLength ON
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list