1 22 package org.jboss.mq; 23 24 import java.io.Serializable ; 25 import java.util.Enumeration ; 26 27 import javax.jms.JMSException ; 28 import javax.jms.Message ; 29 30 39 public class SpyEncapsulatedMessage extends SpyObjectMessage 40 { 41 43 44 private final static long serialVersionUID = 3995327252678969050L; 45 46 48 50 52 54 56 public void setMessage(Message m) throws JMSException 57 { 58 this.setObject((Serializable ) m); 59 60 if (m.getJMSCorrelationID() != null) 61 setJMSCorrelationID(m.getJMSCorrelationID()); 62 else if (m.getJMSCorrelationIDAsBytes() != null) 63 setJMSCorrelationIDAsBytes(m.getJMSCorrelationIDAsBytes()); 64 setJMSReplyTo(m.getJMSReplyTo()); 65 setJMSType(m.getJMSType()); 66 setJMSDestination(m.getJMSDestination()); 67 setJMSDeliveryMode(m.getJMSDeliveryMode()); 68 setJMSExpiration(m.getJMSExpiration()); 69 setJMSPriority(m.getJMSPriority()); 70 setJMSMessageID(m.getJMSMessageID()); 71 setJMSTimestamp(m.getJMSTimestamp()); 72 73 Enumeration enumeration = m.getPropertyNames(); 74 while (enumeration.hasMoreElements()) 75 { 76 String name = (String ) enumeration.nextElement(); 77 Object o = m.getObjectProperty(name); 78 setObjectProperty(name, o); 79 } 80 } 81 82 public Message getMessage() throws JMSException 83 { 84 Message m = (Message ) this.getObject(); 85 m.setJMSRedelivered(getJMSRedelivered()); 86 return m; 87 } 88 89 91 public SpyMessage myClone() throws JMSException 92 { 93 SpyEncapsulatedMessage result = MessagePool.getEncapsulatedMessage(); 94 result.copyProps(this); 95 boolean readOnly = result.header.msgReadOnly; 97 result.header.msgReadOnly = false; 98 result.setMessage(this.getMessage()); 99 result.header.msgReadOnly = readOnly; 100 return result; 101 } 102 103 105 107 109 } | Popular Tags |