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