Merge remote-tracking branch 'upstream/master' into 4.0.0-WIP

Conflicts:
	spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java
	spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java
	spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java
	spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java
	spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AggregatorAnnotationTests.java
	spring-integration-core/src/test/java/org/springframework/integration/config/xml/ControlBusTests.java
	spring-integration-file/src/main/java/org/springframework/integration/file/DefaultFileNameGenerator.java
	spring-integration-file/src/main/java/org/springframework/integration/file/remote/handler/FileTransferringMessageHandler.java
	spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java
	spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundGatewayParserTests.java
	spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpInboundRemoteFileSystemSynchronizerTests.java
	spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java
	spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java
	spring-integration-http/src/test/java/org/springframework/integration/http/outbound/UriVariableExpressionTests.java
	spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptor.java
	spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayIntegrationTests.java
	spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/MongoDbMessageGroupStoreTests.java
	spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/MongoDbMessageStoreTests.java
	spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java
	spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpOutboundGatewayParserTests.java
	spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java
	spring-integration-sftp/src/test/java/org/springframework/integration/sftp/outbound/SftpServerOutboundTests.java

Resolved.
This commit is contained in:
Gary Russell
2013-11-25 17:59:51 -05:00
191 changed files with 8774 additions and 2707 deletions

View File

@@ -16,14 +16,15 @@ import java.util.List;
import org.w3c.dom.Element;
import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.beans.factory.xml.XmlReaderContext;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.integration.scripting.DefaultScriptVariableGenerator;
import org.springframework.integration.scripting.RefreshableResourceScriptSource;
import org.springframework.scripting.support.StaticScriptSource;
import org.springframework.util.CollectionUtils;
@@ -32,6 +33,7 @@ import org.springframework.util.xml.DomUtils;
/**
* @author David Turanski
* @author Artem Bilan
*
*/
public abstract class AbstractScriptParser extends AbstractSingleBeanDefinitionParser {
@@ -62,13 +64,6 @@ public abstract class AbstractScriptParser extends AbstractSingleBeanDefinitionP
List<Element> variableElements = DomUtils.getChildElementsByTagName(element, "variable");
String scriptVariableGeneratorName = element.getAttribute("script-variable-generator");
if (StringUtils.hasText(scriptText)
&& (variableElements.size() > 0 || StringUtils.hasText(scriptVariableGeneratorName))) {
parserContext.getReaderContext().error(
"Variable bindings or custom ScriptVariableGenerator are not allowed when using an inline groovy script. "
+ "Specify location of the script via 'location' attribute instead", element);
return;
}
if (StringUtils.hasText(scriptVariableGeneratorName) && variableElements.size() > 0) {
parserContext.getReaderContext().error(
@@ -88,33 +83,23 @@ public abstract class AbstractScriptParser extends AbstractSingleBeanDefinitionP
builder.addConstructorArgValue(new StaticScriptSource(scriptText));
}
}
BeanMetadataElement scriptVariableGeneratorDef = null;
if (!StringUtils.hasText(scriptVariableGeneratorName)) {
BeanDefinitionBuilder scriptVariableGeneratorBuilder = BeanDefinitionBuilder
.genericBeanDefinition("org.springframework.integration.scripting.DefaultScriptVariableGenerator");
ManagedMap<String, Object> variableMap = new ManagedMap<String, Object>();
for (Element childElement : variableElements) {
String variableName = childElement.getAttribute("name");
String variableValue = childElement.getAttribute("value");
String variableRef = childElement.getAttribute("ref");
if (!(StringUtils.hasText(variableValue) ^ StringUtils.hasText(variableRef))) {
parserContext.getReaderContext().error(
"Exactly one of the 'ref' attribute or 'value' attribute, " + " is required for element "
+ IntegrationNamespaceUtils.createElementDescription(element) + ".", element);
}
if (StringUtils.hasText(variableValue)) {
variableMap.put(variableName, variableValue);
}
else {
variableMap.put(variableName, new RuntimeBeanReference(variableRef));
}
}
.genericBeanDefinition(DefaultScriptVariableGenerator.class);
ManagedMap<String, Object> variableMap = buildVariablesMap(element, parserContext, variableElements);
if (!CollectionUtils.isEmpty(variableMap)) {
scriptVariableGeneratorBuilder.addConstructorArgValue(variableMap);
}
scriptVariableGeneratorName = BeanDefinitionReaderUtils.registerWithGeneratedName(
scriptVariableGeneratorBuilder.getBeanDefinition(), parserContext.getRegistry());
scriptVariableGeneratorDef = scriptVariableGeneratorBuilder.getBeanDefinition();
}
builder.addConstructorArgReference(scriptVariableGeneratorName);
else {
scriptVariableGeneratorDef = new RuntimeBeanReference(scriptVariableGeneratorName);
}
builder.addConstructorArgValue(scriptVariableGeneratorDef);
postProcess(builder, element, parserContext);
}
@@ -138,4 +123,61 @@ public abstract class AbstractScriptParser extends AbstractSingleBeanDefinitionP
return resourceScriptSourceBuilder.getBeanDefinition();
}
private ManagedMap<String, Object> buildVariablesMap(final Element element, final ParserContext parserContext,
List<Element> variableElements) {
@SuppressWarnings("serial")
ManagedMap<String, Object> variableMap = new ManagedMap<String, Object>() {
@Override
public Object put(String key, Object value) {
if (this.containsKey(key)) {
parserContext.getReaderContext().error("Duplicated variable: " + key, element);
}
return super.put(key, value);
}
};
for (Element childElement : variableElements) {
String variableName = childElement.getAttribute("name");
String variableValue = childElement.getAttribute("value");
String variableRef = childElement.getAttribute("ref");
if (!(StringUtils.hasText(variableValue) ^ StringUtils.hasText(variableRef))) {
parserContext.getReaderContext().error(
"Exactly one of the 'ref' attribute or 'value' attribute, " + " is required for element "
+ IntegrationNamespaceUtils.createElementDescription(element) + ".", element);
}
if (StringUtils.hasText(variableValue)) {
variableMap.put(variableName, variableValue);
}
else {
variableMap.put(variableName, new RuntimeBeanReference(variableRef));
}
}
String variables = element.getAttribute("variables");
if (StringUtils.hasText(variables)) {
String[] variablePairs = StringUtils.commaDelimitedListToStringArray(variables);
for (String variablePair : variablePairs) {
String[] variableValue = variablePair.split("=");
if (variableValue.length != 2) {
parserContext.getReaderContext().error(
"Variable declarations in the 'variable' attribute must have the "
+ "form 'var=value'; found : '" + variablePair + "'", element);
}
String variable = variableValue[0].trim();
String value = variableValue[1];
if (variable.endsWith("-ref")) {
variable = variable.substring(0, variable.indexOf("-ref"));
variableMap.put(variable, new RuntimeBeanReference(value));
}
else {
variableMap.put(variable, value);
}
}
}
return variableMap;
}
}

View File

@@ -61,7 +61,7 @@
<xsd:annotation>
<xsd:documentation>
Reference to the ScriptVariableGenerator bean. This attribute is mutually
exclusive with any 'variable' sub-elements.
exclusive with any 'variable' sub-elements and 'variables' attribute.
</xsd:documentation>
<xsd:appinfo>
<tool:expected-type
@@ -78,6 +78,18 @@
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="variables">
<xsd:annotation>
<xsd:documentation>
Comma-delimited pairs of variables and their values.
the variable name can applies '-ref' suffix, which mean to determine
a variable value as a bean reference.
This attribute isn't mutually exclusive with 'variable' sub-elements
and all variables will be merged to one Map.
This attribute is mutually exclusive with 'script-variable-generator' attribute.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:schema>