@Override protected void doInitialise() throws InitialisationException { ((AbstractApplicationContext) applicationContext) .addBeanFactoryPostProcessor(createBeforeInitialisationRegisteredObjectsPostProcessor()); // This is used to track the Spring context lifecycle since there is no way to confirm the lifecycle phase from the // application context springContextInitialised.set(true); if (!readOnly) { ((ConfigurableApplicationContext) applicationContext).refresh(); } }
private void doCopyBeanFactoryPostProcessor(BeanFactoryPostProcessor postProcessor) { if (ignoredBeanPostProcessors.contains(postProcessor.getClass().getName())) return; logger.debug(String.format("copying BeanFactoryPostProcessor %s to child context %s", postProcessor, child)); child.addBeanFactoryPostProcessor(postProcessor); }
@Override protected void doInitialise() throws InitialisationException { ((AbstractApplicationContext) applicationContext) .addBeanFactoryPostProcessor(createBeforeInitialisationRegisteredObjectsPostProcessor()); // This is used to track the Spring context lifecycle since there is no way to confirm the lifecycle phase from the // application context springContextInitialised.set(true); if (!readOnly) { ((ConfigurableApplicationContext) applicationContext).refresh(); } }
private void updateRmiPort(final AbstractApplicationContext applicationContext, final int rmiPort) { final PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer(); Properties properties = new Properties(); properties.put("rmiPort", Integer.toString(rmiPort)); propertyPlaceholderConfigurer.setProperties(properties); propertyPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true); applicationContext.addBeanFactoryPostProcessor(propertyPlaceholderConfigurer); }
protected void safeAddBeanScopePostProcessors( ApplicationContext appCtx ) { if( appCtx != null && appCtx instanceof AbstractApplicationContext ) { boolean beanScopePostProcessorExists = false; for( BeanFactoryPostProcessor bfpp : ( ( AbstractApplicationContext ) appCtx ).getBeanFactoryPostProcessors() ) { beanScopePostProcessorExists |= ( bfpp != null && bfpp instanceof PentahoBeanScopeValidatorPostProcessor ); } if( !beanScopePostProcessorExists ){ ( ( AbstractApplicationContext ) appCtx ).addBeanFactoryPostProcessor( new PentahoBeanScopeValidatorPostProcessor() ); } } } }
@Override protected Scope doStart(Scope aExternalScope) { SpringComponent old = THIS.get(); Scope oldScope = SCOPE.get(); THIS.set(this); Scope scope = new DefaultScope(getProvidedInterfaces().toArray( new ProvidedInterface[0]), aExternalScope); SCOPE.set(scope); try { GenericApplicationContext parentContext = new GenericApplicationContext(); registerRequiredServices(parentContext); registerPropertyObjects(parentContext); parentContext.refresh(); System.out.println("Parent context " + parentContext); AbstractApplicationContext context = parseConfigFiles(parentContext); context.addBeanFactoryPostProcessor(new PropertySetter(properties)); context.refresh(); exposeProvidedServices(context, aExternalScope); scope.put(CONTEXT_KEY, context); return scope; } catch (Exception e) { throw new SystemAssemblyException( "Failed to assemble spring system " + getName(), e); } finally { THIS.set(old); SCOPE.set(oldScope); } }
private void createChildContext() { if (appMetadata.isWebapp()) { applicationContext = new AnnotationConfigWebApplicationContext(); if (appMetadata.getConfigurationClasses().length > 0) { ((AnnotationConfigWebApplicationContext) applicationContext).register(appMetadata.getConfigurationClasses()); } } else { applicationContext = new AnnotationConfigApplicationContext(); if (appMetadata.getConfigurationClasses().length > 0) { ((AnnotationConfigApplicationContext) applicationContext).register(appMetadata.getConfigurationClasses()); } } applicationContext.setParent(bootstrapApplicationContext); applicationContext.getEnvironment().getPropertySources().addFirst(new ArchaiusSpringPropertySource(appMetadata.getName() + "-archaius")); PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setEnvironment(applicationContext.getEnvironment()); applicationContext.addBeanFactoryPostProcessor(configurer); applicationContext.setId(appMetadata.getName()); applicationContext.refresh(); }