private void ParseSelectorChain(ObjectDefinitionBuilder builder, XmlElement element, ParserContext parserContext)
        {
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "voting-strategy");
            ManagedList selectors = new ManagedList();

            selectors.ElementTypeName = typeof(IMessageSelector).FullName;
            XmlNodeList childNodes = element.ChildNodes;

            for (int i = 0; i < childNodes.Count; i++)
            {
                XmlNode child = childNodes.Item(i);
                if (child.NodeType == XmlNodeType.Element)
                {
                    string nodeName = child.LocalName;
                    if ("selector".Equals(nodeName))
                    {
                        string refatr = ((XmlElement)child).GetAttribute("ref");
                        selectors.Add(new RuntimeObjectReference(refatr));
                    }
                    else if ("selector-chain".Equals(nodeName))
                    {
                        ObjectDefinitionBuilder nestedBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(GetObjectTypeName(null));
                        ParseSelectorChain(nestedBuilder, (XmlElement)child, parserContext);
                        string nestedBeanName = parserContext.ReaderContext.RegisterWithGeneratedName(nestedBuilder.ObjectDefinition);
                        selectors.Add(new RuntimeObjectReference(nestedBeanName));
                    }
                }
            }
            builder.AddPropertyValue("selectors", selectors);
        }
        protected override AbstractObjectDefinition ParseInternal(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder metadataBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.SCHEDULING_PACKAGE + ".PollerMetadata");

            if (element.HasAttribute("ref"))
            {
                parserContext.ReaderContext.ReportException(element, element.Name, "the 'ref' attribute must not be present on a 'poller' element submitted to the parser");
            }
            ConfigureTrigger(element, metadataBuilder, parserContext);
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(metadataBuilder, element, "max-messages-per-poll");
            XmlElement adviceChainElement = DomUtils.GetChildElementByTagName(element, "advice-chain");

            if (adviceChainElement != null)
            {
                ConfigureAdviceChain(adviceChainElement, metadataBuilder, parserContext);
            }
            XmlElement txElement = DomUtils.GetChildElementByTagName(element, "transactional");

            if (txElement != null)
            {
                ConfigureTransactionAttributes(txElement, metadataBuilder);
            }
            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(metadataBuilder, element, "task-executor");
            return(metadataBuilder.ObjectDefinition);
        }
Exemplo n.º 3
0
 protected static void PostProcess(ObjectDefinitionBuilder builder, XmlElement element)
 {
     foreach (string attributeName in _referenceAttributes)
     {
         IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, attributeName);
     }
 }
        /**
         * Parse an "interval-trigger" element
         */
        private static string ParseIntervalTrigger(XmlElement element, ParserContext parserContext)
        {
            string interval = element.GetAttribute("interval");

            if (!StringUtils.HasText(interval))
            {
                parserContext.ReaderContext.ReportException(element, element.Name, "the 'interval' attribute is required for an <interval-trigger/>");
            }
            //TimeUnit timeUnit = TimeUnit.valueOf(element.getAttribute("time-unit"));
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.SCHEDULING_PACKAGE + ".IntervalTrigger");

            //TODO MLP handle parsing of time-unit correctly, now hardcode use of 'seconds' via Spring.Core.TypeConversion.TimeSpanConverter
            string timeUnit = element.GetAttribute("time-unit");

            switch (timeUnit)
            {
            case "SECONDS":
                interval = interval + "s";
                break;

            case "MILLISECONDS":
                interval = interval + "ms";
                break;
            }
            builder.AddConstructorArg(interval);


            //builder.addConstructorArgValue(timeUnit);
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "initial-delay");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "fixed-rate");
            return(parserContext.ReaderContext.RegisterWithGeneratedName(builder.ObjectDefinition));
        }
Exemplo n.º 5
0
        protected override ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.FILTER_PACKAGE + ".MessageFilter");

            builder.AddConstructorArgReference(ParseSelector(element, parserContext));
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "throw-exception-on-rejection");
            return(builder);
        }
        protected override ObjectDefinitionBuilder BuildObjectDefinition(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CHANNEL_PACKAGE + ".PublishSubscribeChannel");
            string taskExecutorRef          = element.GetAttribute("task-executor");

            if (StringUtils.HasText(taskExecutorRef))
            {
                builder.AddConstructorArgReference(taskExecutorRef);
            }
            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "error-handler");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "apply-sequence");
            return(builder);
        }
        protected override ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.AGGREGATOR_PACKAGE + ".Resequencer");

            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "discard-channel");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "send-timeout");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "release-partial-sequences");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "send-partial-result-on-timeout");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "reaper-interval");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "tracked-correlation-id-capacity");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "timeout");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "auto-startup");
            return(builder);
        }
        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 ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.AGGREGATOR_PACKAGE + ".MethodInvokingAggregator");
            string refatr = element.GetAttribute(RefAttribute);

            if (!StringUtils.HasText(refatr))
            {
                parserContext.ReaderContext.ReportException(element, element.Name, "The '" + RefAttribute + "' attribute is required.");
            }
            builder.AddConstructorArgReference(refatr);
            if (StringUtils.HasText(element.GetAttribute(MethodAttribute)))
            {
                string method = element.GetAttribute(MethodAttribute);
                builder.AddConstructorArg(method);
            }
            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, DiscardChannelAttribute);
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, SendTimeoutAttribute);
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, SendPartialResultOnTimeoutAttribute);
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, ReaperIntervalAttribute);
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, TrackedCorrelationIdCapacityAttribute);
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "auto-startup");
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, TimeoutAttribute);
            string completionStrategyRef    = element.GetAttribute(CompletionStrategyRefAttribute);
            string completionStrategyMethod = element.GetAttribute(CompletionStrategyMethodAttribute);

            if (StringUtils.HasText(completionStrategyRef))
            {
                if (StringUtils.HasText(completionStrategyMethod))
                {
                    string adapterBeanName = CreateCompletionStrategyAdapter(
                        completionStrategyRef, completionStrategyMethod, parserContext);
                    builder.AddPropertyReference(CompletionStrategyProperty, adapterBeanName);
                }
                else
                {
                    builder.AddPropertyReference(CompletionStrategyProperty, completionStrategyRef);
                }
            }
            return(builder);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        protected override ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
        {
            string refAttribute = element.GetAttribute(RefAttribute);

            if (!StringUtils.HasText(refAttribute))
            {
                parserContext.ReaderContext.ReportException(element, "router", "The '" + RefAttribute + "' attribute is required.");
            }
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CONFIG_PACKAGE + ".RouterFactoryObject");

            builder.AddPropertyReference("targetObject", refAttribute);
            if (StringUtils.HasText(element.GetAttribute(MethodAttribute)))
            {
                string method = element.GetAttribute(MethodAttribute);
                builder.AddPropertyValue("targetMethodName", method);
            }
            ObjectDefinitionBuilder resolverBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CHANNEL_PACKAGE + ".ObjectFactoryChannelResolver");
            string resolverObjectName = parserContext.ReaderContext.RegisterWithGeneratedName(resolverBuilder.ObjectDefinition);

            builder.AddPropertyReference("channelResolver", resolverObjectName);
            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "default-output-channel");
            return(builder);
        }