Coverage Report - org.apache.camel.component.jbi.JbiExchange
 
Classes in this File Line Coverage Branch Coverage Complexity
JbiExchange
0% 
N/A 
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.jbi;
 19  
 
 20  
 import org.apache.camel.CamelContext;
 21  
 import org.apache.camel.Exchange;
 22  
 import org.apache.camel.impl.DefaultExchange;
 23  
 
 24  
 import javax.jbi.messaging.MessageExchange;
 25  
 import javax.jbi.messaging.NormalizedMessage;
 26  
 
 27  
 /**
 28  
  * An {@link Exchange} working with JBI which exposes the underlying JBI features such as the
 29  
  * JBI {@link #getMessageExchange()}, {@link #getInMessage()} and {@link #getOutMessage()} 
 30  
  *
 31  
  * @version $Revision: 550760 $
 32  
  */
 33  0
 public class JbiExchange extends DefaultExchange {
 34  
     private final JbiBinding binding;
 35  
     private MessageExchange messageExchange;
 36  
 
 37  
     public JbiExchange(CamelContext context, JbiBinding binding) {
 38  0
         super(context);
 39  0
         this.binding = binding;
 40  0
     }
 41  
 
 42  
     public JbiExchange(CamelContext context, JbiBinding binding, MessageExchange messageExchange) {
 43  0
         super(context);
 44  0
         this.binding = binding;
 45  0
         this.messageExchange = messageExchange;
 46  
 
 47  
         // TODO we could maybe use the typesafe APIs of different derived APIs from JBI 
 48  0
         setIn(new JbiMessage(messageExchange.getMessage("in")));
 49  0
         setOut(new JbiMessage(messageExchange.getMessage("out")));
 50  0
         setFault(new JbiMessage(messageExchange.getMessage("fault")));
 51  0
     }
 52  
 
 53  
     @Override
 54  
     public JbiMessage getIn() {
 55  0
         return (JbiMessage) super.getIn();
 56  
     }
 57  
 
 58  
     @Override
 59  
     public JbiMessage getOut() {
 60  0
         return (JbiMessage) super.getOut();
 61  
     }
 62  
 
 63  
     @Override
 64  
     public JbiMessage getOut(boolean lazyCreate) {
 65  0
         return (JbiMessage) super.getOut(lazyCreate);
 66  
     }
 67  
 
 68  
     @Override
 69  
     public JbiMessage getFault() {
 70  0
         return (JbiMessage) super.getFault();
 71  
     }
 72  
 
 73  
     /**
 74  
      * @return the Camel <-> JBI binding
 75  
      */
 76  
     public JbiBinding getBinding() {
 77  0
         return binding;
 78  
     }
 79  
 
 80  
     // Expose JBI features
 81  
     //-------------------------------------------------------------------------
 82  
 
 83  
     /**
 84  
      * Returns the underlying JBI message exchange for an inbound exchange
 85  
      * or null for outbound messages
 86  
      *
 87  
      * @return the inbound message exchange
 88  
      */
 89  
     public MessageExchange getMessageExchange() {
 90  0
         return messageExchange;
 91  
     }
 92  
 
 93  
     /**
 94  
      * Returns the underlying In {@link NormalizedMessage}
 95  
      *
 96  
      * @return the In message
 97  
      */
 98  
     public NormalizedMessage getInMessage() {
 99  0
         return getIn().getNormalizedMessage();
 100  
     }
 101  
 
 102  
     /**
 103  
      * Returns the underlying Out {@link NormalizedMessage}
 104  
      *
 105  
      * @return the Out message
 106  
      */
 107  
     public NormalizedMessage getOutMessage() {
 108  0
         return getOut().getNormalizedMessage();
 109  
     }
 110  
 
 111  
     /**
 112  
      * Returns the underlying Fault {@link NormalizedMessage}
 113  
      *
 114  
      * @return the Fault message
 115  
      */
 116  
     public NormalizedMessage getFaultMessage() {
 117  0
         return getFault().getNormalizedMessage();
 118  
     }
 119  
 
 120  
     // Implementation methods
 121  
     //-------------------------------------------------------------------------
 122  
 
 123  
     @Override
 124  
     protected JbiMessage createInMessage() {
 125  0
         return new JbiMessage();
 126  
     }
 127  
 
 128  
     @Override
 129  
     protected JbiMessage createOutMessage() {
 130  0
         return new JbiMessage();
 131  
     }
 132  
 }