1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.processor.chain; |
12 | |
|
13 | |
import org.mule.DefaultMuleEvent; |
14 | |
import org.mule.OptimizedRequestContext; |
15 | |
import org.mule.api.MuleEvent; |
16 | |
import org.mule.api.MuleException; |
17 | |
import org.mule.api.construct.FlowConstruct; |
18 | |
import org.mule.api.endpoint.OutboundEndpoint; |
19 | |
import org.mule.api.processor.MessageProcessor; |
20 | |
import org.mule.construct.SimpleFlowConstruct; |
21 | |
|
22 | |
import java.util.Arrays; |
23 | |
import java.util.List; |
24 | |
|
25 | |
public class DefaultMessageProcessorChain extends AbstractMessageProcessorChain |
26 | |
{ |
27 | |
|
28 | |
public DefaultMessageProcessorChain(List<MessageProcessor> processors) |
29 | |
{ |
30 | 0 | super(null, processors); |
31 | 0 | } |
32 | |
|
33 | |
public DefaultMessageProcessorChain(MessageProcessor... processors) |
34 | |
{ |
35 | 0 | super(null, Arrays.asList(processors)); |
36 | 0 | } |
37 | |
|
38 | |
public DefaultMessageProcessorChain(String name, List<MessageProcessor> processors) |
39 | |
{ |
40 | 0 | super(name, processors); |
41 | 0 | } |
42 | |
|
43 | |
public DefaultMessageProcessorChain(String name, MessageProcessor... processors) |
44 | |
{ |
45 | 0 | super(name, Arrays.asList(processors)); |
46 | 0 | } |
47 | |
|
48 | |
protected MuleEvent doProcess(MuleEvent event) throws MuleException |
49 | |
{ |
50 | 0 | FlowConstruct flowConstruct = event.getFlowConstruct(); |
51 | 0 | MuleEvent currentEvent = event; |
52 | |
MuleEvent resultEvent; |
53 | 0 | for (MessageProcessor processor : processors) |
54 | |
{ |
55 | |
|
56 | |
|
57 | 0 | if (processor instanceof OutboundEndpoint) |
58 | |
{ |
59 | 0 | currentEvent = new DefaultMuleEvent(currentEvent.getMessage(), (OutboundEndpoint) processor, |
60 | |
currentEvent.getSession()); |
61 | |
} |
62 | 0 | resultEvent = processor.process(currentEvent); |
63 | 0 | if (resultEvent != null) |
64 | |
{ |
65 | 0 | currentEvent = resultEvent; |
66 | |
} |
67 | |
else |
68 | |
{ |
69 | 0 | if (flowConstruct instanceof SimpleFlowConstruct) |
70 | |
{ |
71 | 0 | currentEvent = OptimizedRequestContext.criticalSetEvent(currentEvent); |
72 | |
} |
73 | |
else |
74 | |
{ |
75 | 0 | return null; |
76 | |
} |
77 | |
} |
78 | |
} |
79 | 0 | return currentEvent; |
80 | |
} |
81 | |
|
82 | |
} |