--- /dev/null
+package de.juplo.demos.multiplebeans;
+
+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.Arrays;
+
+public class MultipleBeansEnvironmentPostProcessor implements EnvironmentPostProcessor {
+
+ @Override
+ public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
+ String sites = null;
+ for (PropertySource source : environment.getPropertySources()) {
+ Object found = source.getProperty("juplo.sites");
+ if (found != null)
+ sites = found.toString();
+ }
+
+ if (sites == null)
+ throw new IllegalArgumentException("Parameter juplo.sites is not set!");
+
+ application.addInitializers(new MultipleBeansApplicationContextInitializer(
+ Arrays.stream(sites.split(","))
+ .map(site -> site.trim())
+ .toArray(size -> new String[size])));
+ }
+}
\ No newline at end of file