001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mq;
023:
024: import java.io.Serializable;
025: import java.util.Enumeration;
026:
027: import javax.jms.JMSException;
028: import javax.jms.Message;
029:
030: /**
031: * This Message class is used to send a non 'provider-optimized Message' over
032: * the network [4.4.5]
033: *
034: * @author Norbert Lataille (Norbert.Lataille@m4x.org)
035: * @author Hiram Chirino (Cojonudo14@hotmail.com)
036: * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
037: * @version $Revision: 57198 $
038: */
039: public class SpyEncapsulatedMessage extends SpyObjectMessage {
040: // Constants -----------------------------------------------------
041:
042: /** The serialVersionUID */
043: private final static long serialVersionUID = 3995327252678969050L;
044:
045: // Attributes ----------------------------------------------------
046:
047: // Static --------------------------------------------------------
048:
049: // Constructors --------------------------------------------------
050:
051: // Public --------------------------------------------------------
052:
053: // SpyMessage overrides ------------------------------------------
054:
055: public void setMessage(Message m) throws JMSException {
056: this .setObject((Serializable) m);
057:
058: if (m.getJMSCorrelationID() != null)
059: setJMSCorrelationID(m.getJMSCorrelationID());
060: else if (m.getJMSCorrelationIDAsBytes() != null)
061: setJMSCorrelationIDAsBytes(m.getJMSCorrelationIDAsBytes());
062: setJMSReplyTo(m.getJMSReplyTo());
063: setJMSType(m.getJMSType());
064: setJMSDestination(m.getJMSDestination());
065: setJMSDeliveryMode(m.getJMSDeliveryMode());
066: setJMSExpiration(m.getJMSExpiration());
067: setJMSPriority(m.getJMSPriority());
068: setJMSMessageID(m.getJMSMessageID());
069: setJMSTimestamp(m.getJMSTimestamp());
070:
071: Enumeration enumeration = m.getPropertyNames();
072: while (enumeration.hasMoreElements()) {
073: String name = (String) enumeration.nextElement();
074: Object o = m.getObjectProperty(name);
075: setObjectProperty(name, o);
076: }
077: }
078:
079: public Message getMessage() throws JMSException {
080: Message m = (Message) this .getObject();
081: m.setJMSRedelivered(getJMSRedelivered());
082: return m;
083: }
084:
085: // SpyMessage overrides ------------------------------------------
086:
087: public SpyMessage myClone() throws JMSException {
088: SpyEncapsulatedMessage result = MessagePool
089: .getEncapsulatedMessage();
090: result.copyProps(this );
091: //HACK to get around read only problem
092: boolean readOnly = result.header.msgReadOnly;
093: result.header.msgReadOnly = false;
094: result.setMessage(this .getMessage());
095: result.header.msgReadOnly = readOnly;
096: return result;
097: }
098:
099: // Package protected ---------------------------------------------
100:
101: // Protected -----------------------------------------------------
102:
103: // Private -------------------------------------------------------
104:
105: // Inner classes -------------------------------------------------
106: }
|