Browse files

upgraded to groovy 2.0

  • Loading branch information...
1 parent f077ec8 commit 779b0bb260e6dccd198d25c380388a8dbf7b62f1 David Turanski committed Oct 24, 2012
View
1 .gitignore
@@ -7,5 +7,6 @@ build
.idea
.gradle
.externalToolBuilders
+.DS_Store
bin
activemq-data
View
11 README.md
@@ -3,7 +3,7 @@ Groovy DSL For Spring Integration
#Overview
-This project implements a Groovy DSL for Spring Integration. Coming on the heels of the [Scala DSL for Spring Integration] (https://github.com/SpringSource/spring-integration-scala), I have incorporated some of the same basic ideas and vocabulary however this is intended for Groovy developers and Java developers looking for a simple and powerful alternative to XML configuration.
+This project implements a Groovy DSL for Spring Integration. Coming on the heels of the [Scala DSL for Spring Integration] (https://github.com/SpringSource/spring-integration-scala), I have incorporated some of the same basic ideas and vocabulary however this is intended for Groovy developers and Java developers looking for a simple and powerful alternative to XML configuration. This page provides a simple overview to get you started using the DSL. Please refer to the project (Wiki)[https://github.com/SpringSource/spring-integration-dsl-groovy/wiki] pages for more details.
## Features
* Simple configuration using the Groovy builder pattern with the ability to implement endpoint logic in closures
@@ -51,6 +51,7 @@ This flow can also be executed from a Java class. The easiest way is to create a
}
The Equivalant Java code is:
+
IntegrationBuilder builder = new IntegrationBuilder();
MessageFlow flow = (MessageFlow)builder.build(new FileInputStream("messageFlow1.groovy");
flow.sendAndReceive("hello");
@@ -71,8 +72,8 @@ Multiple Message Flows:
assert response == "hello", response
-The above example illustrates two message flows explicitly connected through a named channel 'outputChannel1'. A message sent to flow1's input channel is routed
-to flow2 via its outputChannel. Note that the name of the flow1 input channel is automatically created by appending '.inputChannel' to it's name. This is true of all endpoints.
+The above example illustrates two message flows explicitly connected through a named channel *'outputChannel1'*. A message sent to *flow1*'s input channel is routed
+to *flow2* via its outputChannel. Note that the name of the flow1 input channel is automatically created by appending *'.inputChannel'* to it's name. This is true of all endpoints.
# Building an IntegrationContext with 'doWithSpringIntegration'
@@ -91,7 +92,7 @@ It is possible to build multiple MessageFlows. In Groovy, builder.messageFlow()
handle(inputChannel:flow2.outputChannel,{println it})
}
-doWithSpringIntegration returns an IntegrationContext which can be used to access MessageFlows (they are returned as a List). IntegrationContext also provides
+_doWithSpringIntegration_ returns an IntegrationContext which can be used to access MessageFlows (they are returned as a List). IntegrationContext also provides
send() and sendAndReceive() which require an inputChannel as well as a Message or payload
def integrationContext = doWithSpringIntegration {builder->
@@ -179,7 +180,7 @@ This example shows the use of the map() method to create a channel map for a rou
message = MessageBuilder.withPayload("SOMETHING").copyHeaders([foo:'baz']).build()
assert flow.sendAndReceive(message).payload == "SOMETHINGSOMETHING"
-Note also the 'linkToNext' attribute can be used to prevent chaining the two transformers within a MessageFlow. Alternatives include creating the transformers external to the MessageFlow or nest each in its own MessageFlow
+Note also the _'linkToNext'_ attribute can be used to prevent chaining the two transformers within a MessageFlow. Alternatives include creating the transformers external to the MessageFlow or nest each in its own MessageFlow
## Nested Router Conditions
View
8 build.gradle
@@ -20,12 +20,6 @@ subprojects { subproject ->
apply plugin: 'eclipse'
sourceCompatibility=1.6
targetCompatibility=1.6
-
- project.ext.junitVersion = '4.8.2'
- project.ext.log4jVersion = '1.2.14'
- project.ext.mockitoVersion = '1.9.0'
- project.ext.springIntegrationVersion = '2.2.0.RC1'
- project.ext.groovyVersion = '1.8.7'
install {
repositories.mavenInstaller {
@@ -47,7 +41,7 @@ subprojects { subproject ->
groovy "org.codehaus.groovy:groovy-all:$groovyVersion"
testCompile "junit:junit-dep:$junitVersion"
- testCompile "log4j:log4j:$log4jVersion"
+ testRuntime "log4j:log4j:$log4jVersion"
testCompile "org.mockito:mockito-all:$mockitoVersion"
}
}
View
5 gradle.properties
@@ -1 +1,6 @@
version = 1.0.0.BUILD-SNAPSHOT
+junitVersion = 4.8.2
+log4jVersion = 1.2.14
+mockitoVersion = 1.9.0
+springIntegrationVersion = 2.2.0.RC1
+groovyVersion = 2.0.5
View
13 .../main/groovy/org/springframework/integration/dsl/groovy/builder/IntegrationBuilder.groovy
@@ -136,7 +136,18 @@ class IntegrationBuilder extends FactoryBuilderSupport {
}
Object build(InputStream is) {
- def script = new GroovyClassLoader().parseClass(is).newInstance()
+ def grs = new GroovyCodeSource(new InputStreamReader(is),this.getClass().getName(),GroovyShell.DEFAULT_CODE_BASE)
+ def script = new GroovyClassLoader().parseClass(grs).newInstance()
+ this.build(script)
+ }
+
+ Object build(File file) {
+ def script = new GroovyClassLoader().parseClass(file).newInstance()
+ this.build(script)
+ }
+
+ Object build(GroovyCodeSource codeSource) {
+ def script = new GroovyClassLoader().parseClass(codeSource).newInstance()
this.build(script)
}
View
7 ...vy/org/springframework/integration/dsl/groovy/builder/IntegrationBuilderUsageTests.groovy
@@ -41,9 +41,10 @@ class IntegrationBuilderUsageTests {
@Test
void test1() {
- new File("src/test/resources/messageflow1.groovy").withInputStream {input->
- script = new GroovyClassLoader().parseClass(input).newInstance()
- }
+
+ def codeSource = new GroovyCodeSource(new File("src/test/resources/messageflow1.groovy"));
+ script = new GroovyClassLoader().parseClass(codeSource).newInstance()
+
def eip = builder.build(script)
}

0 comments on commit 779b0bb

Please sign in to comment.