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