From: Kai Moritz Date: Fri, 20 Nov 2020 23:39:54 +0000 (+0100) Subject: WIP X-Git-Tag: wip-implementation~2 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=031b0259628a2c5da59ce760d8871620c662820b;p=demos%2Fmultiple-beans WIP --- diff --git a/src/main/java/de/juplo/demos/multiplebeans/HomeController.java b/src/main/java/de/juplo/demos/multiplebeans/HomeController.java new file mode 100644 index 0000000..2645129 --- /dev/null +++ b/src/main/java/de/juplo/demos/multiplebeans/HomeController.java @@ -0,0 +1,2 @@ +package de.juplo.demos.multiplebeans;public class HomeController { +} diff --git a/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansBeanFactoryPostProcessor.java b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansBeanFactoryPostProcessor.java deleted file mode 100644 index 50bbbc7..0000000 --- a/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansBeanFactoryPostProcessor.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.juplo.demos.multiplebeans; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.stereotype.Component; - -public class MultipleBeansBeanFactoryPostProcessor implements BeanFactoryPostProcessor { - - public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) throws BeansException { - - MultipleBeansProperties properties = factory.getBean(MultipleBeansProperties.class); - BeanDefinitionRegistry registry = (BeanDefinitionRegistry)factory; - - for (MultipleBeansProperties.Site site : properties.sites) { - BeanDefinition beanDefinition = - BeanDefinitionBuilder - .genericBeanDefinition(SiteController.class) - .addConstructorArgValue(site.name) - .addConstructorArgValue(site.description) - .getBeanDefinition(); - - registry.registerBeanDefinition("name", beanDefinition); - } - } -} diff --git a/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansProperties.java b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansProperties.java deleted file mode 100644 index 5d1e2fd..0000000 --- a/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansProperties.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.juplo.demos.multiplebeans; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.boot.context.properties.ConfigurationProperties; - -@ConfigurationProperties("juplo") -@Getter -@Setter -public class MultipleBeansProperties { - - String project; - Site[] sites; - - - @Getter - @Setter - public static class Site { - - String name; - String description; - } -} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 87bec8d..01ec1b0 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,9 +1,2 @@ juplo: - project: multiple-beans - 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! + sites: peter, ute, franz diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html new file mode 100644 index 0000000..e2b7b4f --- /dev/null +++ b/src/main/resources/templates/home.html @@ -0,0 +1,25 @@ + + + + Home + + + + +

Home

+
+ +
+
+

+ + This page links to the pages, that are served by the dynamically created beans. + +

+
+ +