INT-1727 polished documentation, tests, configuration and schema files to reflect name changes for ScriptVariableGenerator
This commit is contained in:
@@ -104,15 +104,15 @@
|
||||
</para>
|
||||
<para>
|
||||
However if you need more dynamics with regard to how a particular variable is generated then all you need to do is
|
||||
provide your own implementation of ScriptVariableGenerator and inject it via <code>script-variable-source</code> atribute:
|
||||
provide your own implementation of ScriptVariableGenerator and inject it via <code>script-variable-generator</code> attribute:
|
||||
<programlisting language="xml"><![CDATA[<groovy:script location="foo/bar/MyScript.groovy"
|
||||
script-variable-source="scriptVarSource"/>
|
||||
<bean id="scriptVariabelSource" class="foo.bar.MyScriptVariableGeneratore"/>]]></programlisting>
|
||||
script-variable-generator="scriptVarGenerator"/>
|
||||
<bean id="scriptVariableGenerator" class="foo.bar.MyScriptVariableGenerator"/>]]></programlisting>
|
||||
|
||||
<important>
|
||||
|
||||
Remember that <code>script-variable-source</code> and use of <variable> sub-element is mutually exclusive.
|
||||
You can only use one of another. Also, the <code>script-variable-source</code> and/or <variable> sub-elements can
|
||||
Remember that <code>script-variable-generator</code> and use of <variable> sub-element is mutually exclusive.
|
||||
You can only use one of another. Also, the <code>script-variable-generator</code> and/or <variable> sub-elements can
|
||||
not be used when using inline script, only when pointing to the script via <code>location</code> attribute.
|
||||
|
||||
</important>
|
||||
|
||||
@@ -59,7 +59,7 @@ public class GroovyScriptParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
|
||||
List<Element> variableElements = DomUtils.getChildElementsByTagName(element, "variable");
|
||||
String scriptVariableSourceName = element.getAttribute("script-variable-source");
|
||||
String scriptVariableSourceName = element.getAttribute("script-variable-generator");
|
||||
|
||||
if (StringUtils.hasText(scriptText) && (variableElements.size() > 0 || StringUtils.hasText(scriptVariableSourceName))){
|
||||
parserContext.getReaderContext().error("Variable bindings or custom ScriptVariabelSource are not allowed when using inline groovy script. " +
|
||||
@@ -68,7 +68,7 @@ public class GroovyScriptParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(scriptVariableSourceName) && variableElements.size() > 0){
|
||||
parserContext.getReaderContext().error("'script-variable-source' and 'variable' sub-element are mutualy exclusive. Must use one or the other.", element);
|
||||
parserContext.getReaderContext().error("'script-variable-generator' and 'variable' sub-element are mutualy exclusive. Must use one or the other.", element);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Allows you to define custom Groovy variable bindings. The use of this sub-element is mutually
|
||||
exclusive with 'script-variable-source' attribute
|
||||
exclusive with 'script-variable-generator' attribute
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="name" type="xsd:string">
|
||||
@@ -59,14 +59,14 @@
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="script-variable-source">
|
||||
<xsd:attribute name="script-variable-generator" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Reference to the ScriptVariableSource bean. This attribute is mutually
|
||||
exclusive with 'variable' sub-element
|
||||
</xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:expected-type type="rg.springframework.integration.groovy.ScriptVariableSource"/>
|
||||
<tool:expected-type type="rg.springframework.integration.groovy.ScriptVariableGenerator"/>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<service-activator input-channel="withScriptVariableSource">
|
||||
<groovy:script location="org/springframework/integration/groovy/config/GroovyServiceActivatorTests.groovy"
|
||||
script-variable-source="scriptVarSource"/>
|
||||
script-variable-generator="scriptVarSource"/>
|
||||
</service-activator>
|
||||
|
||||
<beans:bean id="scriptVarSource"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<service-activator input-channel="withScriptVariableSource">
|
||||
<groovy:script location="org/springframework/integration/groovy/config/GroovyServiceActivatorTests.groovy"
|
||||
script-variable-source="scriptVarSource">
|
||||
script-variable-generator="scriptVarSource">
|
||||
<groovy:variable name="foo" value="foo"/>
|
||||
<groovy:variable name="bar" value="bar"/>
|
||||
</groovy:script>
|
||||
@@ -82,7 +82,7 @@ public class GroovyServiceActivatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withScriptVariableSource() throws Exception{
|
||||
public void withScriptVariableGenerator() throws Exception{
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
replyChannel.setBeanName("returnAddress");
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
@@ -125,7 +125,7 @@ public class GroovyServiceActivatorTests {
|
||||
|
||||
@Test(expected=BeanDefinitionParsingException.class)
|
||||
public void variablesAndScriptVariableSource() throws Exception{
|
||||
new ClassPathXmlApplicationContext("GroovyServiceActivatorTests-fail-withsource-context.xml", this.getClass());
|
||||
new ClassPathXmlApplicationContext("GroovyServiceActivatorTests-fail-withgenerator-context.xml", this.getClass());
|
||||
}
|
||||
|
||||
public static class SampleScriptVariSource implements ScriptVariableGenerator{
|
||||
|
||||
Reference in New Issue
Block a user