KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > SpyEncapsulatedMessage


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mq;
23
24 import java.io.Serializable JavaDoc;
25 import java.util.Enumeration JavaDoc;
26
27 import javax.jms.JMSException JavaDoc;
28 import javax.jms.Message JavaDoc;
29
30 /**
31  * This Message class is used to send a non 'provider-optimized Message' over
32  * the network [4.4.5]
33  *
34  * @author Norbert Lataille (Norbert.Lataille@m4x.org)
35  * @author Hiram Chirino (Cojonudo14@hotmail.com)
36  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
37  * @version $Revision: 37459 $
38  */

39 public class SpyEncapsulatedMessage extends SpyObjectMessage
40 {
41    // Constants -----------------------------------------------------
42

43    /** The serialVersionUID */
44    private final static long serialVersionUID = 3995327252678969050L;
45    
46    // Attributes ----------------------------------------------------
47

48    // Static --------------------------------------------------------
49

50    // Constructors --------------------------------------------------
51

52    // Public --------------------------------------------------------
53

54    // SpyMessage overrides ------------------------------------------
55

56    public void setMessage(Message JavaDoc m) throws JMSException JavaDoc
57    {
58       this.setObject((Serializable JavaDoc) 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 JavaDoc enumeration = m.getPropertyNames();
74       while (enumeration.hasMoreElements())
75       {
76          String JavaDoc name = (String JavaDoc) enumeration.nextElement();
77          Object JavaDoc o = m.getObjectProperty(name);
78          setObjectProperty(name, o);
79       }
80    }
81
82    public Message JavaDoc getMessage() throws JMSException JavaDoc
83    {
84       Message JavaDoc m = (Message JavaDoc) this.getObject();
85       m.setJMSRedelivered(getJMSRedelivered());
86       return m;
87    }
88    
89    // SpyMessage overrides ------------------------------------------
90

91    public SpyMessage myClone() throws JMSException JavaDoc
92    {
93       SpyEncapsulatedMessage result = MessagePool.getEncapsulatedMessage();
94       result.copyProps(this);
95       //HACK to get around read only problem
96
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    // Package protected ---------------------------------------------
104

105    // Protected -----------------------------------------------------
106

107    // Private -------------------------------------------------------
108

109    // Inner classes -------------------------------------------------
110
}
Popular Tags