From: Kai Moritz Date: Fri, 20 Nov 2020 22:55:33 +0000 (+0100) Subject: WIP X-Git-Tag: wip-implementation~3 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=24b105c665fd11d97e6a00a058b9150b9c855d8c;p=demos%2Fmultiple-beans WIP --- diff --git a/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansEnvironmentPostProcessor.java b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansEnvironmentPostProcessor.java new file mode 100644 index 0000000..132f6ee --- /dev/null +++ b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansEnvironmentPostProcessor.java @@ -0,0 +1,20 @@ +package de.juplo.demos.multiplebeans; + +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.env.EnvironmentPostProcessor; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.PropertySource; + +import java.util.regex.Pattern; + +public class MultipleBeansEnvironmentPostProcessor implements EnvironmentPostProcessor { + public final static Pattern PATTERN = Pattern.compile("juplo\\.sites\\[([0-9]+)\\]\\.(.+)"); + + @Override + public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { + for (PropertySource source : environment.getPropertySources()) { + System.out.println(source.getName()); + } + } +} diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories index 5c9c458..05adff8 100644 --- a/src/main/resources/META-INF/spring.factories +++ b/src/main/resources/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.context.ApplicationContextInitializer=de.juplo.demos.multiplebeans.MultipleBeansApplicationContextInitializer +org.springframework.boot.env.EnvironmentPostProcessor=de.juplo.demos.multiplebeans.MultipleBeansEnvironmentPostProcessor \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 04397c1..87bec8d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,4 +3,7 @@ juplo: sites: - name: peter description: This is the Home-Page of PETER - + - name: ute + description: My name is Ute. I like cats! + - name: franz + description: Franz was here!