INT-625 initial commit of namespace support for 'task-executor' on the <channel/> element

This commit is contained in:
Mark Fisher
2009-07-03 07:50:41 +00:00
parent 22543dba6e
commit bf25807969
2 changed files with 36 additions and 3 deletions

View File

@@ -41,6 +41,8 @@ public class PointToPointChannelParser extends AbstractChannelParser {
protected BeanDefinitionBuilder buildBeanDefinition(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = null;
Element queueElement = null;
// configure a queue-based channel if any queue sub-element is defined
if ((queueElement = DomUtils.getChildElementByTagName(element, "queue")) != null) {
builder = BeanDefinitionBuilder.genericBeanDefinition(CHANNEL_PACKAGE + ".QueueChannel");
boolean hasCapacity = this.parseQueueCapacity(builder, queueElement);
@@ -61,8 +63,24 @@ public class PointToPointChannelParser extends AbstractChannelParser {
else if ((queueElement = DomUtils.getChildElementByTagName(element, "rendezvous-queue")) != null) {
builder = BeanDefinitionBuilder.genericBeanDefinition(CHANNEL_PACKAGE + ".RendezvousChannel");
}
else {
builder = BeanDefinitionBuilder.genericBeanDefinition(CHANNEL_PACKAGE + ".DirectChannel");
// verify that the 'task-executor' is not provided if a queue sub-element exists
String taskExecutor = element.getAttribute("task-executor");
if (queueElement != null && StringUtils.hasText(taskExecutor)) {
parserContext.getReaderContext().error("The 'task-executor' attribute " +
"and any queue sub-element are mutually exclusive.", element);
return null;
}
if (builder == null) {
// configure either an ExecutorChannel or DirectChannel based on existence of 'task-executor'
if (StringUtils.hasText(taskExecutor)) {
builder = BeanDefinitionBuilder.genericBeanDefinition(CHANNEL_PACKAGE + ".ExecutorChannel");
builder.addConstructorArgReference(taskExecutor);
}
else {
builder = BeanDefinitionBuilder.genericBeanDefinition(CHANNEL_PACKAGE + ".DirectChannel");
}
parseDispatcher(element.getAttribute("dispatcher"), builder, parserContext);
}
return builder;

View File

@@ -46,7 +46,7 @@
<xsd:element name="channel">
<xsd:annotation>
<xsd:documentation>
Defines a Point-to-Point MessageChannel.
Defines a Point-to-Point MessageChannel.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation>
@@ -66,6 +66,21 @@
<xsd:element name="interceptors" type="channelInterceptorsType"
minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="task-executor" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Provide a TaskExecutor to use when dispatching Messages to this channel's subscribers. This is
mutually exclusive with any of the queue sub-elements. Also, when using a TaskExecutor, keep in
mind that any transaction active for the sender will NOT propagate to the handler invocation
since the TaskExecutor dispatches to the handler on a separate Thread.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.core.task.TaskExecutor" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>