protected override AbstractObjectDefinition DoParse(XmlElement element, ParserContext parserContext, string channelName) { XmlElement pollerElement = DomUtils.GetChildElementByTagName(element, "poller"); ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CONFIG_PACKAGE + ".ConsumerEndpointFactoryObject"); builder.AddConstructorArgReference(ParseAndRegisterConsumer(element, parserContext)); if (pollerElement != null) { if (!StringUtils.HasText(channelName)) { parserContext.ReaderContext.ReportException(element, element.Name, "outbound channel adapter with a 'poller' requires a 'channel' to poll"); } IntegrationNamespaceUtils.ConfigurePollerMetadata(pollerElement, builder, parserContext); } builder.AddPropertyValue("inputChannelName", channelName); return(builder.ObjectDefinition); }
protected override AbstractObjectDefinition DoParse(XmlElement element, ParserContext parserContext, string channelName) { string source = ParseSource(element, parserContext); if (!StringUtils.HasText(source)) { parserContext.ReaderContext.ReportException(element, element.Name, "failed to parse source"); } ObjectDefinitionBuilder adapterBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CONFIG_PACKAGE + ".SourcePollingChannelAdapterFactoryObject"); adapterBuilder.AddPropertyReference("source", source); adapterBuilder.AddPropertyReference("outputChannel", channelName); XmlElement pollerElement = DomUtils.GetChildElementByTagName(element, "poller"); if (pollerElement != null) { IntegrationNamespaceUtils.ConfigurePollerMetadata(pollerElement, adapterBuilder, parserContext); } IntegrationNamespaceUtils.SetValueIfAttributeDefined(adapterBuilder, element, "auto-startup"); return(adapterBuilder.ObjectDefinition); }
protected override AbstractObjectDefinition ParseInternal(XmlElement element, ParserContext parserContext) { ObjectDefinitionBuilder handlerBuilder = ParseHandler(element, parserContext); IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(handlerBuilder, element, "output-channel"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(handlerBuilder, element, "order"); AbstractObjectDefinition handlerBeanDefinition = handlerBuilder.ObjectDefinition; string inputChannelAttributeName = InputChannelAttributeName; if (!element.HasAttribute(inputChannelAttributeName)) { if (!parserContext.IsNested) { parserContext.ReaderContext.ReportException(element, element.Name, "The '" + inputChannelAttributeName + "' attribute is required for top-level endpoint elements."); } return(handlerBeanDefinition); } ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CONFIG_PACKAGE + ".ConsumerEndpointFactoryObject"); string handlerBeanName = parserContext.ReaderContext.RegisterWithGeneratedName(handlerBeanDefinition); builder.AddConstructorArgReference(handlerBeanName); string inputChannelName = element.GetAttribute(inputChannelAttributeName); if (!parserContext.Registry.ContainsObjectDefinition(inputChannelName)) { ObjectDefinitionBuilder channelDef = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CHANNEL_PACKAGE + ".DirectChannel"); ObjectDefinitionHolder holder = new ObjectDefinitionHolder(channelDef.ObjectDefinition, inputChannelName); ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, parserContext.Registry); } builder.AddPropertyValue("inputChannelName", inputChannelName); XmlElement pollerElement = DomUtils.GetChildElementByTagName(element, "poller"); if (pollerElement != null) { IntegrationNamespaceUtils.ConfigurePollerMetadata(pollerElement, builder, parserContext); } IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "auto-startup"); return(builder.ObjectDefinition); }