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