예제 #1
0
        /**
         * Register an error channel in the given ObjectDefinitionRegistry if not yet present.
         * The bean name for which this is checking is defined by the constant
         * {@link IntegrationContextUtils#ERROR_CHANNEL_BEAN_NAME}.
         */
        private void RegisterErrorChannelIfNecessary(IObjectDefinitionRegistry registry)
        {
            if (!registry.ContainsObjectDefinition(IntegrationContextUtils.ErrorChannelObjectName))
            {
                if (logger.IsInfoEnabled)
                {
                    logger.Info("No bean named '" + IntegrationContextUtils.ErrorChannelObjectName +
                                "' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.");
                }

                RootObjectDefinition errorChannelDef = new RootObjectDefinition();
                errorChannelDef.ObjectTypeName = IntegrationNamespaceUtils.BASE_PACKAGE + ".Channel.PublishSubscribeChannel";
                ObjectDefinitionHolder errorChannelHolder = new ObjectDefinitionHolder(errorChannelDef, IntegrationContextUtils.ErrorChannelObjectName);
                ObjectDefinitionReaderUtils.RegisterObjectDefinition(errorChannelHolder, registry);

                ObjectDefinitionBuilder loggingHandlerBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.HANDLER_PACKAGE + ".LoggingHandler");

                string loggingHandlerObjectName = ObjectDefinitionReaderUtils.GenerateObjectName(loggingHandlerBuilder.ObjectDefinition, registry);

                loggingHandlerBuilder.AddConstructorArg("ERROR");
                ObjectDefinitionHolder loggingHandlerHolder = new ObjectDefinitionHolder(loggingHandlerBuilder.ObjectDefinition, loggingHandlerObjectName);
                ObjectDefinitionReaderUtils.RegisterObjectDefinition(loggingHandlerHolder, registry);

                ObjectDefinitionBuilder loggingEndpointBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.ENDPOINT_PACKAGE + ".EventDrivenConsumer");
                loggingEndpointBuilder.AddConstructorArgReference(IntegrationContextUtils.ErrorChannelObjectName);
                loggingEndpointBuilder.AddConstructorArgReference(loggingHandlerObjectName);
                string loggingEndpointObjectName             = ObjectDefinitionReaderUtils.GenerateObjectName(loggingEndpointBuilder.ObjectDefinition, registry);
                ObjectDefinitionHolder loggingEndpointHolder = new ObjectDefinitionHolder(loggingEndpointBuilder.ObjectDefinition, loggingEndpointObjectName);
                ObjectDefinitionReaderUtils.RegisterObjectDefinition(loggingEndpointHolder, registry);
            }
        }
        public string Parse(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CHANNEL_INTERCEPTOR_PACKAGE + ".WireTap");
            string targetRef = element.GetAttribute("channel");

            if (!StringUtils.HasText(targetRef))
            {
                parserContext.ReaderContext.ReportException(element, "wire-tap", "The 'channel' attribute is required.");
            }
            builder.AddConstructorArgReference(targetRef);
            string selectorRef = element.GetAttribute("selector");

            if (StringUtils.HasText(selectorRef))
            {
                builder.AddConstructorArgReference(selectorRef);
            }
            // TODO check timeout
            string timeout = element.GetAttribute("timeout");

            if (StringUtils.HasText(timeout))
            {
                builder.AddPropertyValue("timeout", TimeSpan.Parse(timeout));
            }
            return(parserContext.ReaderContext.RegisterWithGeneratedName(builder.ObjectDefinition));
        }
        protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {
            String containerBeanName = ParseMessageListenerContainer(element, parserContext);
            String listenerBeanName  = ParseMessageListener(element, parserContext);

            builder.AddConstructorArgReference(containerBeanName);
            builder.AddConstructorArgReference(listenerBeanName);
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "auto-startup");
        }
        protected override string ParseSource(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(NmsDestinationPollingSource));
            string nmsTemplate     = element.GetAttribute(NmsAdapterParserUtils.NMS_TEMPLATE_ATTRIBUTE);
            string destination     = element.GetAttribute(NmsAdapterParserUtils.DESTINATION_ATTRIBUTE);
            string destinationName = element.GetAttribute(NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE);
            string headerMapper    = element.GetAttribute(NmsAdapterParserUtils.HEADER_MAPPER_ATTRIBUTE);

            if (StringUtils.HasText(nmsTemplate))
            {
                if (element.HasAttribute(NmsAdapterParserUtils.CONNECTION_FACTORY_ATTRIBUTE) ||
                    element.HasAttribute(NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE) ||
                    element.HasAttribute(NmsAdapterParserUtils.DESTINATION_ATTRIBUTE))
                {
                    throw new ObjectCreationException(
                              "When providing '" + NmsAdapterParserUtils.NMS_TEMPLATE_ATTRIBUTE +
                              "', none of '" + NmsAdapterParserUtils.CONNECTION_FACTORY_ATTRIBUTE +
                              "', '" + NmsAdapterParserUtils.DESTINATION_ATTRIBUTE + "', or '" +
                              NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE + "' should be provided.");
                }
                builder.AddConstructorArgReference(nmsTemplate);
            }

            else if (StringUtils.HasText(destination) || StringUtils.HasText(destinationName))
            {
                builder.AddConstructorArgReference(NmsAdapterParserUtils.DetermineConnectionFactoryBeanName(element,
                                                                                                            parserContext));
                if (StringUtils.HasText(destination))
                {
                    builder.AddConstructorArgReference(destination);
                }
                else if (StringUtils.HasText(destinationName))
                {
                    builder.AddConstructorArg(destinationName);
                }
            }
            else
            {
                throw new ObjectCreationException("either a '" + NmsAdapterParserUtils.NMS_TEMPLATE_ATTRIBUTE + "' or one of '" +
                                                  NmsAdapterParserUtils.DESTINATION_ATTRIBUTE + "' or '" + NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE +
                                                  "' attributes must be provided for a polling NMS adapter");
            }
            if (StringUtils.HasText(headerMapper))
            {
                builder.AddPropertyReference(NmsAdapterParserUtils.HEADER_MAPPER_PROPERTY, headerMapper);
            }
            IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "extract-payload");
            IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "destination-resolver");
            return(parserContext.ReaderContext.RegisterWithGeneratedName(builder.ObjectDefinition));
        }
예제 #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);
        }
        private static string CreateCompletionStrategyAdapter(string refatr, string method, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.AGGREGATOR_PACKAGE + ".CompletionStrategyAdapter");

            builder.AddConstructorArgReference(refatr);
            builder.AddConstructorArg(method);
            return(parserContext.ReaderContext.RegisterWithGeneratedName(builder.ObjectDefinition));
        }
예제 #7
0
        /// <summary>The do parse.</summary>
        /// <param name="element">The element.</param>
        /// <param name="parserContext">The parser context.</param>
        /// <param name="builder">The builder.</param>
        protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {
            var connectionFactoryRef = element.GetAttribute(CONNECTION_FACTORY_ATTRIBUTE);

            if (string.IsNullOrWhiteSpace(connectionFactoryRef))
            {
                parserContext.ReaderContext.ReportFatalException(element, "A '" + CONNECTION_FACTORY_ATTRIBUTE + "' attribute must be set.");
            }

            if (!string.IsNullOrWhiteSpace(connectionFactoryRef))
            {
                // Use constructor with connectionFactory parameter
                builder.AddConstructorArgReference(connectionFactoryRef);
            }

            NamespaceUtils.SetValueIfAttributeDefined(builder, element, CHANNEL_TRANSACTED_ATTRIBUTE);
            NamespaceUtils.SetValueIfAttributeDefined(builder, element, QUEUE_ATTRIBUTE);
            NamespaceUtils.SetValueIfAttributeDefined(builder, element, EXCHANGE_ATTRIBUTE);
            NamespaceUtils.SetValueIfAttributeDefined(builder, element, ROUTING_KEY_ATTRIBUTE);
            NamespaceUtils.SetValueIfAttributeDefined(builder, element, REPLY_TIMEOUT_ATTRIBUTE);
            NamespaceUtils.SetValueIfAttributeDefined(builder, element, ENCODING_ATTRIBUTE);
            NamespaceUtils.SetReferenceIfAttributeDefined(builder, element, MESSAGE_CONVERTER_ATTRIBUTE);
            NamespaceUtils.SetReferenceIfAttributeDefined(builder, element, REPLY_QUEUE_ATTRIBUTE);
            NamespaceUtils.SetValueIfAttributeDefined(builder, element, MANDATORY_ATTRIBUTE);
            NamespaceUtils.SetValueIfAttributeDefined(builder, element, IMMEDIATE_ATTRIBUTE);
            NamespaceUtils.SetReferenceIfAttributeDefined(builder, element, RETURN_CALLBACK_ATTRIBUTE);
            NamespaceUtils.SetReferenceIfAttributeDefined(builder, element, CONFIRM_CALLBACK_ATTRIBUTE);

            IObjectDefinition replyContainer = null;
            XmlElement        childElement   = null;
            var childElements = element.SelectChildElementsByTagName(LISTENER_ELEMENT);

            if (childElements.Count > 0)
            {
                childElement = childElements[0] as XmlElement;
            }

            if (childElement != null)
            {
                replyContainer = this.ParseListener(childElement, element, parserContext);
                if (replyContainer != null)
                {
                    replyContainer.PropertyValues.Add("MessageListener", new RuntimeObjectReference(element.GetAttribute(ID_ATTRIBUTE)));
                    var replyContainerName = element.GetAttribute(ID_ATTRIBUTE) + ".ReplyListener";
                    parserContext.Registry.RegisterObjectDefinition(replyContainerName, replyContainer);
                }
            }

            if (replyContainer == null && element.HasAttribute(REPLY_QUEUE_ATTRIBUTE))
            {
                parserContext.ReaderContext.ReportFatalException(element, "For template '" + element.GetAttribute(ID_ATTRIBUTE) + "', when specifying a reply-queue, a <reply-listener/> element is required");
            }
            else if (replyContainer != null && !element.HasAttribute(REPLY_QUEUE_ATTRIBUTE))
            {
                parserContext.ReaderContext.ReportFatalException(element, "For template '" + element.GetAttribute(ID_ATTRIBUTE) + "', a <reply-listener/> element is not allowed if no 'reply-queue' is supplied");
            }
        }
예제 #8
0
        /// <summary>
        /// Parse the specified XmlElement and register the resulting
        ///             ObjectDefinitions with the <see cref="P:Spring.Objects.Factory.Xml.ParserContext.Registry"/> IObjectDefinitionRegistry
        ///             embedded in the supplied <see cref="T:Spring.Objects.Factory.Xml.ParserContext"/>
        /// </summary>
        /// <remarks>
        /// <p>This method is never invoked if the parser is namespace aware
        ///             and was called to process the root node.
        ///             </p>
        /// </remarks>
        /// <param name="element">The element to be parsed.
        ///             </param><param name="parserContext">TThe object encapsulating the current state of the parsing process.
        ///             Provides access to a IObjectDefinitionRegistry
        ///             </param>
        /// <returns>
        /// The primary object definition.
        /// </returns>
        public IObjectDefinition ParseElement(XmlElement element, ParserContext parserContext)
        {
            IObjectDefinitionFactory factory = parserContext.ReaderContext.ObjectDefinitionFactory;

            AssertUtils.ArgumentNotNull(factory, "factory");

            RegisterTypeConverters();

            string id        = element.GetAttribute(ObjectNames.MongoId);
            string defaultId = StringUtils.HasText(id) ? id : ObjectNames.MongoDatabaseFactoryDefaultId;
            string url       = element.GetAttribute(ObjectNames.MongoDatabaseFactoryUrl);
            string mongoRef  = element.GetAttribute(ObjectNames.MongoDatabaseFactoryMongoRef);
            string dbname    = element.GetAttribute(ObjectNames.MongoDatabaseFactoryDbname);

            ObjectDefinitionBuilder dbFactoryBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(SimpleMongoDatabaseFactory));

            IObjectDefinition userCredentials = GetUserCredentialsObjectDefinition(element);

            ParseAttribute(element, dbFactoryBuilder, SimpleMongoDatabaseFactory.WriteConcernProperty, ObjectNames.MongoDatabaseFactoryWriteConcern);

            if (StringUtils.HasText(url))
            {
                if (StringUtils.HasText(mongoRef) || StringUtils.HasText(dbname) || userCredentials != null)
                {
                    parserContext.ReaderContext.ReportException(element, ObjectNames.DbFactory, "Configure either url or details individually!");
                }

                dbFactoryBuilder.AddConstructorArg(GetMongoUrl(url));
                parserContext.Registry.RegisterObjectDefinition(defaultId, dbFactoryBuilder.ObjectDefinition);

                return(null);
            }

            if (StringUtils.HasText(mongoRef))
            {
                dbFactoryBuilder.AddConstructorArgReference(mongoRef);
            }
            else
            {
                dbFactoryBuilder.AddConstructorArg(RegisterMongoObjectDefinition(element));
            }

            dbname = StringUtils.HasText(dbname) ? dbname : ObjectNames.MongoDatabaseFactoryDefaultDatabaseName;
            dbFactoryBuilder.AddConstructorArg(dbname);

            if (userCredentials != null)
            {
                dbFactoryBuilder.AddConstructorArg(userCredentials);
            }

            parserContext.Registry.RegisterObjectDefinition(defaultId, dbFactoryBuilder.ObjectDefinition);

            return(null);
        }
        protected override ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder            = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.TRANSFORMER_PACKAGE + ".MessageTransformingHandler");
            ObjectDefinitionBuilder transformerBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(TransformerClassName);

            ParseTransformer(element, parserContext, transformerBuilder);
            string transformerBeanName = parserContext.ReaderContext.RegisterWithGeneratedName(transformerBuilder.ObjectDefinition);

            builder.AddConstructorArgReference(transformerBeanName);
            return(builder);
        }
예제 #10
0
        /// <summary>Adds the constructor arg ref if attribute defined.</summary>
        /// <param name="builder">The builder.</param>
        /// <param name="element">The element.</param>
        /// <param name="attributeName">Name of the attribute.</param>
        /// <returns><c>true</c> if [is attribute defined] [the specified element]; otherwise, <c>false</c>.</returns>
        public static bool AddConstructorArgRefIfAttributeDefined(ObjectDefinitionBuilder builder, XmlElement element, string attributeName)
        {
            var value = element.GetAttribute(attributeName);

            if (!string.IsNullOrWhiteSpace(value))
            {
                builder.AddConstructorArgReference(value);
                return(true);
            }

            return(false);
        }
        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 AbstractObjectDefinition ParseConsumer(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder invokerBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.HANDLER_PACKAGE + ".MethodInvokingMessageHandler");

            invokerBuilder.AddConstructorArgReference(element.GetAttribute("ref"));
            invokerBuilder.AddConstructorArg(element.GetAttribute("method"));
            string order = element.GetAttribute("order");

            if (StringUtils.HasText(order))
            {
                invokerBuilder.AddPropertyValue("order", order);
            }
            return(invokerBuilder.ObjectDefinition);
        }
        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 ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.HANDLER_PACKAGE + ".ServiceActivatingHandler");
            string refAttribute             = element.GetAttribute(RefAttribute);

            if (!StringUtils.HasText(refAttribute))
            {
                parserContext.ReaderContext.ReportException(element, "ref", "The '" + RefAttribute + "' attribute is required.");
            }
            builder.AddConstructorArgReference(refAttribute);
            if (StringUtils.HasText(element.GetAttribute(MethodAttribute)))
            {
                string method = element.GetAttribute(MethodAttribute);
                builder.AddConstructorArg(method);
            }
            return(builder);
        }
예제 #15
0
        /// <summary>The do parse.</summary>
        /// <param name="element">The element.</param>
        /// <param name="parserContext">The parser context.</param>
        /// <param name="builder">The builder.</param>
        protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {
            if (!NamespaceUtils.IsAttributeDefined(element, "name") && !NamespaceUtils.IsAttributeDefined(element, ID_ATTRIBUTE))
            {
                parserContext.ReaderContext.ReportFatalException(element, "Queue must have either id or name (or both)");
            }

            NamespaceUtils.AddConstructorArgValueIfAttributeDefined(builder, element, "name");

            if (!NamespaceUtils.IsAttributeDefined(element, "name"))
            {
                if (this.AttributeHasIllegalOverride(element, DURABLE_ATTRIBUTE, "false") ||
                    this.AttributeHasIllegalOverride(element, EXCLUSIVE_ATTRIBUTE, "true") ||
                    this.AttributeHasIllegalOverride(element, AUTO_DELETE_ATTRIBUTE, "true"))
                {
                    parserContext.ReaderContext.ReportFatalException(element, "Anonymous queue cannot specify durable='true', exclusive='false' or auto-delete='false'");
                    return;
                }
            }
            else
            {
                NamespaceUtils.AddConstructorArgBooleanValueIfAttributeDefined(builder, element, DURABLE_ATTRIBUTE, false);
                NamespaceUtils.AddConstructorArgBooleanValueIfAttributeDefined(builder, element, EXCLUSIVE_ATTRIBUTE, false);
                NamespaceUtils.AddConstructorArgBooleanValueIfAttributeDefined(builder, element, AUTO_DELETE_ATTRIBUTE, false);
            }

            var queueArguments   = element.GetAttribute(ARGUMENTS);
            var argumentsElement = element.SelectChildElementByTagName(ARGUMENTS);

            if (argumentsElement != null)
            {
                var parser = new ObjectDefinitionParserHelper(parserContext);
                if (!string.IsNullOrWhiteSpace(queueArguments))
                {
                    parserContext.ReaderContext.ReportFatalException(element, "Queue may have either a queue-attributes attribute or element, but not both");
                }

                var map = parser.ParseMapElement(argumentsElement, builder.RawObjectDefinition);
                builder.AddConstructorArg(map);
            }

            if (!string.IsNullOrWhiteSpace(queueArguments))
            {
                builder.AddConstructorArgReference(queueArguments);
            }
        }
예제 #16
0
        private static string ParseSelector(XmlElement element, ParserContext parserContext)
        {
            string refAttribute = element.GetAttribute("ref");

            if (!StringUtils.HasText(refAttribute))
            {
                parserContext.ReaderContext.ReportException(element, "filter", "The 'ref' attribute is required.");
            }
            string method = element.GetAttribute("method");

            if (!StringUtils.HasText(method))
            {
                return(refAttribute);
            }
            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.FILTER_PACKAGE + ".MethodInvokingSelector");

            builder.AddConstructorArgReference(refAttribute);
            builder.AddConstructorArg(method);
            return(parserContext.ReaderContext.RegisterWithGeneratedName(builder.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);
        }
예제 #18
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);
        }
예제 #19
0
        /// <summary>The do parse.</summary>
        /// <param name="element">The element.</param>
        /// <param name="parserContext">The parser context.</param>
        /// <param name="builder">The builder.</param>
        protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {
            var connectionFactoryRef = element.GetAttribute(CONNECTION_FACTORY_ATTRIBUTE);

            // At least one of 'templateRef' or 'connectionFactoryRef' attribute must be set.
            if (string.IsNullOrWhiteSpace(connectionFactoryRef))
            {
                parserContext.ReaderContext.ReportFatalException(element, "A '" + CONNECTION_FACTORY_ATTRIBUTE + "' attribute must be set.");
            }

            if (!string.IsNullOrWhiteSpace(connectionFactoryRef))
            {
                // Use constructor with connectionFactory parameter
                builder.AddConstructorArgReference(connectionFactoryRef);
            }

            var attributeValue = element.GetAttribute(AUTO_STARTUP_ATTRIBUTE);

            if (!string.IsNullOrWhiteSpace(attributeValue))
            {
                builder.AddPropertyValue("AutoStartup", attributeValue);
            }
        }