I'm thinking about something like this, first get the tokens from the message
body, then split them based on this list of tokens. psuedo code: using beans
in the route for split.
what do you think on this, was hoping for a cleaner approach. thanks!
public class AssetSplitterBean {
public List<String> splitBody(String body, Exchange exchange) {
List<String> serviceRecords = new ArrayList<String>();
List<String> tokens =
(List<String>)exchange.getProperty("splitTokens");
for ( String token : tokens ){
String[] records = body.split(token);
for (String record : records) {
serviceRecords.add(record);
}
}
return serviceRecords;
}
public Object initSplitTokens(Exchange exchange) {
exchange.setProperty("splitTokens", new ArrayList<String>());
return exchange.getIn().getBody();
}
public Object addToken(Exchange exchange) {
String payload = exchange.getIn().getBody(String.class);
Scanner sc = new Scanner(payload).useDelimiter("\r\n|\n");
while(sc.hasNextLine()){
String line = sc.nextLine();
String[] aa = line.split(",");
List<String> tokens =
(List<String>)exchange.getProperty("splitTokens");
if ( !tokens.contains(aa[0]) ){
((List<String>)exchange.getProperty("splitTokens")).add(aa[0]);
}
} sc.close();
return null;
}
}
-----
Gary Lee Mills
--
View this message in context:
http://camel.465427.n5.nabble.com/camel-splitter-tp5798339p5798365.html
Sent from the Camel - Users mailing list archive at Nabble.com.