1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.routing.correlation; |
12 | |
|
13 | |
import org.mule.api.MuleMessage; |
14 | |
import org.mule.api.config.MuleProperties; |
15 | |
import org.mule.expression.MessageHeaderExpressionEvaluator; |
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | 0 | public class CorrelationPropertiesExpressionEvaluator extends MessageHeaderExpressionEvaluator |
26 | |
{ |
27 | |
@Override |
28 | |
public final Object evaluate(String name, MuleMessage message) |
29 | |
{ |
30 | 0 | Object result = null; |
31 | 0 | if (message != null) |
32 | |
{ |
33 | 0 | if (MuleProperties.MULE_CORRELATION_ID_PROPERTY.equals(name)) |
34 | |
{ |
35 | 0 | result = getCorrelationId(message); |
36 | |
} |
37 | 0 | else if (MuleProperties.MULE_MESSAGE_ID_PROPERTY.equals(name)) |
38 | |
{ |
39 | 0 | result = getMessageId(message); |
40 | |
} |
41 | |
else |
42 | |
{ |
43 | 0 | throw new IllegalArgumentException("Property name: " + name |
44 | |
+ " not recognised by the Correlation Property Extractor"); |
45 | |
} |
46 | 0 | if (result == null) |
47 | |
{ |
48 | 0 | throw new IllegalArgumentException( |
49 | |
"Property Extractor cannot return a null value. Extractor is: " + getClass().getName()); |
50 | |
} |
51 | |
} |
52 | |
else |
53 | |
{ |
54 | 0 | return super.evaluate(name, message); |
55 | |
} |
56 | 0 | return result; |
57 | |
} |
58 | |
|
59 | |
public String getMessageId(MuleMessage message) |
60 | |
{ |
61 | 0 | return message.getUniqueId(); |
62 | |
} |
63 | |
|
64 | |
public String getCorrelationId(MuleMessage message) |
65 | |
{ |
66 | 0 | String id = message.getCorrelationId(); |
67 | 0 | if (id == null) |
68 | |
{ |
69 | 0 | id = message.getUniqueId(); |
70 | |
} |
71 | 0 | return id; |
72 | |
} |
73 | |
} |