001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.camel.component.jms; 018 019 import org.apache.camel.CamelContext; 020 import org.apache.camel.Exchange; 021 import org.apache.camel.impl.DefaultExchange; 022 023 import javax.jms.JMSException; 024 import javax.jms.Message; 025 import javax.jms.Session; 026 027 /** 028 * @version $Revision:520964 $ 029 */ 030 public class DefaultJmsExchange extends DefaultExchange implements JmsExchange { 031 032 public DefaultJmsExchange(CamelContext container) { 033 super(container); 034 } 035 036 public DefaultJmsExchange(CamelContext container, Message message) { 037 super(container); 038 setIn(new DefaultJmsMessage(message)); 039 } 040 041 @Override 042 public Exchange newInstance() { 043 return new DefaultJmsExchange(getContext()); 044 } 045 046 public Message createMessage(Session session) throws JMSException { 047 Message request = getInMessage(); 048 if (request == null) { 049 request = session.createMessage(); 050 051 /** TODO 052 if (lazyHeaders != null) { 053 // lets add any lazy headers 054 for (Map.Entry<String, Object> entry : lazyHeaders.entrySet()) { 055 request.setObjectProperty(entry.getKey(), entry.getValue()); 056 } 057 } 058 */ 059 } 060 return request; 061 } 062 063 public Message getInMessage() { 064 JmsMessage jmsMessage = (JmsMessage) getIn(); 065 if (jmsMessage != null) { 066 return jmsMessage.getJmsMessage(); 067 } 068 return null; 069 } 070 071 @Override 072 protected org.apache.camel.Message createInMessage() { 073 return new DefaultJmsMessage(); 074 } 075 076 @Override 077 protected org.apache.camel.Message createOutMessage() { 078 return new DefaultJmsMessage(); 079 } 080 }