List of usage examples for org.springframework.beans.factory.support RootBeanDefinition setAttribute
@Override public void setAttribute(String name, @Nullable Object value)
From source file:org.solmix.runtime.support.spring.ContainerPostProcessor.java
private Object getContainerByName(String name, ConfigurableListableBeanFactory factory, boolean create, String cn) {//from w w w .j ava2s . c o m if (!factory.containsBeanDefinition(name) && (create || Container.DEFAULT_CONTAINER_ID.equals(name))) { // DefaultListableBeanFactory df = (DefaultListableBeanFactory) factory; RootBeanDefinition rbd = new RootBeanDefinition(SpringContainer.class); if (cn != null) { // SpringContainer.setConfig rbd.setAttribute("config", new RuntimeBeanReference(cn)); } df.registerBeanDefinition(name, rbd); } else if (cn != null) { BeanDefinition bd = factory.getBeanDefinition(name); bd.getPropertyValues().addPropertyValue("config", new RuntimeBeanReference(cn)); } return new RuntimeBeanReference(name); }
From source file:org.metaeffekt.dcc.commons.spring.xml.DCCConfigurationBeanDefinitionParser.java
private void registerProfileFactoryBeanIfRequired(String profileId, String deploymentId, String profileType, String profileDescription, File origin, BeanDefinitionRegistry registry, String solutionPropertiesPath, String deploymentPropertiesPath, ParserContext parserContext) { if (!registry.containsBeanDefinition(THE_ONE_TRUE_PROFILE_BEAN_NAME)) { BeanDefinitionBuilder profileFactoryBuilder = BeanDefinitionBuilder .rootBeanDefinition(ProfileFactoryBean.class); profileFactoryBuilder.addConstructorArgValue(Id.createProfileId(profileId)); profileFactoryBuilder.addConstructorArgValue(Id.createDeploymentId(deploymentId)); profileFactoryBuilder.addConstructorArgValue(profileType); profileFactoryBuilder.addConstructorArgValue(profileDescription); profileFactoryBuilder.addConstructorArgValue(origin); profileFactoryBuilder.addPropertyValue(PROPERTY_SOLUTION_PROPERTIES_PATH, solutionPropertiesPath); profileFactoryBuilder.addPropertyValue(PROPERTY_DEPLOYMENT_PROPERTIES_PATH, deploymentPropertiesPath); final ResourceLoader resourceLoader = parserContext.getReaderContext().getResourceLoader(); if (resourceLoader instanceof ProfileApplicationContext) { File solutionDir = ((ProfileApplicationContext) resourceLoader).getSolutionDir(); profileFactoryBuilder.addPropertyValue(PROPERTY_SOLUTION_DIR, solutionDir); }/* w ww . j av a 2 s . c om*/ registry.registerBeanDefinition(THE_ONE_TRUE_PROFILE_BEAN_NAME, profileFactoryBuilder.getBeanDefinition()); RootBeanDefinition factoryBean = (RootBeanDefinition) registry .getBeanDefinition(THE_ONE_TRUE_PROFILE_BEAN_NAME); factoryBean.setAttribute("builder", profileFactoryBuilder); } else { RootBeanDefinition factoryBean = (RootBeanDefinition) registry .getBeanDefinition(THE_ONE_TRUE_PROFILE_BEAN_NAME); BeanDefinitionBuilder builder = (BeanDefinitionBuilder) factoryBean.getAttribute("builder"); if (solutionPropertiesPath != null) { builder.addPropertyValue(PROPERTY_SOLUTION_PROPERTIES_PATH, solutionPropertiesPath); } if (deploymentPropertiesPath != null) { builder.addPropertyValue(PROPERTY_DEPLOYMENT_PROPERTIES_PATH, deploymentPropertiesPath); } } }