Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial import for a Groovy/Camel Spring examples.

  • Loading branch information...
commit ea77862ee8ef23ade626cd4f225c30c435fde94c 1 parent f32f34c
@felipeg48 authored
View
1  01-spring-camel/README.md
@@ -0,0 +1 @@
+###Spring Camel / Groovy Examples
View
19 01-spring-camel/build.gradle
@@ -0,0 +1,19 @@
+apply plugin: 'groovy'
+
+task "create-dirs" << {
+ sourceSets*.groovy.srcDirs*.each { it.mkdirs() }
+ sourceSets*.resources.srcDirs*.each { it.mkdirs() }
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ groovy 'org.codehaus.groovy:groovy-all:2.0.6'
+ compile 'org.apache.camel:camel-spring:2.10.3'
+ compile 'org.grails:grails-spring:2.2.0'
+
+ testCompile 'junit:junit:4.8.2'
+ testCompile 'org.springframework:spring-test:3.2.0.RELEASE'
+}
View
18 01-spring-camel/src/main/groovy/GroovyCamel.groovy
@@ -0,0 +1,18 @@
+
+
+import org.apache.camel.builder.RouteBuilder
+import org.apache.camel.impl.DefaultCamelContext
+import org.apache.camel.Processor
+
+def camelContext = new DefaultCamelContext()
+camelContext.addRoutes(new RouteBuilder() {
+ def void configure() {
+ from("timer://jdkTimer?period=3000")
+ .to("log://camelLogger?level=INFO")
+ .process([ process: { ex -> println("Hello World!") } ] as Processor)
+ }
+})
+camelContext.start()
+sleep 8000
+camelContext.stop()
+camelContext = null
View
12 01-spring-camel/src/main/groovy/GroovySpring.groovy
@@ -0,0 +1,12 @@
+
+
+import grails.spring.BeanBuilder
+
+
+def bb = new BeanBuilder()
+bb.loadBeans("classpath:/META-INF/spring/SpringBeans.groovy")
+
+def ctx = bb.createApplicationContext()
+
+def s = ctx.getBean("sample")
+println s
View
8 01-spring-camel/src/main/groovy/GroovySpringCamel.groovy
@@ -0,0 +1,8 @@
+import grails.spring.BeanBuilder
+
+
+def bb = new BeanBuilder()
+bb.loadBeans("classpath:/META-INF/spring/SpringCamelBeans.groovy")
+
+def ctx = bb.createApplicationContext()
+sleep 10000
View
13 01-spring-camel/src/main/groovy/com/itprosmx/spring/camel/SampleBean.groovy
@@ -0,0 +1,13 @@
+package com.itprosmx.spring.camel
+
+/**
+ *
+ * @author felipeg
+ *
+ */
+class SampleBean {
+
+ def run(){
+ println "Hello Groovy Camel"
+ }
+}
View
17 01-spring-camel/src/main/groovy/com/itprosmx/spring/camel/SampleModel.groovy
@@ -0,0 +1,17 @@
+/**
+ *
+ */
+package com.itprosmx.spring.camel
+
+import groovy.transform.ToString;
+
+/**
+ * @author felipeg
+ *
+ */
+@ToString(includeFields=true)
+class SampleModel {
+ String name
+ String phone
+ Date birthday
+}
View
10 01-spring-camel/src/main/resources/META-INF/spring/SpringBeans.groovy
@@ -0,0 +1,10 @@
+
+beans {
+
+ sample(com.itprosmx.spring.camel.SampleModel){
+ name = 'John Doe'
+ phone = '1-800-SPRING'
+ birthday = new Date().parse("yyyy/MM/dd", "2005/01/01")
+ }
+
+}
View
17 01-spring-camel/src/main/resources/META-INF/spring/SpringCamelBeans.groovy
@@ -0,0 +1,17 @@
+
+beans{
+
+ sample(com.itprosmx.spring.camel.SampleBean)
+
+ xmlns camel: 'http://camel.apache.org/schema/spring'
+ camel {
+ camelContext(id:'camelContext', trace:true) {
+ camel.'route'{
+ camel.'from'(uri:'timer://jdkTimer?period=3000') {}
+ camel.'to'(uri:'log://camelLogger?level=INFO') {}
+ camel.'to'(uri:"bean://sample?method=run") {}
+
+ }
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.