Coverage Report - org.apache.camel.component.jbi.CamelJbiEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
CamelJbiEndpoint
76% 
50% 
1.5
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
 3  
  * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
 4  
  * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
 5  
  * License. You may obtain a copy of the License at
 6  
  * 
 7  
  * http://www.apache.org/licenses/LICENSE-2.0
 8  
  * 
 9  
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 10  
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 11  
  * specific language governing permissions and limitations under the License.
 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  
  * A JBI endpoint which when invoked will delegate to a Camel endpoint
 29  
  *
 30  
  * @version $Revision: 426415 $
 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  
          * ToDo
 64  
          */
 65  0
     }
 66  
 }