Created
March 15, 2011 10:03
-
-
Save ketankhairnar/870534 to your computer and use it in GitHub Desktop.
Abstract Camel Processor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class CamelProcessor<T> implements Processor | |
{ | |
protected void process(Exchange exchange, ResultMapper<T> mapper) throws Exception | |
{ | |
try | |
{ | |
ArrayList<T> payloads = new ArrayList<T>(); | |
ArrayList<HashMap<String, Object>> data = exchange.getIn().getBody(ArrayList.class); | |
if (data != null) | |
{ | |
for (HashMap<String, Object> obj : data) | |
{ | |
payloads.add(mapper.valueOf(obj)); | |
} | |
} | |
exchange.getIn().setBody(payloads); | |
} | |
catch (Exception e) | |
{ | |
// TODO common error handling | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment