diff --git a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyControlBusFactoryBean.java b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyControlBusFactoryBean.java
index 08ee2d386e..b0e2eccbeb 100644
--- a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyControlBusFactoryBean.java
+++ b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyControlBusFactoryBean.java
@@ -27,6 +27,7 @@ import org.springframework.integration.groovy.GroovyCommandMessageProcessor;
import org.springframework.integration.handler.ServiceActivatingHandler;
import org.springframework.integration.scripting.ScriptVariableGenerator;
import org.springframework.jmx.export.annotation.ManagedResource;
+import org.springframework.scripting.groovy.GroovyObjectCustomizer;
import org.springframework.util.CustomizableThreadCreator;
/**
@@ -34,20 +35,31 @@ import org.springframework.util.CustomizableThreadCreator;
*
* @author Dave Syer
* @author Oleg Zhurakousky
+ * @author Mark Fisher
* @since 2.0
*/
public class GroovyControlBusFactoryBean extends AbstractSimpleMessageHandlerFactoryBean {
private volatile Long sendTimeout;
+ private volatile GroovyObjectCustomizer customizer;
+
+
public void setSendTimeout(Long sendTimeout) {
this.sendTimeout = sendTimeout;
}
+ public void setCustomizer(GroovyObjectCustomizer customizer) {
+ this.customizer = customizer;
+ }
+
@Override
protected MessageHandler createHandler() {
ManagedBeansScriptVariableGenerator scriptVariableGenerator = new ManagedBeansScriptVariableGenerator(this.getBeanFactory());
GroovyCommandMessageProcessor processor = new GroovyCommandMessageProcessor(scriptVariableGenerator);
+ if (this.customizer != null) {
+ processor.setCustomizer(this.customizer);
+ }
return this.configureHandler(new ServiceActivatingHandler(processor));
}
diff --git a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyControlBusParser.java b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyControlBusParser.java
index 26e61c9909..56d19a592f 100644
--- a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyControlBusParser.java
+++ b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyControlBusParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2011 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. You may obtain a copy of the License at
@@ -29,6 +29,7 @@ public class GroovyControlBusParser extends AbstractConsumerEndpointParser {
@Override
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(GroovyControlBusFactoryBean.class);
+ IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "customizer");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "order");
return builder;
diff --git a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyScriptParser.java b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyScriptParser.java
index c9d31077dd..3f6ad0dba8 100644
--- a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyScriptParser.java
+++ b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyScriptParser.java
@@ -68,7 +68,7 @@ public class GroovyScriptParser extends AbstractSingleBeanDefinitionParser {
return;
}
- if (StringUtils.hasText(scriptVariableGeneratorName) && variableElements.size() > 0){
+ if (StringUtils.hasText(scriptVariableGeneratorName) && variableElements.size() > 0) {
parserContext.getReaderContext().error("'script-variable-generator' and 'variable' sub-elements are mutualy exclusive.", element);
return;
}
@@ -106,6 +106,7 @@ public class GroovyScriptParser extends AbstractSingleBeanDefinitionParser {
scriptVariableGeneratorBuilder.getBeanDefinition(), parserContext.getRegistry());
}
builder.addConstructorArgReference(scriptVariableGeneratorName);
+ IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "customizer");
}
private Object resolveScriptLocation(Element element, XmlReaderContext readerContext, String scriptLocation) {
diff --git a/spring-integration-groovy/src/main/resources/org/springframework/integration/groovy/config/spring-integration-groovy-2.0.xsd b/spring-integration-groovy/src/main/resources/org/springframework/integration/groovy/config/spring-integration-groovy-2.0.xsd
index caef23acc2..f636706dc4 100644
--- a/spring-integration-groovy/src/main/resources/org/springframework/integration/groovy/config/spring-integration-groovy-2.0.xsd
+++ b/spring-integration-groovy/src/main/resources/org/springframework/integration/groovy/config/spring-integration-groovy-2.0.xsd
@@ -20,27 +20,27 @@
Allows you to define custom Groovy variable bindings. The use of this sub-element is mutually
- exclusive with 'script-variable-generator' attribute
+ exclusive with the 'script-variable-generator' attribute.
- Name of the Groovy binding variable
+ Name of the Groovy variable.
- Value of the Groovy binding variable
+ Value of the Groovy variable as a literal.
- Value of the Groovy binding variable pointing to a bean reference
+ Value of the Groovy variable as a bean reference.
@@ -54,8 +54,7 @@
Resource location path for the Script. Either this or an inline script
- as body text should be
- provided, but not both.
+ as body text should be provided, but not both.
@@ -63,10 +62,20 @@
Reference to the ScriptVariableGenerator bean. This attribute is mutually
- exclusive with 'variable' sub-element
+ exclusive with any 'variable' sub-elements.
-
+
+
+
+
+
+
+
+ Reference to a GroovyObjectCustomizer bean to be applied to this script.
+
+
+
@@ -74,8 +83,7 @@
Refresh delay for the script contents if specified as a resource
- location (defaults to never
- refresh).
+ location (defaults to -1, never refresh).
@@ -95,6 +103,16 @@
+
+
+
+ Reference to a GroovyObjectCustomizer bean to be applied to each script payload.
+
+
+
+
+
+