INT-3527: WebSocket and 'o-c-a' Improvements
JIRA: https://jira.spring.io/browse/INT-3527 * `WebSocketInboundChannelAdapter` now handles `CONNECT` STOMP message and sends `CONNECT_ACK` message to the `WebSocketSession` immediately * `ExpressionMessageProducerSupport` implementations now checks the result of `expression` and if it is a `Message<?>` it is sent to channel without creating a new one which previously wrapped that `Message<?>` as the `payload`. * Add `<script>` support to the `<outbound-channel-adapter>` * Upgrade to the SF 4.1.1 * Add appropriate notes to the Docs
This commit is contained in:
committed by
Gary Russell
parent
d5f1bb6516
commit
252c53db4c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.integration.config.xml;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
@@ -27,6 +28,7 @@ import org.springframework.integration.config.ExpressionFactoryBean;
|
||||
import org.springframework.integration.handler.ExpressionEvaluatingMessageHandler;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <outbound-channel-adapter/> element.
|
||||
@@ -39,20 +41,32 @@ public class DefaultOutboundChannelAdapterParser extends AbstractOutboundChannel
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanComponentDefinition innerConsumerDefinition = IntegrationNamespaceUtils.parseInnerHandlerDefinition(element, parserContext);
|
||||
Object source = parserContext.extractSource(element);
|
||||
BeanComponentDefinition innerConsumerDefinition =
|
||||
IntegrationNamespaceUtils.parseInnerHandlerDefinition(element, parserContext);
|
||||
|
||||
String consumerRef = element.getAttribute(IntegrationNamespaceUtils.REF_ATTRIBUTE);
|
||||
String methodName = element.getAttribute(IntegrationNamespaceUtils.METHOD_ATTRIBUTE);
|
||||
String consumerExpressionString = element.getAttribute(IntegrationNamespaceUtils.EXPRESSION_ATTRIBUTE);
|
||||
Element scriptElement = DomUtils.getChildElementByTagName(element, "script");
|
||||
|
||||
boolean isInnerConsumer = innerConsumerDefinition != null;
|
||||
boolean isRef = StringUtils.hasText(consumerRef);
|
||||
boolean isExpression = StringUtils.hasText(consumerExpressionString);
|
||||
boolean hasMethod = StringUtils.hasText(methodName);
|
||||
boolean hasScript = scriptElement != null;
|
||||
|
||||
if (!(isInnerConsumer ^ (isRef ^ isExpression))) {
|
||||
if (!isInnerConsumer & !isRef & !isExpression & !hasScript) {
|
||||
parserContext.getReaderContext().error(
|
||||
"Exactly one of the 'ref', 'expression' or inner bean is required.", element);
|
||||
"Exactly one of the 'ref', 'expression', <script> or inner bean is required.", source);
|
||||
}
|
||||
|
||||
if (hasScript) {
|
||||
if (isRef | isExpression) {
|
||||
parserContext.getReaderContext().error(
|
||||
"Neither 'ref' nor 'expression' are permitted when an inner script element is configured.",
|
||||
source);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasMethod & isExpression) {
|
||||
@@ -68,6 +82,13 @@ public class DefaultOutboundChannelAdapterParser extends AbstractOutboundChannel
|
||||
expressionDef.getConstructorArgumentValues().addGenericArgumentValue(consumerExpressionString);
|
||||
consumerBuilder.addConstructorArgValue(expressionDef);
|
||||
}
|
||||
else if (hasScript) {
|
||||
consumerBuilder = BeanDefinitionBuilder.genericBeanDefinition(MethodInvokingMessageHandler.class);
|
||||
BeanDefinition scriptBeanDefinition = parserContext.getDelegate().parseCustomElement(scriptElement,
|
||||
consumerBuilder.getBeanDefinition());
|
||||
consumerBuilder.addConstructorArgValue(scriptBeanDefinition);
|
||||
consumerBuilder.addConstructorArgValue("processMessage");
|
||||
}
|
||||
else {
|
||||
consumerBuilder = BeanDefinitionBuilder.genericBeanDefinition(MethodInvokingMessageHandler.class);
|
||||
if (isRef) {
|
||||
|
||||
@@ -1152,11 +1152,11 @@
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="outboundChannelAdapterType">
|
||||
<xsd:all>
|
||||
<xsd:choice minOccurs="0" maxOccurs="3">
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element ref="beans:bean" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="request-handler-advice-chain" type="handlerAdviceChainType" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:choice>
|
||||
<xsd:attributeGroup ref="channelAdapterAttributes" />
|
||||
<xsd:attribute name="order">
|
||||
<xsd:annotation>
|
||||
@@ -1171,9 +1171,9 @@
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="outboundChannelAdapterTypeChain">
|
||||
<xsd:all>
|
||||
<xsd:element ref="beans:bean" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:choice minOccurs="0">
|
||||
<xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user