protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {
            String taskExecutorRef = element.GetAttribute("task-executor");

            if (StringUtils.HasText(taskExecutorRef))
            {
                builder.AddPropertyReference("taskExecutor", taskExecutorRef);
            }
            else
            {
                IExecutor taskExecutor = IntegrationContextUtils.CreateThreadPoolTaskExecutor(1, 10, 0, "event-multicaster-");
                builder.AddPropertyValue("taskExecutor", taskExecutor);
            }
            // TODO CopyOnWriteArraySet
            builder.AddPropertyValue("collectionClass", typeof(Set));  //CopyOnWriteArraySet));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Register a TaskScheduler in the given <see cref="IObjectDefinitionFactory"/> if not yet present.
        /// The object name for which this is checking is defined by the constant <see cref="IntegrationContextUtils.TaskSchedulerObjectName"/>
        /// </summary>
        /// <param name="registry">the <see cref="IObjectDefinitionFactory"/></param>
        private void RegisterTaskSchedulerIfNecessary(IObjectDefinitionRegistry registry)
        {
            if (!registry.ContainsObjectDefinition(IntegrationContextUtils.TaskSchedulerObjectName))
            {
                if (logger.IsInfoEnabled)
                {
                    logger.Info("No object named '" + IntegrationContextUtils.TaskSchedulerObjectName +
                                "' has been explicitly defined. Therefore, a default SimpleTaskScheduler will be created.");
                }
                IExecutor taskExecutor = IntegrationContextUtils.CreateThreadPoolTaskExecutor(2, 100, 0, "task-scheduler-");
                ObjectDefinitionBuilder schedulerBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.SCHEDULING_PACKAGE + ".SimpleTaskScheduler");
                schedulerBuilder.AddConstructorArg(taskExecutor);

                ObjectDefinitionBuilder errorHandlerBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CHANNEL_PACKAGE + ".MessagePublishingErrorHandler");
                errorHandlerBuilder.AddPropertyReference("defaultErrorChannel", IntegrationContextUtils.ErrorChannelObjectName);
                string errorHandlerBeanName = ObjectDefinitionReaderUtils.GenerateObjectName(errorHandlerBuilder.ObjectDefinition, registry);
                ObjectDefinitionHolder errorHandlerHolder = new ObjectDefinitionHolder(errorHandlerBuilder.ObjectDefinition, errorHandlerBeanName);
                ObjectDefinitionReaderUtils.RegisterObjectDefinition(errorHandlerHolder, registry);

                schedulerBuilder.AddPropertyReference("errorHandler", errorHandlerBeanName);
                ObjectDefinitionHolder schedulerHolder = new ObjectDefinitionHolder(schedulerBuilder.ObjectDefinition, IntegrationContextUtils.TaskSchedulerObjectName);
                ObjectDefinitionReaderUtils.RegisterObjectDefinition(schedulerHolder, registry);
            }
        }