org.springframework.beans.factory.support.BeanDefinitionReaderUtils Java Examples
The following examples show how to use
org.springframework.beans.factory.support.BeanDefinitionReaderUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DDDBeanRegistryPostProcessor.java From flower with Apache License 2.0 | 6 votes |
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { Set<String> serviceTypes = new HashSet<>(); Class<?> services[] = new Class<?>[] {CommandHandlerService.class, EventHandlerService.class, QueryHandlerService.class, DDDStartService.class, DDDEndService.class, DefaultCommandGateway.class, DefaultQueryGateway.class}; for (Class<?> service : services) { BeanDefinition beanDefinition = new RootBeanDefinition(service); String handlerServiceName = BeanDefinitionReaderUtils.generateBeanName(beanDefinition, registry); registry.registerBeanDefinition(handlerServiceName, beanDefinition); if (Service.class.isAssignableFrom(service)) { serviceTypes.add(service.getName()); } } final String dddFactoryName = "dddFactory"; if (registry.containsBeanDefinition(dddFactoryName)) { BeanDefinition dddFactoryBeanDefinition = registry.getBeanDefinition(dddFactoryName); dddFactoryBeanDefinition.getPropertyValues().add("serviceTypes", serviceTypes); } }
Example #2
Source File: BeanNameGenerationTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void naming() { String className = GeneratedNameBean.class.getName(); String targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "0"; GeneratedNameBean topLevel1 = (GeneratedNameBean) beanFactory.getBean(targetName); assertNotNull(topLevel1); targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "1"; GeneratedNameBean topLevel2 = (GeneratedNameBean) beanFactory.getBean(targetName); assertNotNull(topLevel2); GeneratedNameBean child1 = topLevel1.getChild(); assertNotNull(child1.getBeanName()); assertTrue(child1.getBeanName().startsWith(className)); GeneratedNameBean child2 = topLevel2.getChild(); assertNotNull(child2.getBeanName()); assertTrue(child2.getBeanName().startsWith(className)); assertFalse(child1.getBeanName().equals(child2.getBeanName())); }
Example #3
Source File: BeanDefinitionParserDelegate.java From java-technology-stack with MIT License | 6 votes |
@Nullable private BeanDefinitionHolder parseNestedCustomElement(Element ele, @Nullable BeanDefinition containingBd) { BeanDefinition innerDefinition = parseCustomElement(ele, containingBd); if (innerDefinition == null) { error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " + "This tag cannot be used nested inside <property>.", ele); return null; } String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdentityHexString(innerDefinition); if (logger.isTraceEnabled()) { logger.trace("Using generated bean name [" + id + "] for nested custom element '" + ele.getNodeName() + "'"); } return new BeanDefinitionHolder(innerDefinition, id); }
Example #4
Source File: ClassReloaderImpl.java From tephra with MIT License | 6 votes |
private void load(ClassLoader loader, String name) { try { DefaultListableBeanFactory lbf = (DefaultListableBeanFactory) applicationContext.getAutowireCapableBeanFactory(); BeanDefinition bd = BeanDefinitionReaderUtils.createBeanDefinition(null, name, loader); String dynamicBeanName = generator.uuid(); lbf.registerBeanDefinition(dynamicBeanName, bd); Object bean = lbf.getBean(dynamicBeanName); String beanName = getBeanName(bean.getClass()); Object oldBean = null; if (beanName != null) { oldBean = container.getBean(beanName); container.mapBeanName(beanName, dynamicBeanName); } inject(bean.getClass(), null, bean); inject(bean, oldBean); } catch (Exception e) { logger.warn(e, "重新载入[{}]时发生异常!", name); } }
Example #5
Source File: NetworkAssemble.java From network-spring-boot-starter with Apache License 2.0 | 6 votes |
@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { ClassPathScanningCandidateComponentProvider scanner = new ScanningComponent(Boolean.FALSE, this.environment); scanner.setResourceLoader(this.resourceLoader); AnnotationTypeFilter annotationTypeFilter = new AnnotationTypeFilter(Network.class); scanner.addIncludeFilter(annotationTypeFilter); String packageName = ClassUtils.getPackageName(importingClassMetadata.getClassName()); Set<BeanDefinition> candidateComponents = scanner.findCandidateComponents(packageName); candidateComponents.forEach(beanDefinition -> { AnnotatedBeanDefinition annotatedBeanDefinition = (AnnotatedBeanDefinition) beanDefinition; AnnotationMetadata annotationMetadata = annotatedBeanDefinition.getMetadata(); BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(NetworkFactory.class); String className = annotationMetadata.getClassName(); definition.addPropertyValue(NetworkFactoryConstants.PROPERTY_VALUE.getValue(), className); definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); AbstractBeanDefinition abstractBeanDefinition = definition.getBeanDefinition(); BeanDefinitionHolder holder = new BeanDefinitionHolder(abstractBeanDefinition, className); BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); }); }
Example #6
Source File: DefaultBeanDefinitionDocumentReader.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Process the given bean element, parsing the bean definition * and registering it with the registry. */ protected void processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate) { BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(ele); if (bdHolder != null) { bdHolder = delegate.decorateBeanDefinitionIfRequired(ele, bdHolder); try { // Register the final decorated instance. BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, getReaderContext().getRegistry()); } catch (BeanDefinitionStoreException ex) { getReaderContext().error("Failed to register bean definition with name '" + bdHolder.getBeanName() + "'", ele, ex); } // Send registration event. getReaderContext().fireComponentRegistered(new BeanComponentDefinition(bdHolder)); } }
Example #7
Source File: DefaultBeanDefinitionDocumentReader.java From java-technology-stack with MIT License | 6 votes |
/** * Process the given bean element, parsing the bean definition * and registering it with the registry. */ protected void processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate) { BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(ele); if (bdHolder != null) { bdHolder = delegate.decorateBeanDefinitionIfRequired(ele, bdHolder); try { // Register the final decorated instance. BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, getReaderContext().getRegistry()); } catch (BeanDefinitionStoreException ex) { getReaderContext().error("Failed to register bean definition with name '" + bdHolder.getBeanName() + "'", ele, ex); } // Send registration event. getReaderContext().fireComponentRegistered(new BeanComponentDefinition(bdHolder)); } }
Example #8
Source File: BeanNameGenerationTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void naming() { String className = GeneratedNameBean.class.getName(); String targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "0"; GeneratedNameBean topLevel1 = (GeneratedNameBean) beanFactory.getBean(targetName); assertNotNull(topLevel1); targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "1"; GeneratedNameBean topLevel2 = (GeneratedNameBean) beanFactory.getBean(targetName); assertNotNull(topLevel2); GeneratedNameBean child1 = topLevel1.getChild(); assertNotNull(child1.getBeanName()); assertTrue(child1.getBeanName().startsWith(className)); GeneratedNameBean child2 = topLevel2.getChild(); assertNotNull(child2.getBeanName()); assertTrue(child2.getBeanName().startsWith(className)); assertFalse(child1.getBeanName().equals(child2.getBeanName())); }
Example #9
Source File: DefaultBeanDefinitionDocumentReader.java From blog_demos with Apache License 2.0 | 6 votes |
/** * Process the given bean element, parsing the bean definition * and registering it with the registry. */ protected void processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate) { BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(ele); if (bdHolder != null) { bdHolder = delegate.decorateBeanDefinitionIfRequired(ele, bdHolder); try { // Register the final decorated instance. BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, getReaderContext().getRegistry()); } catch (BeanDefinitionStoreException ex) { getReaderContext().error("Failed to register bean definition with name '" + bdHolder.getBeanName() + "'", ele, ex); } // Send registration event. getReaderContext().fireComponentRegistered(new BeanComponentDefinition(bdHolder)); } }
Example #10
Source File: AbstractHasorDefinitionParser.java From hasor with Apache License 2.0 | 6 votes |
/**摘抄 Spring 源码,将Bean注册到容器中*/ private BeanDefinition registerBean(Element element, ParserContext parserContext, NamedNodeMap attributes, AbstractBeanDefinition definition) { if (!parserContext.isNested()) { try { String id = beanID(element, attributes); if (!StringUtils.hasText(id)) { parserContext.getReaderContext().error(beanID(element, attributes) + " is undefined. for element '" + element.getLocalName(), element); } BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, id); BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry()); parserContext.registerComponent(new BeanComponentDefinition(holder)); } catch (BeanDefinitionStoreException ex) { parserContext.getReaderContext().error(ex.getMessage(), element); return null; } } return definition; }
Example #11
Source File: AbstractRetrofitClientsRegistrar.java From spring-cloud-square with Apache License 2.0 | 6 votes |
private void registerRetrofitClient(BeanDefinitionRegistry registry, AnnotationMetadata annotationMetadata, Map<String, Object> attributes) { String className = annotationMetadata.getClassName(); BeanDefinitionBuilder definition = BeanDefinitionBuilder .genericBeanDefinition(getFactoryBeanClass()); validate(attributes); definition.addPropertyValue("url", getUrl(attributes)); String name = getName(attributes); definition.addPropertyValue("name", name); definition.addPropertyValue("type", className); definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); String alias = name + "RetrofitClient"; AbstractBeanDefinition beanDefinition = definition.getBeanDefinition(); beanDefinition.setPrimary(true); String qualifier = getQualifier(attributes); if (StringUtils.hasText(qualifier)) { alias = qualifier; } BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className, new String[] { alias }); BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); }
Example #12
Source File: BeanDefinitionParserDelegate.java From spring-analysis-note with MIT License | 6 votes |
@Nullable private BeanDefinitionHolder parseNestedCustomElement(Element ele, @Nullable BeanDefinition containingBd) { BeanDefinition innerDefinition = parseCustomElement(ele, containingBd); if (innerDefinition == null) { error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " + "This tag cannot be used nested inside <property>.", ele); return null; } String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdentityHexString(innerDefinition); if (logger.isTraceEnabled()) { logger.trace("Using generated bean name [" + id + "] for nested custom element '" + ele.getNodeName() + "'"); } return new BeanDefinitionHolder(innerDefinition, id); }
Example #13
Source File: WebMvcServerDsl.java From spring-fu with Apache License 2.0 | 6 votes |
@Override public void initialize(GenericApplicationContext context) { super.initialize(context); this.dsl.accept(this); context.registerBean(BeanDefinitionReaderUtils.uniqueBeanName(RouterFunction.class.getName(), context), RouterFunction.class, () -> RouterFunctions.route().resources("/**", new ClassPathResource("static/")).build() ); serverProperties.setPort(port); serverProperties.getServlet().setRegisterDefaultServlet(false); if (!convertersConfigured) { new StringConverterInitializer().initialize(context); new ResourceConverterInitializer().initialize(context); } if (context.containsBeanDefinition("webHandler")) { throw new IllegalStateException("Only one webFlux per application is supported"); } new ServletWebServerInitializer(serverProperties, webMvcProperties, resourceProperties).initialize(context); }
Example #14
Source File: BeanNameGenerationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void naming() { String className = GeneratedNameBean.class.getName(); String targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "0"; GeneratedNameBean topLevel1 = (GeneratedNameBean) beanFactory.getBean(targetName); assertNotNull(topLevel1); targetName = className + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + "1"; GeneratedNameBean topLevel2 = (GeneratedNameBean) beanFactory.getBean(targetName); assertNotNull(topLevel2); GeneratedNameBean child1 = topLevel1.getChild(); assertNotNull(child1.getBeanName()); assertTrue(child1.getBeanName().startsWith(className)); GeneratedNameBean child2 = topLevel2.getChild(); assertNotNull(child2.getBeanName()); assertTrue(child2.getBeanName().startsWith(className)); assertFalse(child1.getBeanName().equals(child2.getBeanName())); }
Example #15
Source File: AmazonWebserviceClientConfigurationUtils.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
public static BeanDefinitionHolder registerAmazonWebserviceClient(Object source, BeanDefinitionRegistry registry, String serviceNameClassName, String customRegionProvider, String customRegion) { String beanName = getBeanName(serviceNameClassName); if (registry.containsBeanDefinition(beanName)) { return new BeanDefinitionHolder(registry.getBeanDefinition(beanName), beanName); } BeanDefinition definition = getAmazonWebserviceClientBeanDefinition(source, serviceNameClassName, customRegionProvider, customRegion, registry); BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, beanName); BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); return holder; }
Example #16
Source File: DefaultBeanDefinitionDocumentReader.java From spring-analysis-note with MIT License | 6 votes |
/** * Process the given bean element, parsing the bean definition * and registering it with the registry. */ protected void processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate) { // 注释 1.15 解析 bean 名称的元素 BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(ele); if (bdHolder != null) { bdHolder = delegate.decorateBeanDefinitionIfRequired(ele, bdHolder); try { // Register the final decorated instance. (注释 1.16 注册最后修饰后的实例) BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, getReaderContext().getRegistry()); } catch (BeanDefinitionStoreException ex) { getReaderContext().error("Failed to register bean definition with name '" + bdHolder.getBeanName() + "'", ele, ex); } // Send registration event. 通知相关的监听器,表示这个 bean 已经加载完成 getReaderContext().fireComponentRegistered(new BeanComponentDefinition(bdHolder)); } }
Example #17
Source File: DefaultBeanDefinitionDocumentReader.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Process the given bean element, parsing the bean definition * and registering it with the registry. */ protected void processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate) { BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(ele); if (bdHolder != null) { bdHolder = delegate.decorateBeanDefinitionIfRequired(ele, bdHolder); try { // Register the final decorated instance. BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, getReaderContext().getRegistry()); } catch (BeanDefinitionStoreException ex) { getReaderContext().error("Failed to register bean definition with name '" + bdHolder.getBeanName() + "'", ele, ex); } // Send registration event. getReaderContext().fireComponentRegistered(new BeanComponentDefinition(bdHolder)); } }
Example #18
Source File: HttpRequestParamsValidateManager.java From common-project with Apache License 2.0 | 6 votes |
/** * 设置注册bean动态AOP信息 * * @param configs * @param beanFactory */ private void setAopInfo(List<String> configs, ConfigurableListableBeanFactory beanFactory) { if (beanFactory instanceof BeanDefinitionRegistry) { BeanDefinitionRegistry beanDefinitionRegistry = (BeanDefinitionRegistry) beanFactory; for (String config : configs) { //增强器 RootBeanDefinition advisor = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); advisor.getPropertyValues().addPropertyValue("adviceBeanName", new RuntimeBeanReference("httpParamsValidateAdvisor").getBeanName()); //切点类 RootBeanDefinition pointCut = new RootBeanDefinition(AspectJExpressionPointcut.class); pointCut.setScope(BeanDefinition.SCOPE_PROTOTYPE); pointCut.setSynthetic(true); pointCut.getPropertyValues().addPropertyValue("expression", config); advisor.getPropertyValues().addPropertyValue("pointcut", pointCut); //注册到spring容器 String beanName = BeanDefinitionReaderUtils.generateBeanName(advisor, beanDefinitionRegistry, false); beanDefinitionRegistry.registerBeanDefinition(beanName, advisor); } } }
Example #19
Source File: AnnotatedBeanDefinitionReader.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Register a bean from the given bean class, deriving its metadata from * class-declared annotations. * @param annotatedClass the class of the bean * @param name an explicit name for the bean * @param qualifiers specific qualifier annotations to consider, * in addition to qualifiers at the bean class level */ @SuppressWarnings("unchecked") public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers) { AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass); if (this.conditionEvaluator.shouldSkip(abd.getMetadata())) { return; } ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd); abd.setScope(scopeMetadata.getScopeName()); String beanName = (name != null ? name : this.beanNameGenerator.generateBeanName(abd, this.registry)); AnnotationConfigUtils.processCommonDefinitionAnnotations(abd); if (qualifiers != null) { for (Class<? extends Annotation> qualifier : qualifiers) { if (Primary.class == qualifier) { abd.setPrimary(true); } else if (Lazy.class == qualifier) { abd.setLazyInit(true); } else { abd.addQualifier(new AutowireCandidateQualifier(qualifier)); } } } BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(abd, beanName); definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry); BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, this.registry); }
Example #20
Source File: AbstractImportRegistrar.java From onetwo with Apache License 2.0 | 5 votes |
protected void registerComponent(BeanDefinitionRegistry registry, AnnotationMetadata annotationMetadata, AnnotationAttributes tagAttributes) { String className = annotationMetadata.getClassName(); String beanName = resolveName(tagAttributes, className); if(logger.isInfoEnabled()){ logger.info("register api client beanName: {}, class: {}", beanName, className); } BeanDefinitionBuilder definition = createComponentFactoryBeanBuilder(annotationMetadata, tagAttributes); String alias = beanName + "-" + getComponentAnnotationClass().getSimpleName(); AbstractBeanDefinition beanDefinition = definition.getBeanDefinition(); beanDefinition.setPrimary(true); BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, beanName, new String[] { alias }); BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); }
Example #21
Source File: ContextResourceLoaderConfiguration.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { BeanDefinitionHolder client = AmazonWebserviceClientConfigurationUtils .registerAmazonWebserviceClient(this, registry, AmazonS3Client.class.getName(), null, null); BeanDefinitionBuilder configurer = BeanDefinitionBuilder .genericBeanDefinition(SimpleStorageProtocolResolverConfigurer.class); configurer.addConstructorArgValue(getProtocolResolver(client)); BeanDefinitionReaderUtils .registerWithGeneratedName(configurer.getBeanDefinition(), registry); }
Example #22
Source File: ContextConfigurationUtils.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
public static void registerRegionProvider(BeanDefinitionRegistry registry, boolean autoDetect, boolean useDefaultRegionChain, String configuredRegion) { if (autoDetect && StringUtils.hasText(configuredRegion)) { throw new IllegalArgumentException( "No region must be configured if autoDetect is defined as true"); } AbstractBeanDefinition beanDefinition; if (autoDetect) { beanDefinition = BeanDefinitionBuilder.genericBeanDefinition( useDefaultRegionChain ? DefaultAwsRegionProviderChainDelegate.class : Ec2MetadataRegionProvider.class) .getBeanDefinition(); } else if (StringUtils.hasText(configuredRegion)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder .genericBeanDefinition(StaticRegionProvider.class); builder.addConstructorArgValue(configuredRegion); beanDefinition = builder.getBeanDefinition(); } else { throw new IllegalArgumentException( "Region must be manually configured or autoDetect enabled"); } BeanDefinitionReaderUtils.registerBeanDefinition( new BeanDefinitionHolder(beanDefinition, REGION_PROVIDER_BEAN_NAME), registry); AmazonWebserviceClientConfigurationUtils.replaceDefaultRegionProvider(registry, REGION_PROVIDER_BEAN_NAME); }
Example #23
Source File: ActivitiAnnotationDrivenBeanDefinitionParser.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
private void registerStateHandlerAnnotationBeanFactoryPostProcessor(Element element, ParserContext context) { Class clz = StateHandlerAnnotationBeanFactoryPostProcessor.class; BeanDefinitionBuilder postProcessorBuilder = BeanDefinitionBuilder.genericBeanDefinition(clz.getName()); BeanDefinitionHolder postProcessorHolder = new BeanDefinitionHolder( postProcessorBuilder.getBeanDefinition(), ActivitiContextUtils.ANNOTATION_STATE_HANDLER_BEAN_FACTORY_POST_PROCESSOR_BEAN_NAME); configureProcessEngine(postProcessorBuilder.getBeanDefinition(), element); BeanDefinitionReaderUtils.registerBeanDefinition(postProcessorHolder, context.getRegistry()); }
Example #24
Source File: StateHandlerAnnotationBeanFactoryPostProcessor.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
private void configureDefaultActivitiRegistry(String registryBeanName, BeanDefinitionRegistry registry) { if (!beanAlreadyConfigured(registry, registryBeanName, ActivitiStateHandlerRegistry.class)) { String registryName =ActivitiStateHandlerRegistry.class.getName(); log.info( "registering a " + registryName + " instance under bean name "+ ActivitiContextUtils.ACTIVITI_REGISTRY_BEAN_NAME+ "."); RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(); rootBeanDefinition.setBeanClassName( registryName ); rootBeanDefinition.getPropertyValues().addPropertyValue("processEngine", this.processEngine); BeanDefinitionHolder holder = new BeanDefinitionHolder(rootBeanDefinition, registryBeanName); BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); } }
Example #25
Source File: RedissonNamespaceParserSupport.java From redisson with Apache License 2.0 | 5 votes |
public BeanComponentDefinition registerBeanDefinition(BeanDefinitionBuilder builder, Element element, ParserContext parserContext) { BeanDefinitionHolder holder = new BeanDefinitionHolder(builder.getBeanDefinition(), getId(element, builder, parserContext), parseAliase(element)); BeanDefinitionReaderUtils .registerBeanDefinition(holder, parserContext.getRegistry()); BeanComponentDefinition componentDefinition = new BeanComponentDefinition(holder); parserContext.registerComponent(componentDefinition); return componentDefinition; }
Example #26
Source File: BeanDefinitionParserDelegate.java From spring4-understanding with Apache License 2.0 | 5 votes |
private BeanDefinitionHolder parseNestedCustomElement(Element ele, BeanDefinition containingBd) { BeanDefinition innerDefinition = parseCustomElement(ele, containingBd); if (innerDefinition == null) { error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " + "This tag cannot be used nested inside <property>.", ele); return null; } String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdentityHexString(innerDefinition); if (logger.isDebugEnabled()) { logger.debug("Using generated bean name [" + id + "] for nested custom element '" + ele.getNodeName() + "'"); } return new BeanDefinitionHolder(innerDefinition, id); }
Example #27
Source File: DubboComponentScanRegistrar.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
/** * Registers {@link ServiceAnnotationBeanPostProcessor} * * @param packagesToScan packages to scan without resolving placeholders * @param registry {@link BeanDefinitionRegistry} * @since 2.5.8 */ private void registerServiceAnnotationBeanPostProcessor(Set<String> packagesToScan, BeanDefinitionRegistry registry) { BeanDefinitionBuilder builder = rootBeanDefinition(ServiceAnnotationBeanPostProcessor.class); builder.addConstructorArgValue(packagesToScan); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); AbstractBeanDefinition beanDefinition = builder.getBeanDefinition(); BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, registry); }
Example #28
Source File: JobDrivenBeanDefinitionParser.java From niubi-job with Apache License 2.0 | 5 votes |
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { AbstractBeanDefinition beanDefinition = new GenericBeanDefinition(); MutablePropertyValues propertyValues = new MutablePropertyValues(); beanDefinition.setBeanClass(SpringContextJobDriver.class); propertyValues.addPropertyValue("packagesToScan", element.getAttribute("packagesToScan")); beanDefinition.setPropertyValues(propertyValues); beanDefinition.setInitMethodName("init"); BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, parserContext.getRegistry()); return beanDefinition; }
Example #29
Source File: BeanDefinitionParserDelegate.java From lams with GNU General Public License v2.0 | 5 votes |
private BeanDefinitionHolder parseNestedCustomElement(Element ele, BeanDefinition containingBd) { BeanDefinition innerDefinition = parseCustomElement(ele, containingBd); if (innerDefinition == null) { error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " + "This tag cannot be used nested inside <property>.", ele); return null; } String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdentityHexString(innerDefinition); if (logger.isDebugEnabled()) { logger.debug("Using generated bean name [" + id + "] for nested custom element '" + ele.getNodeName() + "'"); } return new BeanDefinitionHolder(innerDefinition, id); }
Example #30
Source File: BeanDefinitionParserDelegate.java From blog_demos with Apache License 2.0 | 5 votes |
private BeanDefinitionHolder parseNestedCustomElement(Element ele, BeanDefinition containingBd) { BeanDefinition innerDefinition = parseCustomElement(ele, containingBd); if (innerDefinition == null) { error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " + "This tag cannot be used nested inside <property>.", ele); return null; } String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdentityHexString(innerDefinition); if (logger.isDebugEnabled()) { logger.debug("Using generated bean name [" + id + "] for nested custom element '" + ele.getNodeName() + "'"); } return new BeanDefinitionHolder(innerDefinition, id); }