Coverage Report - org.apache.camel.component.cxf.CxfExchange
 
Classes in this File Line Coverage Branch Coverage Complexity
CxfExchange
27% 
0% 
0
 
 1  
 /**
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.camel.component.cxf;
 18  
 
 19  
 import org.apache.camel.CamelContext;
 20  
 import org.apache.camel.impl.DefaultExchange;
 21  
 import org.apache.cxf.message.Exchange;
 22  
 import org.apache.cxf.message.Message;
 23  
 import org.apache.cxf.transport.Conduit;
 24  
 import org.apache.cxf.transport.Destination;
 25  
 
 26  
 /**
 27  
  * An {@link Exchange} for working with Apache CXF which expoes the underlying
 28  
  * CXF messages via {@link #getInMessage()} and {@link #getOutMessage()} along with the
 29  
  * {@link #getExchange()} 
 30  
  *
 31  
  * @version $Revision: 563665 $
 32  
  */
 33  5
 public class CxfExchange extends DefaultExchange {
 34  
     private final CxfBinding binding;
 35  
     private Exchange exchange;
 36  
 
 37  
     public CxfExchange(CamelContext context, CxfBinding binding) {
 38  1
         super(context);
 39  1
         this.binding = binding;
 40  1
     }
 41  
 
 42  
     public CxfExchange(CamelContext context, CxfBinding binding, Exchange exchange) {
 43  0
         super(context);
 44  0
         this.binding = binding;
 45  0
         this.exchange = exchange;
 46  
 
 47  0
         setIn(new CxfMessage(exchange.getInMessage()));
 48  0
         setOut(new CxfMessage(exchange.getOutMessage()));
 49  0
         setFault(new CxfMessage(exchange.getInFaultMessage()));
 50  0
     }
 51  
 
 52  
     public CxfExchange(CamelContext context, CxfBinding binding, Message inMessage) {
 53  0
         super(context);
 54  0
         this.binding = binding;
 55  0
         this.exchange = inMessage.getExchange();
 56  
 
 57  0
         setIn(new CxfMessage(inMessage));
 58  0
         if (exchange != null) {
 59  0
             setOut(new CxfMessage(exchange.getOutMessage()));
 60  0
             setFault(new CxfMessage(exchange.getInFaultMessage()));
 61  
         }
 62  0
     }
 63  
 
 64  
     @Override
 65  
     public CxfMessage getIn() {
 66  2
         return (CxfMessage) super.getIn();
 67  
     }
 68  
 
 69  
     @Override
 70  
     public CxfMessage getOut() {
 71  2
         return (CxfMessage) super.getOut();
 72  
     }
 73  
 
 74  
     @Override
 75  
     public CxfMessage getOut(boolean lazyCreate) {
 76  2
         return (CxfMessage) super.getOut(lazyCreate);
 77  
     }
 78  
 
 79  
     @Override
 80  
     public CxfMessage getFault() {
 81  0
         return (CxfMessage) super.getFault();
 82  
     }
 83  
 
 84  
     /**
 85  
      * @return the Camel <-> JBI binding
 86  
      */
 87  
     public CxfBinding getBinding() {
 88  0
         return binding;
 89  
     }
 90  
 
 91  
     // Expose CXF APIs directly on the exchange
 92  
     //-------------------------------------------------------------------------
 93  
 
 94  
     /**
 95  
      * Returns the underlying CXF message exchange for an inbound exchange
 96  
      * or null for outbound messages
 97  
      *
 98  
      * @return the inbound message exchange
 99  
      */
 100  
     public Exchange getExchange() {
 101  0
         return exchange;
 102  
     }
 103  
 
 104  
     public Message getInMessage() {
 105  0
         return getIn().getMessage();
 106  
     }
 107  
 
 108  
     public Message getOutMessage() {
 109  0
         return getOut().getMessage();
 110  
     }
 111  
 
 112  
     public Message getOutFaultMessage() {
 113  0
         return getExchange().getOutFaultMessage();
 114  
     }
 115  
 
 116  
     public Message getInFaultMessage() {
 117  0
         return getExchange().getInFaultMessage();
 118  
     }
 119  
 
 120  
     public Destination getDestination() {
 121  0
         return getExchange().getDestination();
 122  
     }
 123  
 
 124  
     public Conduit getConduit(Message message) {
 125  0
         return getExchange().getConduit(message);
 126  
     }
 127  
 
 128  
     @Override
 129  
     protected CxfMessage createInMessage() {
 130  1
         return new CxfMessage();
 131  
     }
 132  
 
 133  
     @Override
 134  
     protected CxfMessage createOutMessage() {
 135  1
         return new CxfMessage();
 136  
     }
 137  
 }