AbstractApplicationContext createApplicationContext(Api api) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.setParent(gatewayApplicationContext); context.setClassLoader(new ReactorHandlerClassLoader(gatewayApplicationContext.getClassLoader())); context.setEnvironment((ConfigurableEnvironment) gatewayApplicationContext.getEnvironment()); PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setIgnoreUnresolvablePlaceholders(true); configurer.setEnvironment(gatewayApplicationContext.getEnvironment()); context.addBeanFactoryPostProcessor(configurer); context.getBeanFactory().registerSingleton("api", api); context.register(ApiHandlerConfiguration.class); context.setId("context-api-" + api.getId()); context.refresh(); return context; }
@Configuration public class Test { @Value("${prop1}") //props1.properties contains prop1=val1 String prop1; public static void main(String[] args) throws Exception { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(Test.class); PropertySourcesPlaceholderConfigurer pph = new PropertySourcesPlaceholderConfigurer(); pph.setLocation(new ClassPathResource("/props1.properties")); ctx.addBeanFactoryPostProcessor(pph); ctx.refresh(); Test test = ctx.getBean(Test.class); System.out.println(test.prop1); } }
appContext.addBeanFactoryPostProcessor(beanFactory -> { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.postProcessBeanFactory(beanFactory);
private static void addPostprocessorAndUpdateContext(Class<?> currentVerticleClass, AnnotationConfigApplicationContext annotationConfigApplicationContext) { annotationConfigApplicationContext.addBeanFactoryPostProcessor(new SpringSingleVerticleConfiguration(currentVerticleClass)); annotationConfigApplicationContext.refresh(); annotationConfigApplicationContext.start(); annotationConfigApplicationContext.registerShutdownHook(); }
public BristlebackServerInstance resolverServerInstance() { InitialConfiguration initialConfiguration = initialConfigurationResolver.resolveConfiguration(); startLogger(initialConfiguration); AnnotationConfigApplicationContext frameworkContext = new AnnotationConfigApplicationContext(); BristleSpringIntegration springIntegration = new BristleSpringIntegration(actualApplicationContext, frameworkContext); BristlebackBeanFactoryPostProcessor bristlebackPostProcessor = new BristlebackBeanFactoryPostProcessor(initialConfiguration, springIntegration); frameworkContext.addBeanFactoryPostProcessor(bristlebackPostProcessor); frameworkContext.register(SpringConfigurationResolver.class); frameworkContext.scan(InitialConfiguration.SYSTEM_BASE_PACKAGES); frameworkContext.refresh(); BristlebackConfig configuration = frameworkContext.getBean("bristlebackConfigurationFinal", BristlebackConfig.class); return new BristlebackServerInstance(configuration); }
AbstractApplicationContext createApplicationContext(Domain domain) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.setParent(gatewayApplicationContext); context.setClassLoader(new ReactorHandlerClassLoader(gatewayApplicationContext.getClassLoader())); context.setEnvironment((ConfigurableEnvironment) gatewayApplicationContext.getEnvironment()); PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setIgnoreUnresolvablePlaceholders(true); configurer.setEnvironment(gatewayApplicationContext.getEnvironment()); context.addBeanFactoryPostProcessor(configurer); context.getBeanFactory().registerSingleton("domain", domain); context.register(HandlerConfiguration.class); context.setId("context-domain-" + domain.getId()); context.refresh(); return context; }
public SpringContextSupport build(String[] packages) { applicationContext = new AnnotationConfigApplicationContext(); applicationContext.scan(packages); applicationContext.addBeanFactoryPostProcessor(propertyPlaceholderConfigurerWith(providedProperties)); applicationContext.refresh(); return this; }
AbstractApplicationContext createApplicationContext(Domain domain) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.setParent(gatewayApplicationContext); context.setClassLoader(new ReactorHandlerClassLoader(gatewayApplicationContext.getClassLoader())); context.setEnvironment((ConfigurableEnvironment) gatewayApplicationContext.getEnvironment()); PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setIgnoreUnresolvablePlaceholders(true); configurer.setEnvironment(gatewayApplicationContext.getEnvironment()); context.addBeanFactoryPostProcessor(configurer); context.getBeanFactory().registerSingleton("domain", domain); context.register(HandlerConfiguration.class); context.setId("context-domain-" + domain.getId()); context.refresh(); return context; }
classTestNeedContainers); appContext.addBeanFactoryPostProcessor(postProcessor);