×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: XML
Posted by: Jonathan Vila López
Added: May 27, 2014 2:01 PM
Views: 16
Tags: camel
agregator
  1. class ArrayListAgregador {
  2.  
  3.     public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
  4.         Object newBody = newExchange.getIn().getBody();
  5.         ArrayList<Object> list = null;
  6.         if (oldExchange == null) {
  7.             list = new ArrayList<Object>();
  8.             list.add(newBody);
  9.             newExchange.getIn().setBody(list);
  10.             return newExchange;
  11.         } else {
  12.             list = oldExchange.getIn().getBody(ArrayList.class);
  13.             list.add(newBody);
  14.             return oldExchange;
  15.         }
  16.     }
  17. }