1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.routing; |
8 | |
|
9 | |
import org.mule.api.MuleContext; |
10 | |
import org.mule.api.MuleMessage; |
11 | |
import org.mule.api.context.MuleContextAware; |
12 | |
import org.mule.api.routing.MessageInfoMapping; |
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | 0 | public class ExpressionMessageInfoMapping implements MessageInfoMapping, MuleContextAware |
18 | |
{ |
19 | |
private String correlationIdExpression; |
20 | |
private String messageIdExpression; |
21 | |
private MuleContext muleContext; |
22 | |
|
23 | |
public void setMuleContext(MuleContext context) |
24 | |
{ |
25 | 0 | this.muleContext = context; |
26 | 0 | } |
27 | |
|
28 | |
public String getMessageId(MuleMessage message) |
29 | |
{ |
30 | 0 | return (String) muleContext.getExpressionManager().evaluate(getMessageIdExpression(), message, true); |
31 | |
} |
32 | |
|
33 | |
public String getCorrelationId(MuleMessage message) |
34 | |
{ |
35 | 0 | String id = (String) muleContext.getExpressionManager().evaluate(getCorrelationIdExpression(), message, false); |
36 | 0 | if (id == null) |
37 | |
{ |
38 | 0 | id = getMessageId(message); |
39 | |
} |
40 | 0 | return id; |
41 | |
} |
42 | |
|
43 | |
public String getCorrelationIdExpression() |
44 | |
{ |
45 | 0 | return correlationIdExpression; |
46 | |
} |
47 | |
|
48 | |
public void setCorrelationIdExpression(String correlationIdExpression) |
49 | |
{ |
50 | 0 | this.correlationIdExpression = correlationIdExpression; |
51 | 0 | } |
52 | |
|
53 | |
public String getMessageIdExpression() |
54 | |
{ |
55 | 0 | return messageIdExpression; |
56 | |
} |
57 | |
|
58 | |
public void setMessageIdExpression(String messageIdExpression) |
59 | |
{ |
60 | 0 | this.messageIdExpression = messageIdExpression; |
61 | 0 | } |
62 | |
} |