Skip to content

Commit

Permalink
GH-4: Added example processor that is in fact a Spring bean
Browse files Browse the repository at this point in the history
  • Loading branch information
padcom committed Dec 3, 2011
1 parent 7f154cc commit 13125a0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions grails-app/conf/spring/resources.groovy
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Place your Spring DSL code here
beans = {
myProcessor(org.example.MyProcessor) {
textProviderService = ref("textProviderService")
}
}
3 changes: 2 additions & 1 deletion grails-app/routes/ExampleRoute.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class ExampleRoute {
def textProviderService

This comment has been minimized.

Copy link
@padcom

padcom Dec 3, 2011

Author Owner

Please dissregard this declaration - it was a mistake...

def configure = {
// example:
// from('seda:input').to('stream:out')
from('activemq:example').to('bean:exampleService?method=receive')
from('activemq:example').processRef("myProcessor").to('bean:exampleService?method=receive')
}
}
7 changes: 7 additions & 0 deletions grails-app/services/org/example/TextProviderService.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.example

class TextProviderService {
String getText() {
"This is a text from service"
}
}
20 changes: 20 additions & 0 deletions src/java/org/example/MyProcessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.example;

import org.apache.camel.*;

public class MyProcessor implements Processor {
private TextProviderService textProviderService;

public void process(Exchange exchange) throws Exception {
String body = exchange.getIn().getBody(String.class);
exchange.getOut().setBody("Processed: " + textProviderService.getText() + " - org: " + body);
}

public TextProviderService getTextProviderService(TextProviderService textProviderService) {
return this.textProviderService;
}

public void setTextProviderService(TextProviderService textProviderService) {
this.textProviderService = textProviderService;
}
}

0 comments on commit 13125a0

Please sign in to comment.