1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.model.pipeline; |
12 | |
|
13 | |
import org.mule.api.MuleEvent; |
14 | |
import org.mule.api.MuleException; |
15 | |
import org.mule.api.MuleMessage; |
16 | |
import org.mule.api.MuleRuntimeException; |
17 | |
import org.mule.api.component.Component; |
18 | |
import org.mule.api.transport.DispatchException; |
19 | |
import org.mule.component.SimpleCallableJavaComponent; |
20 | |
import org.mule.config.i18n.CoreMessages; |
21 | |
import org.mule.model.direct.DirectService; |
22 | |
|
23 | |
public class PipelineService extends DirectService |
24 | |
{ |
25 | |
|
26 | |
|
27 | |
|
28 | |
private static final long serialVersionUID = -2788210157354765190L; |
29 | |
|
30 | |
public PipelineService() |
31 | |
{ |
32 | 0 | super(); |
33 | 0 | } |
34 | |
|
35 | |
protected MuleMessage doSend(MuleEvent event) throws MuleException |
36 | |
{ |
37 | |
try |
38 | |
{ |
39 | 0 | MuleMessage result = component.onCall(event); |
40 | 0 | MuleMessage returnMessage = null; |
41 | 0 | returnMessage = (MuleMessage) result; |
42 | |
|
43 | 0 | if (!event.isStopFurtherProcessing()) |
44 | |
{ |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | 0 | if (outboundRouter.hasEndpoints()) |
51 | |
{ |
52 | 0 | MuleMessage outboundReturnMessage = outboundRouter.route(returnMessage, event.getSession(), |
53 | |
event.isSynchronous()); |
54 | 0 | if (outboundReturnMessage != null) |
55 | |
{ |
56 | 0 | returnMessage = outboundReturnMessage; |
57 | |
} |
58 | 0 | } |
59 | |
else |
60 | |
{ |
61 | 0 | logger.debug("Outbound router on service '" + name + "' doesn't have any endpoints configured."); |
62 | |
} |
63 | |
} |
64 | |
|
65 | 0 | return returnMessage; |
66 | |
} |
67 | 0 | catch (Exception e) |
68 | |
{ |
69 | 0 | throw new DispatchException(event.getMessage(), event.getEndpoint(), e); |
70 | |
} |
71 | |
} |
72 | |
|
73 | |
protected void doDispatch(MuleEvent event) throws MuleException |
74 | |
{ |
75 | 0 | sendEvent(event); |
76 | 0 | } |
77 | |
|
78 | |
|
79 | |
public void setComponent(Component component) |
80 | |
{ |
81 | 0 | if (!(component instanceof SimpleCallableJavaComponent)) |
82 | |
{ |
83 | 0 | throw new MuleRuntimeException(CoreMessages.objectNotOfCorrectType(component.getClass(), |
84 | |
SimpleCallableJavaComponent.class)); |
85 | |
} |
86 | 0 | super.setComponent(component); |
87 | 0 | } |
88 | |
|
89 | |
} |