1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.construct.builder; |
12 | |
|
13 | |
import java.util.List; |
14 | |
|
15 | |
import org.mule.MessageExchangePattern; |
16 | |
import org.mule.api.MuleContext; |
17 | |
import org.mule.api.MuleException; |
18 | |
import org.mule.api.endpoint.EndpointBuilder; |
19 | |
import org.mule.api.endpoint.OutboundEndpoint; |
20 | |
import org.mule.api.processor.MessageProcessor; |
21 | |
import org.mule.construct.AbstractFlowConstruct; |
22 | |
|
23 | |
@SuppressWarnings("unchecked") |
24 | 0 | public abstract class AbstractFlowConstructWithSingleInboundAndOutboundEndpointBuilder<T extends AbstractFlowConstructBuilder, F extends AbstractFlowConstruct> |
25 | |
extends AbstractFlowConstructWithSingleInboundEndpointBuilder<T, F> |
26 | |
{ |
27 | |
private OutboundEndpoint outboundEndpoint; |
28 | |
private EndpointBuilder outboundEndpointBuilder; |
29 | |
private String outboundAddress; |
30 | |
|
31 | |
|
32 | |
protected List<MessageProcessor> outboundTransformers; |
33 | |
protected List<MessageProcessor> outboundResponseTransformers; |
34 | |
|
35 | |
public T outboundEndpoint(OutboundEndpoint outboundEndpoint) |
36 | |
{ |
37 | 0 | this.outboundEndpoint = outboundEndpoint; |
38 | 0 | return (T) this; |
39 | |
} |
40 | |
|
41 | |
public T outboundEndpoint(EndpointBuilder outboundEndpointBuilder) |
42 | |
{ |
43 | 0 | this.outboundEndpointBuilder = outboundEndpointBuilder; |
44 | 0 | return (T) this; |
45 | |
} |
46 | |
|
47 | |
public T outboundAddress(String outboundAddress) |
48 | |
{ |
49 | 0 | this.outboundAddress = outboundAddress; |
50 | 0 | return (T) this; |
51 | |
} |
52 | |
|
53 | |
protected OutboundEndpoint getOrBuildOutboundEndpoint(MuleContext muleContext) throws MuleException |
54 | |
{ |
55 | 0 | if (outboundEndpoint != null) |
56 | |
{ |
57 | 0 | return outboundEndpoint; |
58 | |
} |
59 | |
|
60 | 0 | if (outboundEndpointBuilder == null) |
61 | |
{ |
62 | 0 | outboundEndpointBuilder = muleContext.getEndpointFactory().getEndpointBuilder( |
63 | |
outboundAddress); |
64 | |
} |
65 | |
|
66 | 0 | outboundEndpointBuilder.setExchangePattern(getOutboundMessageExchangePattern()); |
67 | |
|
68 | 0 | if (outboundTransformers != null) |
69 | |
{ |
70 | 0 | outboundEndpointBuilder.setMessageProcessors(outboundTransformers); |
71 | |
} |
72 | |
|
73 | 0 | if (outboundResponseTransformers != null) |
74 | |
{ |
75 | 0 | outboundEndpointBuilder.setResponseMessageProcessors(outboundResponseTransformers); |
76 | |
} |
77 | |
|
78 | 0 | doConfigureOutboundEndpointBuilder(muleContext, outboundEndpointBuilder); |
79 | |
|
80 | 0 | return outboundEndpointBuilder.buildOutboundEndpoint(); |
81 | |
} |
82 | |
|
83 | |
protected abstract MessageExchangePattern getOutboundMessageExchangePattern(); |
84 | |
|
85 | |
protected void doConfigureOutboundEndpointBuilder(MuleContext muleContext, EndpointBuilder endpointBuilder) |
86 | |
{ |
87 | |
|
88 | 0 | } |
89 | |
|
90 | |
} |