| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.camel.processor; |
| 18 |
|
|
| 19 |
|
import java.util.Comparator; |
| 20 |
|
import java.util.List; |
| 21 |
|
import java.util.Set; |
| 22 |
|
import java.util.TreeSet; |
| 23 |
|
|
| 24 |
|
import org.apache.camel.Endpoint; |
| 25 |
|
import org.apache.camel.Exchange; |
| 26 |
|
import org.apache.camel.Expression; |
| 27 |
|
import org.apache.camel.Processor; |
| 28 |
|
import org.apache.camel.util.ExpressionComparator; |
| 29 |
|
import org.apache.camel.util.ExpressionListComparator; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
public class Resequencer extends BatchProcessor { |
| 38 |
|
public Resequencer(Endpoint endpoint, Processor processor, Expression<Exchange> expression) { |
| 39 |
0 |
this(endpoint, processor, createSet(expression)); |
| 40 |
0 |
} |
| 41 |
|
|
| 42 |
|
public Resequencer(Endpoint endpoint, Processor processor, List<Expression> expressions) { |
| 43 |
3 |
this(endpoint, processor, createSet(expressions)); |
| 44 |
3 |
} |
| 45 |
|
|
| 46 |
|
public Resequencer(Endpoint endpoint, Processor processor, Set<Exchange> collection) { |
| 47 |
3 |
super(endpoint, processor, collection); |
| 48 |
3 |
} |
| 49 |
|
|
| 50 |
|
@Override |
| 51 |
|
public String toString() { |
| 52 |
6 |
return "Resequencer[to: " + getProcessor() + "]"; |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
protected static Set<Exchange> createSet(Expression<Exchange> expression) { |
| 59 |
3 |
return createSet(new ExpressionComparator<Exchange>(expression)); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
protected static Set<Exchange> createSet(List<Expression> expressions) { |
| 63 |
3 |
if (expressions.size() == 1) { |
| 64 |
3 |
return createSet(expressions.get(0)); |
| 65 |
|
} |
| 66 |
0 |
return createSet(new ExpressionListComparator(expressions)); |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
protected static Set<Exchange> createSet(Comparator<? super Exchange> comparator) { |
| 70 |
3 |
return new TreeSet<Exchange>(comparator); |
| 71 |
|
} |
| 72 |
|
} |