1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
package org.apache.camel.component.jbi; |
14 |
|
|
15 |
|
import org.apache.camel.Endpoint; |
16 |
|
import org.apache.camel.Processor; |
17 |
|
import org.apache.camel.FailedToCreateProducerException; |
18 |
|
import org.apache.commons.logging.Log; |
19 |
|
import org.apache.commons.logging.LogFactory; |
20 |
|
import org.apache.servicemix.common.ServiceUnit; |
21 |
|
import org.apache.servicemix.common.endpoints.ProviderEndpoint; |
22 |
|
|
23 |
|
import javax.jbi.messaging.MessageExchange; |
24 |
|
import javax.jbi.messaging.NormalizedMessage; |
25 |
|
import javax.xml.namespace.QName; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
public class CamelJbiEndpoint extends ProviderEndpoint { |
33 |
0 |
public static final QName SERVICE_NAME = new QName("http://activemq.apache.org/camel/schema/jbi", "endpoint"); |
34 |
|
|
35 |
0 |
private static final transient Log log = LogFactory.getLog(CamelJbiEndpoint.class); |
36 |
|
private Endpoint camelEndpoint; |
37 |
|
private JbiBinding binding; |
38 |
|
private Processor camelProcessor; |
39 |
|
|
40 |
|
public CamelJbiEndpoint(ServiceUnit serviceUnit, QName service, String endpoint, Endpoint camelEndpoint, JbiBinding binding, Processor camelProcessor) { |
41 |
0 |
super(serviceUnit, service, endpoint); |
42 |
0 |
this.camelProcessor = camelProcessor; |
43 |
0 |
this.camelEndpoint = camelEndpoint; |
44 |
0 |
this.binding = binding; |
45 |
0 |
} |
46 |
|
|
47 |
|
public CamelJbiEndpoint(ServiceUnit serviceUnit, Endpoint camelEndpoint, JbiBinding binding, Processor camelProcesso) { |
48 |
0 |
this(serviceUnit, SERVICE_NAME, camelEndpoint.getEndpointUri(), camelEndpoint, binding, camelProcesso); |
49 |
0 |
} |
50 |
|
|
51 |
|
protected void processInOnly(MessageExchange exchange, NormalizedMessage in) throws Exception { |
52 |
0 |
if (log.isDebugEnabled()) { |
53 |
0 |
log.debug("Received exchange: " + exchange); |
54 |
|
} |
55 |
0 |
JbiExchange camelExchange = new JbiExchange(camelEndpoint.getContext(), binding, exchange); |
56 |
0 |
camelProcessor.process(camelExchange); |
57 |
0 |
} |
58 |
|
|
59 |
|
protected void processInOut(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws Exception { |
60 |
0 |
if (log.isDebugEnabled()) { |
61 |
0 |
log.debug("Received exchange: " + exchange); |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
0 |
} |
67 |
|
} |