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