1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.endpoint; |
12 | |
|
13 | |
import org.mule.MessageExchangePattern; |
14 | |
import org.mule.api.MuleContext; |
15 | |
import org.mule.api.MuleEvent; |
16 | |
import org.mule.api.MuleException; |
17 | |
import org.mule.api.config.MuleProperties; |
18 | |
import org.mule.api.construct.FlowConstruct; |
19 | |
import org.mule.api.context.MuleContextAware; |
20 | |
import org.mule.api.endpoint.EndpointMessageProcessorChainFactory; |
21 | |
import org.mule.api.endpoint.EndpointURI; |
22 | |
import org.mule.api.endpoint.OutboundEndpoint; |
23 | |
import org.mule.api.lifecycle.Initialisable; |
24 | |
import org.mule.api.processor.MessageProcessor; |
25 | |
import org.mule.api.retry.RetryPolicyTemplate; |
26 | |
import org.mule.api.transaction.TransactionConfig; |
27 | |
import org.mule.api.transport.Connector; |
28 | |
import org.mule.transport.AbstractConnector; |
29 | |
import org.mule.util.StringUtils; |
30 | |
|
31 | |
import java.util.ArrayList; |
32 | |
import java.util.Arrays; |
33 | |
import java.util.List; |
34 | |
import java.util.Map; |
35 | |
|
36 | |
public class DefaultOutboundEndpoint extends AbstractEndpoint implements OutboundEndpoint |
37 | |
{ |
38 | |
private static final long serialVersionUID = 8860985949279708638L; |
39 | |
|
40 | |
private List<String> responseProperties; |
41 | |
|
42 | |
public DefaultOutboundEndpoint(Connector connector, |
43 | |
EndpointURI endpointUri, |
44 | |
String name, |
45 | |
Map properties, |
46 | |
TransactionConfig transactionConfig, |
47 | |
boolean deleteUnacceptedMessage, |
48 | |
MessageExchangePattern messageExchangePattern, |
49 | |
int responseTimeout, |
50 | |
String initialState, |
51 | |
String endpointEncoding, |
52 | |
String endpointBuilderName, |
53 | |
MuleContext muleContext, |
54 | |
RetryPolicyTemplate retryPolicyTemplate, |
55 | |
String responsePropertiesList, |
56 | |
EndpointMessageProcessorChainFactory messageProcessorsFactory, |
57 | |
List <MessageProcessor> messageProcessors, |
58 | |
List <MessageProcessor> responseMessageProcessors, |
59 | |
boolean disableTransportTransformer, |
60 | |
String endpointMimeType) |
61 | |
{ |
62 | 0 | super(connector, endpointUri, name, properties, transactionConfig, |
63 | |
deleteUnacceptedMessage, messageExchangePattern, responseTimeout, initialState, |
64 | |
endpointEncoding, endpointBuilderName, muleContext, retryPolicyTemplate, |
65 | |
messageProcessorsFactory, messageProcessors, responseMessageProcessors, disableTransportTransformer, endpointMimeType); |
66 | |
|
67 | 0 | responseProperties = new ArrayList<String>(); |
68 | |
|
69 | 0 | responseProperties.add(MuleProperties.MULE_CORRELATION_ID_PROPERTY); |
70 | 0 | responseProperties.add(MuleProperties.MULE_CORRELATION_GROUP_SIZE_PROPERTY); |
71 | 0 | responseProperties.add(MuleProperties.MULE_CORRELATION_SEQUENCE_PROPERTY); |
72 | 0 | responseProperties.add(MuleProperties.MULE_SESSION_PROPERTY); |
73 | |
|
74 | 0 | String[] props = StringUtils.splitAndTrim(responsePropertiesList, ","); |
75 | 0 | if (props != null) |
76 | |
{ |
77 | 0 | responseProperties.addAll(Arrays.asList(props)); |
78 | |
} |
79 | 0 | } |
80 | |
|
81 | |
public List<String> getResponseProperties() |
82 | |
{ |
83 | 0 | return responseProperties; |
84 | |
} |
85 | |
|
86 | |
public MuleEvent process(MuleEvent event) throws MuleException |
87 | |
{ |
88 | 0 | return getMessageProcessorChain(event.getFlowConstruct()).process(event); |
89 | |
} |
90 | |
|
91 | |
@Override |
92 | |
protected MessageProcessor createMessageProcessorChain(FlowConstruct flowContruct) throws MuleException |
93 | |
{ |
94 | 0 | EndpointMessageProcessorChainFactory factory = getMessageProcessorsFactory(); |
95 | 0 | MessageProcessor chain = factory.createOutboundMessageProcessorChain(this, flowContruct, |
96 | |
((AbstractConnector) getConnector()).createDispatcherMessageProcessor(this)); |
97 | |
|
98 | 0 | if (chain instanceof MuleContextAware) |
99 | |
{ |
100 | 0 | ((MuleContextAware) chain).setMuleContext(getMuleContext()); |
101 | |
} |
102 | 0 | if (chain instanceof Initialisable) |
103 | |
{ |
104 | 0 | ((Initialisable) chain).initialise(); |
105 | |
} |
106 | |
|
107 | 0 | return chain; |
108 | |
} |
109 | |
} |