Permalink
Browse files

First attempt at getting the files to write

  • Loading branch information...
1 parent fe047f9 commit ed701831507c600ea4dce7cd3cf6b8c93e11a6e9 @christian-posta committed Aug 25, 2011
View
@@ -1,3 +1,5 @@
/**/target
/**/*.iml
.idea/
+deck-of-cards/data/cards
+deck-of-cards/src/.DS_Store
@@ -1,3 +1,4 @@
firstuser
seconduser
-thirduser
+thirduser
+fourthuser
@@ -1,7 +1,10 @@
package com.christianposta.fuse.integration;
+import com.christianposta.fuse.Player;
+import com.thoughtworks.xstream.XStream;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
+import org.apache.camel.dataformat.xstream.XStreamDataFormat;
import org.apache.camel.spring.SpringRouteBuilder;
/**
@@ -14,11 +17,19 @@
public class CardRoutingDefinition extends SpringRouteBuilder {
@Override
public void configure() throws Exception {
- from("file:data/users?noop=true").process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- System.out.println("Trying to move a file");
- System.out.println(exchange.getIn().getHeader("CamelFileName"));
- }
- });
+ XStream xStream = new XStream();
+ xStream.processAnnotations(Player.class);
+ XStreamDataFormat dataFormat = new XStreamDataFormat();
+ dataFormat.setXstream(xStream);
+ from("file:data/users?noop=true")
+ .split(body(String.class).tokenize("\n"), new PlayerAggregationStrategy())
+ .log("Player names: ${body}")
+ .bean(StringToPlayerTranslator.class)
+ .end()
+ .log("What we have so far \"${body}\"")
+ .beanRef("dealer")
+ .split(body())
+ .marshal(dataFormat).setHeader(Exchange.FILE_NAME, xpath("/player/name/text()"))
+ .to("file:data/cards");
}
}
@@ -9,6 +9,7 @@
http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="routingBean" class="com.christianposta.fuse.integration.CardRoutingDefinition" />
+ <bean id="dealer" class="com.christianposta.fuse.Dealer" />
<camel:camelContext>
<camel:routeBuilder ref="routingBean" />
@@ -3,8 +3,6 @@
import com.christianposta.fuse.Player;
import com.thoughtworks.xstream.XStream;
import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.dataformat.xstream.XStreamDataFormat;

0 comments on commit ed70183

Please sign in to comment.