[spring-extensions] branch master updated: JSE-38 - Provide a command line wrapper for Spring contexts
Rod Widdowson
rdw at steadingsoftware.com
Thu Jul 30 10:32:51 UTC 2020
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository spring-extensions.
View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=f4db4e96b9abbecf1146a106dcd0df8096d963e2
The following commit(s) were added to refs/heads/master by this push:
new f4db4e9 JSE-38 - Provide a command line wrapper for Spring contexts
f4db4e9 is described below
commit f4db4e96b9abbecf1146a106dcd0df8096d963e2
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jul 28 14:44:55 2020 +0100
JSE-38 - Provide a command line wrapper for Spring contexts
https://issues.shibboleth.net/jira/browse/JSE-38
Allow for more resource files to be included into the
spring context controlled by the CLI program
---
.../ext/spring/cli/AbstractCommandLine.java | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/main/java/net/shibboleth/ext/spring/cli/AbstractCommandLine.java b/src/main/java/net/shibboleth/ext/spring/cli/AbstractCommandLine.java
index 164944e..4f4d1af 100644
--- a/src/main/java/net/shibboleth/ext/spring/cli/AbstractCommandLine.java
+++ b/src/main/java/net/shibboleth/ext/spring/cli/AbstractCommandLine.java
@@ -20,6 +20,7 @@ package net.shibboleth.ext.spring.cli;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;
@@ -40,6 +41,8 @@ import com.beust.jcommander.JCommander;
import net.shibboleth.ext.spring.resource.PreferFileSystemResourceLoader;
import net.shibboleth.ext.spring.util.ApplicationContextBuilder;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotLive;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.logic.Constraint;
/**
@@ -86,6 +89,14 @@ public abstract class AbstractCommandLine<T extends CommandLineArguments> {
return applicationContext;
}
+ /** Return any additional resources that should be prepended to that
+ * supplied by the user.
+ * @return the resources.
+ */
+ @Nonnull @Unmodifiable @NotLive protected List<Resource> getAdditionalSpringResources() {
+ return Collections.emptyList();
+ }
+
/**
* Run method.
*
@@ -181,7 +192,12 @@ public abstract class AbstractCommandLine<T extends CommandLineArguments> {
try {
final ResourceLoader loader = new PreferFileSystemResourceLoader();
final Resource config = loader.getResource(args.getOtherArgs().get(0));
-
+ final List<Resource> additionalConfigs = getAdditionalSpringResources();
+ final List<Resource> configs = new ArrayList<>(1+additionalConfigs.size());
+
+ configs.addAll(additionalConfigs);
+ configs.add(config);
+
getLogger().debug("Initializing Spring context with configuration file {}", config.getURI());
final List<Resource> resources =
@@ -200,7 +216,7 @@ public abstract class AbstractCommandLine<T extends CommandLineArguments> {
});
applicationContext = new ApplicationContextBuilder()
- .setServiceConfiguration(config)
+ .setServiceConfigurations(configs)
.setPropertySources(propertySources)
.build();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list