List of usage examples for org.springframework.beans.factory.support BeanDefinitionRegistry registerBeanDefinition
void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException;
From source file:org.fishwife.jrugged.spring.config.MonitorMethodInterceptorDefinitionDecorator.java
/** * Register a new SingleServiceWrapperInterceptor for the bean being * wrapped, associate it with the PerformanceMonitor and tell it which methods * to intercept./* ww w . j ava2 s . c o m*/ * * @param source An Attribute node from the spring configuration * @param beanName The name of the bean that this performance monitor is wrapped around * @param registry The registry where all the spring beans are registered */ private void registerInterceptor(Node source, String beanName, BeanDefinitionRegistry registry) { List<String> methodList = buildMethodList(source); BeanDefinitionBuilder initializer = BeanDefinitionBuilder .rootBeanDefinition(SingleServiceWrapperInterceptor.class); initializer.addPropertyValue("methods", methodList); String perfMonitorName = beanName + "PerformanceMonitor"; initializer.addPropertyReference("serviceWrapper", perfMonitorName); String interceptorName = beanName + "PerformanceMonitorInterceptor"; registry.registerBeanDefinition(interceptorName, initializer.getBeanDefinition()); }
From source file:com.clican.pluto.dataprocess.spring.parser.AbstractProcessorParser.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinitionRegistry bdr = parserContext.getRegistry(); RootBeanDefinition beanDef = new RootBeanDefinition(); beanDef.setDestroyMethodName("destroy"); beanDef.setAbstract(false);//from ww w. jav a 2s . c o m beanDef.setBeanClass(getDataProcessorClass()); beanDef.setLazyInit(false); beanDef.setAutowireMode(Autowire.BY_NAME.value()); String id = element.getAttribute("id"); if (bdr.containsBeanDefinition(id)) { throw new RuntimeException("id[" + id + "]??"); } bdr.registerBeanDefinition(id, beanDef); beanDef.getPropertyValues().addPropertyValue("id", id); String startProcessor = element.getAttribute("startProcessor"); boolean sp = false; if (StringUtils.isNotEmpty(startProcessor)) { sp = Boolean.parseBoolean(startProcessor); } beanDef.getPropertyValues().addPropertyValue("startProcessor", sp); String transaction = element.getAttribute("transaction"); if (StringUtils.isNotEmpty(transaction)) { beanDef.getPropertyValues().addPropertyValue("transaction", transaction); } else if (sp) { beanDef.getPropertyValues().addPropertyValue("transaction", TransactionMode.BEGIN.getMode()); } String cloneContext = element.getAttribute("cloneContext"); if (StringUtils.isNotEmpty(cloneContext)) { beanDef.getPropertyValues().addPropertyValue("cloneContext", Boolean.parseBoolean(cloneContext)); } String propagations = element.getAttribute("propagations"); if (StringUtils.isNotEmpty(propagations)) { List<String> propataionList = new ArrayList<String>(); for (String propagation : propagations.split(",")) { propataionList.add(propagation); } beanDef.getPropertyValues().addPropertyValue("propagations", propataionList); } String nextDataProcessors = element.getAttribute("nextDataProcessors"); if (StringUtils.isNotEmpty(nextDataProcessors)) { List nextDataProcessList = new ManagedList(); for (String nextDataProcess : nextDataProcessors.split(",")) { nextDataProcess = nextDataProcess.trim(); nextDataProcessList.add(new RuntimeBeanReference(nextDataProcess)); } beanDef.getPropertyValues().addPropertyValue("nextDataProcessors", nextDataProcessList); } customiseBeanDefinition(beanDef, element, parserContext); return beanDef; }
From source file:org.craftercms.commons.ebus.config.EBusBeanDefinitionRegistrar.java
@Override public void registerBeanDefinitions(final AnnotationMetadata annotationMetadata, final BeanDefinitionRegistry beanDefinitionRegistry) { // Create a root Environment if (!beanDefinitionRegistry.containsBeanDefinition(DEFAULT_EBUS_ENVIRONMENT_NAME)) { BeanDefinitionBuilder envBeanDef = BeanDefinitionBuilder .rootBeanDefinition(CreateOrReuseFactoryBean.class); envBeanDef.addConstructorArgValue(DEFAULT_EBUS_ENVIRONMENT_NAME); envBeanDef.addConstructorArgValue(Environment.class); Supplier<Environment> envSupplier = new DefaultEnvironmentSupplier(); envBeanDef.addConstructorArgValue(envSupplier); beanDefinitionRegistry.registerBeanDefinition(DEFAULT_EBUS_ENVIRONMENT_NAME, envBeanDef.getBeanDefinition()); }//from w w w .ja va 2 s . c o m // Create a EBusBeanAutoConfiguration if (!beanDefinitionRegistry.containsBeanDefinition(EBusBeanAutoConfiguration.class.getName())) { BeanDefinitionBuilder autoConfigDef = BeanDefinitionBuilder .rootBeanDefinition(EBusBeanAutoConfiguration.class); beanDefinitionRegistry.registerBeanDefinition(EBusBeanAutoConfiguration.class.getName(), autoConfigDef.getBeanDefinition()); } }
From source file:com.github.xdcrafts.flower.spring.impl.DefaultActionDefinitionFactory.java
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { actions.entrySet().forEach(entry -> { final String name = entry.getKey(); final String qualifiedName = Named.qualifiedName(this.namespace, name); final Object method = entry.getValue(); final MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("method", method); final GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(DefaultActionFactory.class); beanDefinition.setPropertyValues(propertyValues); registry.registerBeanDefinition(qualifiedName, beanDefinition); });//from ww w . j ava 2 s.co m }
From source file:org.wallride.autoconfigure.WebAdminComponentScanRegistrar.java
private void addWebAdminComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(WebAdminComponentScanBeanPostProcessor.class); beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(toArray(packagesToScan)); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); // We don't need this one to be post processed otherwise it can cause a // cascade of bean instantiation that we would rather avoid. beanDefinition.setSynthetic(true);/*from ww w. j av a 2s.co m*/ registry.registerBeanDefinition(BEAN_NAME, beanDefinition); }
From source file:org.wallride.autoconfigure.WebGuestComponentScanRegistrar.java
private void addWebGuestComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(WebGuestComponentScanBeanPostProcessor.class); beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(toArray(packagesToScan)); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); // We don't need this one to be post processed otherwise it can cause a // cascade of bean instantiation that we would rather avoid. beanDefinition.setSynthetic(true);/*from ww w.j a v a2 s.co m*/ registry.registerBeanDefinition(BEAN_NAME, beanDefinition); }
From source file:org.springmodules.cache.config.MethodMapInterceptorsParser.java
private void registerCachingInterceptor(String cachingInterceptorId, BeanDefinitionRegistry registry, CacheSetupStrategyPropertySource propertySource) { MutablePropertyValues propertyValues = new MutablePropertyValues(); RootBeanDefinition cachingInterceptor = new RootBeanDefinition(MethodMapCachingInterceptor.class, propertyValues);// w w w . j a v a 2 s . c om propertyValues.addPropertyValue(propertySource.getCacheKeyGeneratorProperty()); propertyValues.addPropertyValue(propertySource.getCacheProviderFacadeProperty()); propertyValues.addPropertyValue(propertySource.getCachingListenersProperty()); propertyValues.addPropertyValue(propertySource.getCachingModelsProperty()); registry.registerBeanDefinition(cachingInterceptorId, cachingInterceptor); }
From source file:org.lightadmin.core.config.bootstrap.LightAdminBeanDefinitionRegistryPostProcessor.java
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { WebApplicationContext rootContext = WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext); EntityManager entityManager = findEntityManager(rootContext); ResourceLoader resourceLoader = newResourceLoader(servletContext); Set<Class> administrationConfigs = scanPackageForAdministrationClasses(); Set<ConfigurationUnits> configurationUnits = configurationUnits(rootContext, administrationConfigs); registry.registerBeanDefinition(JPA_MAPPPING_CONTEXT_BEAN, mappingContext(entityManager)); registry.registerBeanDefinition(CONFIGURATION_UNITS_VALIDATOR_BEAN, configurationUnitsValidator(resourceLoader)); for (Class<?> managedEntityType : managedEntities(entityManager)) { Class repoInterface = createDynamicRepositoryClass(managedEntityType, entityManager); registry.registerBeanDefinition(beanName(repoInterface), repositoryFactory(repoInterface, entityManager)); }/*from w ww . jav a2s .co m*/ registerRepositoryEventListeners(configurationUnits, registry); registry.registerBeanDefinition(beanName(GlobalAdministrationConfiguration.class), globalAdministrationConfigurationFactoryBeanDefinition(configurationUnits)); registry.registerBeanDefinition(beanName(DomainTypeAdministrationConfigurationFactory.class), domainTypeAdministrationConfigurationFactoryDefinition(entityManager)); }
From source file:io.fabric8.spring.cloud.kubernetes.archaius.ArchaiusConfigMapSourceRegistar.java
private void registerSourceConfiguration(BeanDefinitionRegistry registry, Object name, Object namespace) { BeanDefinitionBuilder configMapSourceConfigBuilder = BeanDefinitionBuilder .genericBeanDefinition(ArchaiusConfigMapSourceConfiguration.class); BeanDefinitionBuilder dynamicWatchedConfigBuilder = BeanDefinitionBuilder .genericBeanDefinition(DynamicWatchedConfiguration.class); configMapSourceConfigBuilder.addConstructorArgReference(KUBERNETES_CLIENT_REF); configMapSourceConfigBuilder.addConstructorArgValue(name); configMapSourceConfigBuilder.addConstructorArgValue(namespace); String configMapSourceConfigName = name + CONFIG_MAP_SOURCE_SUFFIX; registry.registerBeanDefinition(configMapSourceConfigName, configMapSourceConfigBuilder.getBeanDefinition()); String dynamicWatchedConfigName = name + DYNAMIC_WATCH_CONFIG_SUFFIX; dynamicWatchedConfigBuilder.addConstructorArgReference(configMapSourceConfigName); registry.registerBeanDefinition(dynamicWatchedConfigName, dynamicWatchedConfigBuilder.getBeanDefinition()); }
From source file:org.springmodules.cache.config.AbstractMetadataAttributesParser.java
private void registerFlushingInterceptor(BeanDefinitionRegistry registry, CacheSetupStrategyPropertySource propertySource) { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.addPropertyValue(propertySource.getCacheProviderFacadeProperty()); propertyValues.addPropertyValue(propertySource.getFlushingModelsProperty()); RootBeanDefinition flushingInterceptor = new RootBeanDefinition(MetadataFlushingInterceptor.class, propertyValues);/*from w w w. j a va2s .c om*/ configureFlushingInterceptor(propertyValues, registry); String beanName = BeanName.FLUSHING_INTERCEPTOR; registry.registerBeanDefinition(beanName, flushingInterceptor); }