package de.juplo.demos.multiplebeans;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;
@Override
public void initialize(ConfigurableApplicationContext context) {
+ context.refresh();
MultipleBeansProperties properties = context.getBean(MultipleBeansProperties.class);
- System.out.println(properties.project);
+ ConfigurableListableBeanFactory factory = context.getBeanFactory();
+ for (MultipleBeansProperties.Site site : properties.sites) {
+ SiteController controller = new SiteController(site.name, site.description);
+ factory.registerSingleton("/" + site.name, controller);
+ }
}
}