Java Code Examples for org.springframework.beans.factory.support.BeanDefinitionBuilder#setRole()
The following examples show how to use
org.springframework.beans.factory.support.BeanDefinitionBuilder#setRole() .
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: LoadTimeWeaverBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 6 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); if (isAspectJWeavingEnabled(element.getAttribute(ASPECTJ_WEAVING_ATTRIBUTE), parserContext)) { if (!parserContext.getRegistry().containsBeanDefinition(ASPECTJ_WEAVING_ENABLER_BEAN_NAME)) { RootBeanDefinition def = new RootBeanDefinition(ASPECTJ_WEAVING_ENABLER_CLASS_NAME); parserContext.registerBeanComponent( new BeanComponentDefinition(def, ASPECTJ_WEAVING_ENABLER_BEAN_NAME)); } if (isBeanConfigurerAspectEnabled(parserContext.getReaderContext().getBeanClassLoader())) { new SpringConfiguredBeanDefinitionParser().parse(element, parserContext); } } }
Example 2
Source File: ZookeeperConfigurerParser.java From spring-zookeeper with Apache License 2.0 | 6 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String order = element.getAttribute("order"); if (!StringUtils.hasText(order)) { order = Integer.MAX_VALUE + ""; } String localLocations = element.getAttribute("localLocations"); if (StringUtils.hasLength(localLocations)) { String[] locations = StringUtils.commaDelimitedListToStringArray(localLocations); builder.addPropertyValue("locations", locations); } builder.addPropertyValue( "location", parserContext.getDelegate().parseCustomElement( DomUtils.getChildElementByTagName(element, "zkResource"), builder.getRawBeanDefinition())); builder.addPropertyValue("order", Integer.valueOf(order)); builder.addPropertyValue("ignoreUnresolvablePlaceholders", true); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); }
Example 3
Source File: CuratorFrameworkBeanDefinitionParser.java From zookeeper-spring with Apache License 2.0 | 6 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { final BeanDefinitionBuilder beanDefBuilder = BeanDefinitionBuilder.rootBeanDefinition(CuratorFrameworkFactoryBean.class); beanDefBuilder.setRole(ROLE_APPLICATION); beanDefBuilder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); beanDefBuilder.addPropertyValue("connectString", element.getAttribute("connect-string")); Element retryPolicyElement = DomUtils.getChildElementByTagName(element, "retry-policy"); if (retryPolicyElement != null) { Element retryPolicyBeanElement = DomUtils.getChildElements(retryPolicyElement).get(0); BeanDefinitionHolder retryPolicy = parserContext.getDelegate().parseBeanDefinitionElement(retryPolicyBeanElement, beanDefBuilder.getBeanDefinition()); beanDefBuilder.addPropertyValue("retryPolicy", retryPolicy); } Node namespace = element.getAttributeNode("namespace"); if (namespace != null) { beanDefBuilder.addPropertyValue("namespace", namespace.getNodeValue()); } return beanDefBuilder.getBeanDefinition(); }
Example 4
Source File: AmazonWebserviceClientConfigurationUtils.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
private static void registerCredentialsProviderIfNeeded( BeanDefinitionRegistry registry) { if (!registry.containsBeanDefinition(CREDENTIALS_PROVIDER_BEAN_NAME)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder .genericBeanDefinition(CredentialsProviderFactoryBean.class); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); registry.registerBeanDefinition(CREDENTIALS_PROVIDER_BEAN_NAME, builder.getBeanDefinition()); } }
Example 5
Source File: MBeanExportBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AnnotationMBeanExporter.class); // Mark as infrastructure bean and attach source location. builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); String defaultDomain = element.getAttribute(DEFAULT_DOMAIN_ATTRIBUTE); if (StringUtils.hasText(defaultDomain)) { builder.addPropertyValue("defaultDomain", defaultDomain); } String serverBeanName = element.getAttribute(SERVER_ATTRIBUTE); if (StringUtils.hasText(serverBeanName)) { builder.addPropertyReference("server", serverBeanName); } else { AbstractBeanDefinition specialServer = MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment(); if (specialServer != null) { builder.addPropertyValue("server", specialServer); } } String registration = element.getAttribute(REGISTRATION_ATTRIBUTE); RegistrationPolicy registrationPolicy = RegistrationPolicy.FAIL_ON_EXISTING; if (REGISTRATION_IGNORE_EXISTING.equals(registration)) { registrationPolicy = RegistrationPolicy.IGNORE_EXISTING; } else if (REGISTRATION_REPLACE_EXISTING.equals(registration)) { registrationPolicy = RegistrationPolicy.REPLACE_EXISTING; } builder.addPropertyValue("registrationPolicy", registrationPolicy); return builder.getBeanDefinition(); }
Example 6
Source File: AbstractPropertyLoadingBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String location = element.getAttribute("location"); if (StringUtils.hasLength(location)) { location = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(location); String[] locations = StringUtils.commaDelimitedListToStringArray(location); builder.addPropertyValue("locations", locations); } String propertiesRef = element.getAttribute("properties-ref"); if (StringUtils.hasLength(propertiesRef)) { builder.addPropertyReference("properties", propertiesRef); } String fileEncoding = element.getAttribute("file-encoding"); if (StringUtils.hasLength(fileEncoding)) { builder.addPropertyValue("fileEncoding", fileEncoding); } String order = element.getAttribute("order"); if (StringUtils.hasLength(order)) { builder.addPropertyValue("order", Integer.valueOf(order)); } builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found"))); builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override"))); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); }
Example 7
Source File: AnnotationDrivenBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 5 votes |
private static void registerPostProcessor( ParserContext parserContext, BeanDefinitionBuilder builder, String beanName) { builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(beanName, builder.getBeanDefinition()); BeanDefinitionHolder holder = new BeanDefinitionHolder(builder.getBeanDefinition(), beanName); parserContext.registerComponent(new BeanComponentDefinition(holder)); }
Example 8
Source File: AnnotationDrivenJmsBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 5 votes |
private static void registerInfrastructureBean( ParserContext parserContext, BeanDefinitionBuilder builder, String beanName) { builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(beanName, builder.getBeanDefinition()); BeanDefinitionHolder holder = new BeanDefinitionHolder(builder.getBeanDefinition(), beanName); parserContext.registerComponent(new BeanComponentDefinition(holder)); }
Example 9
Source File: AnnotationDrivenBeanDefinitionParser.java From zookeeper-spring with Apache License 2.0 | 5 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { final BeanDefinitionBuilder beanDefBuilder = BeanDefinitionBuilder.rootBeanDefinition(ZooKeeperAnnotationBeanPostProcessor.class); beanDefBuilder.setRole(ROLE_INFRASTRUCTURE); beanDefBuilder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); beanDefBuilder.addPropertyReference("curatorFramework", element.getAttribute("curator-framework")); return beanDefBuilder.getBeanDefinition(); }
Example 10
Source File: AbstractPropertyLoadingBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected void doParse(Element element, BeanDefinitionBuilder builder) { String location = element.getAttribute("location"); if (StringUtils.hasLength(location)) { String[] locations = StringUtils.commaDelimitedListToStringArray(location); builder.addPropertyValue("locations", locations); } String propertiesRef = element.getAttribute("properties-ref"); if (StringUtils.hasLength(propertiesRef)) { builder.addPropertyReference("properties", propertiesRef); } String fileEncoding = element.getAttribute("file-encoding"); if (StringUtils.hasLength(fileEncoding)) { builder.addPropertyValue("fileEncoding", fileEncoding); } String order = element.getAttribute("order"); if (StringUtils.hasLength(order)) { builder.addPropertyValue("order", Integer.valueOf(order)); } builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found"))); builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override"))); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); }
Example 11
Source File: AbstractPropertyLoadingBeanDefinitionParser.java From java-technology-stack with MIT License | 5 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String location = element.getAttribute("location"); if (StringUtils.hasLength(location)) { location = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(location); String[] locations = StringUtils.commaDelimitedListToStringArray(location); builder.addPropertyValue("locations", locations); } String propertiesRef = element.getAttribute("properties-ref"); if (StringUtils.hasLength(propertiesRef)) { builder.addPropertyReference("properties", propertiesRef); } String fileEncoding = element.getAttribute("file-encoding"); if (StringUtils.hasLength(fileEncoding)) { builder.addPropertyValue("fileEncoding", fileEncoding); } String order = element.getAttribute("order"); if (StringUtils.hasLength(order)) { builder.addPropertyValue("order", Integer.valueOf(order)); } builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found"))); builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override"))); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); }
Example 12
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 13
Source File: AbstractEncryptablePropertyLoadingBeanDefinitionParser.java From jasypt with Apache License 2.0 | 5 votes |
@Override protected void doParse(final Element element, final BeanDefinitionBuilder builder) { String location = element.getAttribute("location"); if (StringUtils.hasLength(location)) { String[] locations = StringUtils.commaDelimitedListToStringArray(location); builder.addPropertyValue("locations", locations); } String propertiesRef = element.getAttribute("properties-ref"); if (StringUtils.hasLength(propertiesRef)) { builder.addPropertyReference("properties", propertiesRef); } String fileEncoding = element.getAttribute("file-encoding"); if (StringUtils.hasLength(fileEncoding)) { builder.addPropertyReference("fileEncoding", fileEncoding); } String order = element.getAttribute("order"); if (StringUtils.hasLength(order)) { builder.addPropertyValue("order", Integer.valueOf(order)); } builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found"))); builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override"))); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); }
Example 14
Source File: AmazonWebserviceClientConfigurationUtils.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
private static void registerRegionProviderBeanIfNeeded( BeanDefinitionRegistry registry) { if (!registry.containsBeanDefinition(REGION_PROVIDER_BEAN_NAME)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder .genericBeanDefinition(StaticRegionProvider.class); builder.addConstructorArgValue(Regions.DEFAULT_REGION.getName()); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); registry.registerBeanDefinition(REGION_PROVIDER_BEAN_NAME, builder.getBeanDefinition()); } }
Example 15
Source File: AnnotationDrivenJmsBeanDefinitionParser.java From spring-analysis-note with MIT License | 5 votes |
private static void registerInfrastructureBean( ParserContext parserContext, BeanDefinitionBuilder builder, String beanName) { builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(beanName, builder.getBeanDefinition()); BeanDefinitionHolder holder = new BeanDefinitionHolder(builder.getBeanDefinition(), beanName); parserContext.registerComponent(new BeanComponentDefinition(holder)); }
Example 16
Source File: MBeanExportBeanDefinitionParser.java From spring-analysis-note with MIT License | 5 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AnnotationMBeanExporter.class); // Mark as infrastructure bean and attach source location. builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); String defaultDomain = element.getAttribute(DEFAULT_DOMAIN_ATTRIBUTE); if (StringUtils.hasText(defaultDomain)) { builder.addPropertyValue("defaultDomain", defaultDomain); } String serverBeanName = element.getAttribute(SERVER_ATTRIBUTE); if (StringUtils.hasText(serverBeanName)) { builder.addPropertyReference("server", serverBeanName); } else { AbstractBeanDefinition specialServer = MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment(); if (specialServer != null) { builder.addPropertyValue("server", specialServer); } } String registration = element.getAttribute(REGISTRATION_ATTRIBUTE); RegistrationPolicy registrationPolicy = RegistrationPolicy.FAIL_ON_EXISTING; if (REGISTRATION_IGNORE_EXISTING.equals(registration)) { registrationPolicy = RegistrationPolicy.IGNORE_EXISTING; } else if (REGISTRATION_REPLACE_EXISTING.equals(registration)) { registrationPolicy = RegistrationPolicy.REPLACE_EXISTING; } builder.addPropertyValue("registrationPolicy", registrationPolicy); return builder.getBeanDefinition(); }
Example 17
Source File: MapRepositoryConfigurationExtension.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
@Override protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition( RepositoryConfigurationSource configurationSource) { BeanDefinitionBuilder adapterBuilder = BeanDefinitionBuilder.rootBeanDefinition(MapKeyValueAdapter.class); adapterBuilder.addConstructorArgValue(getMapTypeToUse(configurationSource)); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(KeyValueTemplate.class); builder .addConstructorArgValue(ParsingUtils.getSourceBeanDefinition(adapterBuilder, configurationSource.getSource())); builder.setRole(BeanDefinition.ROLE_SUPPORT); return ParsingUtils.getSourceBeanDefinition(builder, configurationSource.getSource()); }
Example 18
Source File: AbstractPropertyLoadingBeanDefinitionParser.java From spring-analysis-note with MIT License | 5 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String location = element.getAttribute("location"); if (StringUtils.hasLength(location)) { location = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(location); String[] locations = StringUtils.commaDelimitedListToStringArray(location); builder.addPropertyValue("locations", locations); } String propertiesRef = element.getAttribute("properties-ref"); if (StringUtils.hasLength(propertiesRef)) { builder.addPropertyReference("properties", propertiesRef); } String fileEncoding = element.getAttribute("file-encoding"); if (StringUtils.hasLength(fileEncoding)) { builder.addPropertyValue("fileEncoding", fileEncoding); } String order = element.getAttribute("order"); if (StringUtils.hasLength(order)) { builder.addPropertyValue("order", Integer.valueOf(order)); } builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found"))); builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override"))); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); }
Example 19
Source File: AnnotationDrivenBeanDefinitionParser.java From spring-analysis-note with MIT License | 5 votes |
private static void registerPostProcessor( ParserContext parserContext, BeanDefinitionBuilder builder, String beanName) { builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); parserContext.getRegistry().registerBeanDefinition(beanName, builder.getBeanDefinition()); BeanDefinitionHolder holder = new BeanDefinitionHolder(builder.getBeanDefinition(), beanName); parserContext.registerComponent(new BeanComponentDefinition(holder)); }
Example 20
Source File: AnnotationBeanDefinitionParser.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
/** * parse * <prev> * <dubbo:annotation package="" /> * </prev> * * @param element * @param parserContext * @param builder * parse <dubbo:annotation package="" /> */ @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String packageToScan = element.getAttribute("package"); // 多个包是用,分开 String[] packagesToScan = trimArrayElements(commaDelimitedListToStringArray(packageToScan)); builder.addConstructorArgValue(packagesToScan); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); // Registers ReferenceAnnotationBeanPostProcessor registerReferenceAnnotationBeanPostProcessor(parserContext.getRegistry()); }