[java-shib-shared] branch main updated: JSSH-33 - Review property placement behavior in context builder
Scott Cantor
cantor.2 at osu.edu
Tue Jun 13 21:05:15 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-shared.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=8ccbf556e4611fad08b65ce6929d1f81cd474094
The following commit(s) were added to refs/heads/main by this push:
new 8ccbf556 JSSH-33 - Review property placement behavior in context builder
8ccbf556 is described below
commit 8ccbf556e4611fad08b65ce6929d1f81cd474094
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Jun 13 17:05:12 2023 -0400
JSSH-33 - Review property placement behavior in context builder
https://shibboleth.atlassian.net/browse/JSSH-33
Belt and suspenders in the expected property configurer.
Inject ApplicationContext/Environment where required by bean processors.
---
.../spring/util/ApplicationContextBuilder.java | 30 ++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/shib-spring/src/main/java/net/shibboleth/shared/spring/util/ApplicationContextBuilder.java b/shib-spring/src/main/java/net/shibboleth/shared/spring/util/ApplicationContextBuilder.java
index 05045b97..a4551e30 100644
--- a/shib-spring/src/main/java/net/shibboleth/shared/spring/util/ApplicationContextBuilder.java
+++ b/shib-spring/src/main/java/net/shibboleth/shared/spring/util/ApplicationContextBuilder.java
@@ -47,9 +47,12 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.EnvironmentAware;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.Resource;
@@ -356,11 +359,29 @@ public class ApplicationContextBuilder {
}
if (factoryPostProcessors != null) {
- factoryPostProcessors.forEach(bfpp -> context.addBeanFactoryPostProcessor(bfpp));
+ for (final BeanFactoryPostProcessor bfpp : factoryPostProcessors) {
+ assert bfpp != null;
+ context.addBeanFactoryPostProcessor(bfpp);
+ if (bfpp instanceof ApplicationContextAware aware) {
+ aware.setApplicationContext(context);
+ }
+ if (bfpp instanceof EnvironmentAware aware) {
+ aware.setEnvironment(context.getEnvironment());
+ }
+ }
}
if (postProcessors != null) {
- postProcessors.forEach(bpp -> context.getBeanFactory().addBeanPostProcessor(bpp));
+ for (final BeanPostProcessor bpp : postProcessors) {
+ assert bpp != null;
+ context.getBeanFactory().addBeanPostProcessor(bpp);
+ if (bpp instanceof ApplicationContextAware aware) {
+ aware.setApplicationContext(context);
+ }
+ if (bpp instanceof EnvironmentAware aware) {
+ aware.setEnvironment(context.getEnvironment());
+ }
+ }
}
if (beanProfiles != null) {
@@ -373,6 +394,11 @@ public class ApplicationContextBuilder {
propertySources.forEach(p -> context.getEnvironment().getPropertySources().addLast(p));
context.getEnvironment().setPlaceholderPrefix("%{");
context.getEnvironment().setPlaceholderSuffix("}");
+ final PropertySourcesPlaceholderConfigurer propertyConfigurer = new PropertySourcesPlaceholderConfigurer();
+ propertyConfigurer.setPlaceholderPrefix("%{");
+ propertyConfigurer.setPlaceholderSuffix("}");
+ propertyConfigurer.setEnvironment(context.getEnvironment());
+ context.getBeanFactoryPostProcessors().add(propertyConfigurer);
}
if (installShutdownHook) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list