1 45 46 package org.exolab.jms.message; 47 48 import java.util.Enumeration ; 49 50 import javax.jms.Destination ; 51 import javax.jms.JMSException ; 52 import javax.jms.Message ; 53 54 import org.exolab.jms.client.JmsDestination; 55 56 57 64 abstract class AbstractMessageConverter implements MessageConverter { 65 66 73 public Message convert(Message message) throws JMSException { 74 Message result = create(); 75 populate(message, result); 76 return result; 77 } 78 79 85 protected abstract Message create() throws JMSException ; 86 87 94 protected void populate(Message source, Message target) 95 throws JMSException { 96 97 target.setJMSMessageID(source.getJMSMessageID()); 98 target.setJMSDestination(source.getJMSDestination()); 99 target.setJMSTimestamp(source.getJMSTimestamp()); 100 target.setJMSPriority(source.getJMSPriority()); 101 target.setJMSExpiration(source.getJMSExpiration()); 102 target.setJMSDeliveryMode(source.getJMSDeliveryMode()); 103 target.setJMSCorrelationID(source.getJMSCorrelationID()); 104 target.setJMSType(source.getJMSType()); 105 106 Destination replyTo = source.getJMSReplyTo(); 107 if (replyTo instanceof JmsDestination) { 108 target.setJMSReplyTo(replyTo); 109 } 110 111 Enumeration iterator = source.getPropertyNames(); 113 while (iterator.hasMoreElements()) { 114 String name = (String ) iterator.nextElement(); 115 if (!name.startsWith("JMSX") || name.equals("JMSXGroupID") 116 || name.equals("JMSXGroupSeq")) { 117 119 Object value = (Object ) source.getObjectProperty(name); 120 target.setObjectProperty(name, value); 121 } 122 } 123 } 124 125 } 126 | Popular Tags |