| 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.Exchange; |
| 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 |
1 |
private static final transient Log log = LogFactory.getLog(CamelJbiEndpoint.class); |
| 34 |
1 |
private static final QName SERVICE_NAME = new QName("http://camel.apache.org/service", "CamelEndpointComponent"); |
| 35 |
|
private Endpoint camelEndpoint; |
| 36 |
|
private JbiBinding binding; |
| 37 |
|
private Processor processor; |
| 38 |
|
|
| 39 |
|
public CamelJbiEndpoint(ServiceUnit serviceUnit, QName service, String endpoint, Endpoint camelEndpoint, JbiBinding binding, Processor processor) { |
| 40 |
2 |
super(serviceUnit, service, endpoint); |
| 41 |
2 |
this.processor = processor; |
| 42 |
2 |
this.camelEndpoint = camelEndpoint; |
| 43 |
2 |
this.binding = binding; |
| 44 |
2 |
} |
| 45 |
|
|
| 46 |
|
public CamelJbiEndpoint(ServiceUnit serviceUnit, Endpoint camelEndpoint, JbiBinding binding, Processor processor) { |
| 47 |
1 |
this(serviceUnit, SERVICE_NAME, camelEndpoint.getEndpointUri(), camelEndpoint, binding, processor); |
| 48 |
1 |
} |
| 49 |
|
|
| 50 |
|
protected void processInOnly(MessageExchange exchange, NormalizedMessage in) throws Exception { |
| 51 |
2 |
if (log.isDebugEnabled()) { |
| 52 |
0 |
log.debug("Received exchange: " + exchange); |
| 53 |
|
} |
| 54 |
2 |
JbiExchange camelExchange = new JbiExchange(camelEndpoint.getContext(), binding, exchange); |
| 55 |
2 |
processor.process(camelExchange); |
| 56 |
2 |
} |
| 57 |
|
|
| 58 |
|
protected void processInOut(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws Exception { |
| 59 |
0 |
if (log.isDebugEnabled()) { |
| 60 |
0 |
log.debug("Received exchange: " + exchange); |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
0 |
} |
| 66 |
|
} |