Java Code Examples for org.springframework.beans.factory.support.BeanDefinitionBuilder#addPropertyReference()
The following examples show how to use
org.springframework.beans.factory.support.BeanDefinitionBuilder#addPropertyReference() .
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: ScriptFactoryPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testPrototypeScriptedBean() throws Exception { GenericApplicationContext ctx = new GenericApplicationContext(); ctx.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition()); BeanDefinitionBuilder scriptedBeanBuilder = BeanDefinitionBuilder.rootBeanDefinition(GroovyScriptFactory.class); scriptedBeanBuilder.setScope(BeanDefinition.SCOPE_PROTOTYPE); scriptedBeanBuilder.addConstructorArgValue(DELEGATING_SCRIPT); scriptedBeanBuilder.addPropertyReference("messenger", "messenger"); final String BEAN_WITH_DEPENDENCY_NAME = "needsMessenger"; ctx.registerBeanDefinition(BEAN_WITH_DEPENDENCY_NAME, scriptedBeanBuilder.getBeanDefinition()); ctx.registerBeanDefinition("scriptProcessor", createScriptFactoryPostProcessor(true)); ctx.refresh(); Messenger messenger1 = (Messenger) ctx.getBean(BEAN_WITH_DEPENDENCY_NAME); Messenger messenger2 = (Messenger) ctx.getBean(BEAN_WITH_DEPENDENCY_NAME); assertNotSame(messenger1, messenger2); }
Example 2
Source File: DynamoDBRepositoryConfigExtension.java From spring-data-dynamodb with Apache License 2.0 | 6 votes |
private void postProcess(BeanDefinitionBuilder builder, String amazonDynamoDBRef, String dynamoDBMapperConfigRef,String dynamoDBOperationsRef) { if (StringUtils.hasText(dynamoDBOperationsRef)) { builder.addPropertyReference("dynamoDBOperations", dynamoDBOperationsRef); Assert.isTrue(!StringUtils.hasText(amazonDynamoDBRef),"Cannot specify both amazonDynamoDB bean and dynamoDBOperationsBean in repository configuration"); Assert.isTrue(!StringUtils.hasText(dynamoDBMapperConfigRef),"Cannot specify both dynamoDBMapperConfigBean bean and dynamoDBOperationsBean in repository configuration"); } else { amazonDynamoDBRef = StringUtils.hasText(amazonDynamoDBRef) ? amazonDynamoDBRef : DEFAULT_AMAZON_DYNAMO_DB_BEAN_NAME; builder.addPropertyReference("amazonDynamoDB", amazonDynamoDBRef); if (StringUtils.hasText(dynamoDBMapperConfigRef)) { builder.addPropertyReference("dynamoDBMapperConfig", dynamoDBMapperConfigRef); } } }
Example 3
Source File: KualiBeanDefinitionParserBase.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
protected void parseEmbeddedPropertyElements(Element element, BeanDefinitionBuilder bean) { NodeList children = element.getChildNodes(); for ( int i = 0; i < children.getLength(); i++ ) { Node child = children.item(i); if ( child.getLocalName() != null && child.getLocalName().equals("property") ) { Element propertyElement = (Element)child; String propName = propertyElement.getAttribute("name"); String propValue = propertyElement.getAttribute("value"); if ( propValue != null ) { bean.addPropertyValue(propName, propValue); } else if ( propertyElement.getAttribute("ref") != null ) { bean.addPropertyReference(propName, propertyElement.getAttribute("ref") ); } } } }
Example 4
Source File: CacheAdviceParser.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { builder.addPropertyReference("cacheManager", CacheNamespaceHandler.extractCacheManager(element)); CacheNamespaceHandler.parseKeyGenerator(element, builder.getBeanDefinition()); List<Element> cacheDefs = DomUtils.getChildElementsByTagName(element, DEFS_ELEMENT); if (cacheDefs.size() >= 1) { // Using attributes source. List<RootBeanDefinition> attributeSourceDefinitions = parseDefinitionsSources(cacheDefs, parserContext); builder.addPropertyValue("cacheOperationSources", attributeSourceDefinitions); } else { // Assume annotations source. builder.addPropertyValue("cacheOperationSources", new RootBeanDefinition("org.springframework.cache.annotation.AnnotationCacheOperationSource")); } }
Example 5
Source File: AuditingBeanDefinitionParser.java From spring-data-mybatis with Apache License 2.0 | 6 votes |
@Override public BeanDefinition parse(Element element, ParserContext parser) { auditingHandlerParser.parse(element, parser); Object source = parser.getReaderContext().extractSource(element); BeanDefinitionBuilder builder = rootBeanDefinition( AUDITING_ENTITY_LISTENER_CLASS_NAME); builder.addPropertyValue("auditingHandler", ParsingUtils.getObjectFactoryBeanDefinition( auditingHandlerParser.getResolvedBeanName(), source)); builder.addPropertyReference("sqlSessionTemplate", DEFAULT_SQL_SESSION_TEMPLATE_BEAN_NAME); // builder.setScope("prototype"); registerInfrastructureBeanWithId(builder.getRawBeanDefinition(), AUDITING_ENTITY_LISTENER_CLASS_NAME, parser, element); return null; }
Example 6
Source File: ZmqOutboundGatewayParser.java From spring-integration-zmq with Apache License 2.0 | 5 votes |
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition( "com.github.moonkev.spring.integration.zmq.ZmqOutboundGateway"); builder.addPropertyValue("address", element.getAttribute("address")); builder.addPropertyValue("socketType", element.getAttribute("socket-type")); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "bind"); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout", "socketSendTimeout"); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "receive-timeout", "socketReceiveTimeout"); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "linger"); IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel"); IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "context-manager"); if ("".equals(element.getAttribute("request-converter"))) { builder.addPropertyValue("requestConverter", new MapToJsonByteArrayConverter()); } else { builder.addPropertyReference("request-converter", element.getAttribute("requestConverter")); } if ("".equals(element.getAttribute("reply-converter"))) { builder.addPropertyValue("replyConverter", new JsonByteArrayToMapConverter()); } else { builder.addPropertyReference("reply-converter", element.getAttribute("replyConverter")); } return builder; }
Example 7
Source File: ContextSourceParser.java From spring-ldap with Apache License 2.0 | 5 votes |
private void populatePoolValidationProperties(BeanDefinitionBuilder builder, Element element, boolean testOnBorrow, boolean testOnReturn, boolean testWhileIdle) { builder.addPropertyValue("testOnBorrow", testOnBorrow); builder.addPropertyValue("testOnReturn", testOnReturn); builder.addPropertyValue("testWhileIdle", testWhileIdle); BeanDefinitionBuilder validatorBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultDirContextValidator.class); validatorBuilder.addPropertyValue("base", getString(element, ATT_VALIDATION_QUERY_BASE, "")); validatorBuilder.addPropertyValue("filter", getString(element, ATT_VALIDATION_QUERY_FILTER, DefaultDirContextValidator.DEFAULT_FILTER)); String searchControlsRef = element.getAttribute(ATT_VALIDATION_QUERY_SEARCH_CONTROLS_REF); if(StringUtils.hasText(searchControlsRef)) { validatorBuilder.addPropertyReference("searchControls", searchControlsRef); } builder.addPropertyValue("dirContextValidator", validatorBuilder.getBeanDefinition()); builder.addPropertyValue("timeBetweenEvictionRunsMillis", getString(element, ATT_EVICTION_RUN_MILLIS, String.valueOf(DEFAULT_EVICTION_RUN_MILLIS))); builder.addPropertyValue("numTestsPerEvictionRun", getInt(element, ATT_TESTS_PER_EVICTION_RUN, DEFAULT_TESTS_PER_EVICTION_RUN)); builder.addPropertyValue("minEvictableIdleTimeMillis", getString(element, ATT_EVICTABLE_TIME_MILLIS, String.valueOf(DEFAULT_EVICTABLE_MILLIS))); String nonTransientExceptions = getString(element, ATT_NON_TRANSIENT_EXCEPTIONS, CommunicationException.class.getName()); String[] strings = StringUtils.commaDelimitedListToStringArray(nonTransientExceptions); Set<Class<?>> nonTransientExceptionClasses = new HashSet<Class<?>>(); for (String className : strings) { try { nonTransientExceptionClasses.add(ClassUtils.getDefaultClassLoader().loadClass(className)); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(String.format("%s is not a valid class name", className), e); } } builder.addPropertyValue("nonTransientExceptions", nonTransientExceptionClasses); }
Example 8
Source File: EncryptablePropertiesBeanDefinitionParser.java From jasypt with Apache License 2.0 | 5 votes |
@Override protected void doParse(final Element element, final ParserContext parserContext, final BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder); Properties parsedProps = parserContext.getDelegate().parsePropsElement(element); builder.addPropertyValue("properties", parsedProps); String scope = element.getAttribute(SCOPE_ATTRIBUTE); if (StringUtils.hasLength(scope)) { builder.setScope(scope); } final String encryptorBeanName = element.getAttribute(ENCRYPTOR_ATTRIBUTE); if (StringUtils.hasText(encryptorBeanName)) { builder.addPropertyReference("encryptor", encryptorBeanName); } }
Example 9
Source File: BeanDefinitionParser.java From hasor with Apache License 2.0 | 5 votes |
@Override protected AbstractBeanDefinition parse(Element element, NamedNodeMap attributes, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); builder.getRawBeanDefinition().setBeanClass(TargetFactoryBean.class); // String factoryID = revertProperty(attributes, "hasorID"); String refID = revertProperty(attributes, "refID"); String refType = revertProperty(attributes, "refType"); String refName = revertProperty(attributes, "refName"); String lazy = revertProperty(attributes, "lazy"); builder.setLazyInit((Boolean) ConverterUtils.convert(lazy, Boolean.TYPE)); // if (StringUtils.isBlank(factoryID)) { factoryID = AppContext.class.getName(); } if (StringUtils.isNotBlank(refID) || StringUtils.isNotBlank(refType)) { builder.addPropertyReference("factory", factoryID); builder.addPropertyValue("refID", refID); // builder.addPropertyValue("refName", refName); if (StringUtils.isNotBlank(refType)) { try { ClassLoader classLoader = parserContext.getReaderContext().getBeanClassLoader(); Class<?> refTypeClass = ClassUtils.forName(refType, classLoader); builder.addPropertyValue("refType", refTypeClass); } catch (ClassNotFoundException ex) { parserContext.getReaderContext().error("Bean class [" + refType + "] not found", element, ex); } } } else { parserContext.getReaderContext().error("Bean class [" + refType + "] refID and refType ,both undefined.", element); } return builder.getBeanDefinition(); }
Example 10
Source File: XmlBeansMarshallerBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) { String optionsName = element.getAttribute("options"); if (StringUtils.hasText(optionsName)) { beanDefinitionBuilder.addPropertyReference("xmlOptions", optionsName); } }
Example 11
Source File: SqsOutboundChannelAdapterParser.java From spring-integration-aws with MIT License | 5 votes |
@Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { final BeanDefinitionBuilder sqsOutboundChannelAdapterBuilder = BeanDefinitionBuilder .genericBeanDefinition(SqsOutboundGateway.class); final BeanDefinitionBuilder sqsExecutorBuilder = SqsParserUtils .getSqsExecutorBuilder(element, parserContext); final BeanDefinition sqsExecutorBuilderBeanDefinition = sqsExecutorBuilder .getBeanDefinition(); final String channelAdapterId = this.resolveId(element, sqsOutboundChannelAdapterBuilder.getRawBeanDefinition(), parserContext); final String sqsExecutorBeanName = SqsParserUtils .getExecutorBeanName(channelAdapterId); parserContext.registerBeanComponent(new BeanComponentDefinition( sqsExecutorBuilderBeanDefinition, sqsExecutorBeanName)); sqsOutboundChannelAdapterBuilder.addPropertyReference("sqsExecutor", sqsExecutorBeanName); SqsParserUtils.registerExecutorProxy(element, sqsExecutorBeanName, parserContext); sqsOutboundChannelAdapterBuilder.addPropertyValue("producesReply", Boolean.FALSE); AwsParserUtils.registerPermissions(element, sqsExecutorBuilder, parserContext); return sqsOutboundChannelAdapterBuilder.getBeanDefinition(); }
Example 12
Source File: RMManagerBeanDefinitionParser.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) { mapElementToJaxbProperty(element, bean, new QName(RM_NS, "deliveryAssurance"), "deliveryAssurance"); mapElementToJaxbProperty(element, bean, new QName(RM_NS, "sourcePolicy"), "sourcePolicy"); mapElementToJaxbProperty(element, bean, new QName(RM_NS, "destinationPolicy"), "destinationPolicy"); mapElementToJaxbProperty(element, bean, new QName(RM_NS, "RM10AddressingNamespace"), "RM10AddressingNamespace"); mapElementToJaxbProperty(element, bean, new QName("http://schemas.xmlsoap.org/ws/2005/02/rm/policy", "RMAssertion"), "RMAssertion", org.apache.cxf.ws.rmp.v200502.RMAssertion.class); // TODO: handle // mapElementToJaxbProperty(element, bean, // new QName("http://docs.oasis-open.org/ws-rx/wsrmp/200702", "RMAssertion"), // "RMAssertion", // org.apache.cxf.ws.rmp.v200702.RMAssertion.class); ctx.getDelegate().parsePropertyElements(element, bean.getBeanDefinition()); String bus = element.getAttribute("bus"); if (bus == null || "".equals(bus)) { addBusWiringAttribute(bean, BusWiringType.PROPERTY); } else { bean.addPropertyReference("bus", bus); } super.parseChildElements(element, ctx, bean); }
Example 13
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 14
Source File: InitializeDatabaseBeanDefinitionParser.java From effectivejava with Apache License 2.0 | 5 votes |
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(DataSourceInitializer.class); builder.addPropertyReference("dataSource", element.getAttribute("data-source")); builder.addPropertyValue("enabled", element.getAttribute("enabled")); DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); return builder.getBeanDefinition(); }
Example 15
Source File: FirestoreRepositoryConfigurationExtension.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Override public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config) { AnnotationAttributes attributes = config.getAttributes(); builder.addPropertyReference("firestoreTemplate", attributes.getString("firestoreTemplateRef")); builder.addPropertyReference("firestoreMappingContext", attributes.getString("firestoreMappingContextRef")); }
Example 16
Source File: AnnotationDrivenJmsBeanDefinitionParser.java From java-technology-stack with MIT License | 4 votes |
@Override @Nullable public BeanDefinition parse(Element element, ParserContext parserContext) { Object source = parserContext.extractSource(element); // Register component for the surrounding <jms:annotation-driven> element. CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source); parserContext.pushContainingComponent(compDefinition); // Nest the concrete post-processor bean in the surrounding component. BeanDefinitionRegistry registry = parserContext.getRegistry(); if (registry.containsBeanDefinition(JmsListenerConfigUtils.JMS_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME)) { parserContext.getReaderContext().error( "Only one JmsListenerAnnotationBeanPostProcessor may exist within the context.", source); } else { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition( "org.springframework.jms.annotation.JmsListenerAnnotationBeanPostProcessor"); builder.getRawBeanDefinition().setSource(source); String endpointRegistry = element.getAttribute("registry"); if (StringUtils.hasText(endpointRegistry)) { builder.addPropertyReference("endpointRegistry", endpointRegistry); } else { registerDefaultEndpointRegistry(source, parserContext); } String containerFactory = element.getAttribute("container-factory"); if (StringUtils.hasText(containerFactory)) { builder.addPropertyValue("containerFactoryBeanName", containerFactory); } String handlerMethodFactory = element.getAttribute("handler-method-factory"); if (StringUtils.hasText(handlerMethodFactory)) { builder.addPropertyReference("messageHandlerMethodFactory", handlerMethodFactory); } registerInfrastructureBean(parserContext, builder, JmsListenerConfigUtils.JMS_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME); } // Finally register the composite component. parserContext.popAndRegisterContainingComponent(); return null; }
Example 17
Source File: AnnotationDrivenJmsBeanDefinitionParser.java From spring-analysis-note with MIT License | 4 votes |
@Override @Nullable public BeanDefinition parse(Element element, ParserContext parserContext) { Object source = parserContext.extractSource(element); // Register component for the surrounding <jms:annotation-driven> element. CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source); parserContext.pushContainingComponent(compDefinition); // Nest the concrete post-processor bean in the surrounding component. BeanDefinitionRegistry registry = parserContext.getRegistry(); if (registry.containsBeanDefinition(JmsListenerConfigUtils.JMS_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME)) { parserContext.getReaderContext().error( "Only one JmsListenerAnnotationBeanPostProcessor may exist within the context.", source); } else { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition( "org.springframework.jms.annotation.JmsListenerAnnotationBeanPostProcessor"); builder.getRawBeanDefinition().setSource(source); String endpointRegistry = element.getAttribute("registry"); if (StringUtils.hasText(endpointRegistry)) { builder.addPropertyReference("endpointRegistry", endpointRegistry); } else { registerDefaultEndpointRegistry(source, parserContext); } String containerFactory = element.getAttribute("container-factory"); if (StringUtils.hasText(containerFactory)) { builder.addPropertyValue("containerFactoryBeanName", containerFactory); } String handlerMethodFactory = element.getAttribute("handler-method-factory"); if (StringUtils.hasText(handlerMethodFactory)) { builder.addPropertyReference("messageHandlerMethodFactory", handlerMethodFactory); } registerInfrastructureBean(parserContext, builder, JmsListenerConfigUtils.JMS_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME); } // Finally register the composite component. parserContext.popAndRegisterContainingComponent(); return null; }
Example 18
Source File: ScheduledTasksBeanDefinitionParser.java From spring-analysis-note with MIT License | 4 votes |
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { builder.setLazyInit(false); // lazy scheduled tasks are a contradiction in terms -> force to false ManagedList<RuntimeBeanReference> cronTaskList = new ManagedList<>(); ManagedList<RuntimeBeanReference> fixedDelayTaskList = new ManagedList<>(); ManagedList<RuntimeBeanReference> fixedRateTaskList = new ManagedList<>(); ManagedList<RuntimeBeanReference> triggerTaskList = new ManagedList<>(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (!isScheduledElement(child, parserContext)) { continue; } Element taskElement = (Element) child; String ref = taskElement.getAttribute("ref"); String method = taskElement.getAttribute("method"); // Check that 'ref' and 'method' are specified if (!StringUtils.hasText(ref) || !StringUtils.hasText(method)) { parserContext.getReaderContext().error("Both 'ref' and 'method' are required", taskElement); // Continue with the possible next task element continue; } String cronAttribute = taskElement.getAttribute("cron"); String fixedDelayAttribute = taskElement.getAttribute("fixed-delay"); String fixedRateAttribute = taskElement.getAttribute("fixed-rate"); String triggerAttribute = taskElement.getAttribute("trigger"); String initialDelayAttribute = taskElement.getAttribute("initial-delay"); boolean hasCronAttribute = StringUtils.hasText(cronAttribute); boolean hasFixedDelayAttribute = StringUtils.hasText(fixedDelayAttribute); boolean hasFixedRateAttribute = StringUtils.hasText(fixedRateAttribute); boolean hasTriggerAttribute = StringUtils.hasText(triggerAttribute); boolean hasInitialDelayAttribute = StringUtils.hasText(initialDelayAttribute); if (!(hasCronAttribute || hasFixedDelayAttribute || hasFixedRateAttribute || hasTriggerAttribute)) { parserContext.getReaderContext().error( "one of the 'cron', 'fixed-delay', 'fixed-rate', or 'trigger' attributes is required", taskElement); continue; // with the possible next task element } if (hasInitialDelayAttribute && (hasCronAttribute || hasTriggerAttribute)) { parserContext.getReaderContext().error( "the 'initial-delay' attribute may not be used with cron and trigger tasks", taskElement); continue; // with the possible next task element } String runnableName = runnableReference(ref, method, taskElement, parserContext).getBeanName(); if (hasFixedDelayAttribute) { fixedDelayTaskList.add(intervalTaskReference(runnableName, initialDelayAttribute, fixedDelayAttribute, taskElement, parserContext)); } if (hasFixedRateAttribute) { fixedRateTaskList.add(intervalTaskReference(runnableName, initialDelayAttribute, fixedRateAttribute, taskElement, parserContext)); } if (hasCronAttribute) { cronTaskList.add(cronTaskReference(runnableName, cronAttribute, taskElement, parserContext)); } if (hasTriggerAttribute) { String triggerName = new RuntimeBeanReference(triggerAttribute).getBeanName(); triggerTaskList.add(triggerTaskReference(runnableName, triggerName, taskElement, parserContext)); } } String schedulerRef = element.getAttribute("scheduler"); if (StringUtils.hasText(schedulerRef)) { builder.addPropertyReference("taskScheduler", schedulerRef); } builder.addPropertyValue("cronTasksList", cronTaskList); builder.addPropertyValue("fixedDelayTasksList", fixedDelayTaskList); builder.addPropertyValue("fixedRateTasksList", fixedRateTaskList); builder.addPropertyValue("triggerTasksList", triggerTaskList); }
Example 19
Source File: SnsInboundChannelAdapterParser.java From spring-integration-aws with MIT License | 4 votes |
@Override protected AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName) { final BeanDefinitionBuilder snsInboundChannelAdapterBuilder = BeanDefinitionBuilder .genericBeanDefinition(SnsInboundChannelAdapter.class); snsInboundChannelAdapterBuilder.addPropertyReference("outputChannel", channelName); IntegrationNamespaceUtils.setValueIfAttributeDefined( snsInboundChannelAdapterBuilder, element, "send-timeout"); IntegrationNamespaceUtils.setValueIfAttributeDefined( snsInboundChannelAdapterBuilder, element, "auto-startup"); final BeanDefinitionBuilder snsExecutorBuilder = SnsParserUtils .getSnsExecutorBuilder(element, parserContext); final BeanDefinition snsExecutorBuilderBeanDefinition = snsExecutorBuilder .getBeanDefinition(); final String channelAdapterId = this.resolveId(element, snsInboundChannelAdapterBuilder.getRawBeanDefinition(), parserContext); final String snsExecutorBeanName = channelAdapterId + ".snsExecutor"; SnsParserUtils.registerSubscriptions(element, parserContext, snsExecutorBuilder, channelAdapterId); parserContext.registerBeanComponent(new BeanComponentDefinition( snsExecutorBuilderBeanDefinition, snsExecutorBeanName)); snsInboundChannelAdapterBuilder.addPropertyReference("snsExecutor", snsExecutorBeanName); SnsParserUtils.registerExecutorProxy(element, snsExecutorBeanName, parserContext); IntegrationNamespaceUtils.setValueIfAttributeDefined( snsInboundChannelAdapterBuilder, element, "phase"); IntegrationNamespaceUtils.setValueIfAttributeDefined( snsInboundChannelAdapterBuilder, element, "auto-startup"); AwsParserUtils.registerPermissions(element, snsExecutorBuilder, parserContext); return snsInboundChannelAdapterBuilder.getBeanDefinition(); }
Example 20
Source File: FeignClientToDubboProviderBeanPostProcessor.java From spring-cloud-dubbo with Apache License 2.0 | 4 votes |
private void addPropertyReference(BeanDefinitionBuilder builder, String propertyName, String beanName) { String resolvedBeanName = environment.resolvePlaceholders(beanName); builder.addPropertyReference(propertyName, resolvedBeanName); }