KickJava   Java API By Example, From Geeks To Geeks.

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


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.Externalizable JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.io.ObjectInput JavaDoc;
27 import java.io.ObjectOutput JavaDoc;
28
29 /**
30  * This class contians all the data needed to perform a JMS transaction
31  *
32  * @author Hiram Chirino (Cojonudo14@hotmail.com)
33  * @author David Maplesden (David.Maplesden@orion.co.nz)
34  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
35  * @version $Revision: 37459 $
36  */

37 public class ReceiveRequest implements Externalizable JavaDoc
38 {
39    // Constants -----------------------------------------------------
40

41    /** The serialVersionUID */
42    private static final long serialVersionUID = 8632752498878645170L;
43
44    /** Whether the subscription is null */
45    protected final static byte NULL = 0;
46
47    /** Whether the subscription is non null */
48    protected final static byte NON_NULL = 1;
49    
50    // Attributes ----------------------------------------------------
51

52    // Static --------------------------------------------------------
53

54    /** The message */
55    public SpyMessage message;
56    /** Is this an exlusive message? Then subscriptionId != null */
57    public Integer JavaDoc subscriptionId;
58    
59    // Constructors --------------------------------------------------
60

61    // Public --------------------------------------------------------
62

63    public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc
64    {
65       message = SpyMessage.readMessage(in);
66       byte b = in.readByte();
67       if (b == NON_NULL)
68       {
69          subscriptionId = new Integer JavaDoc(in.readInt());
70       }
71       else
72       {
73          subscriptionId = null;
74       }
75    }
76    
77    // Object overrides ----------------------------------------------
78

79    public String JavaDoc toString()
80    {
81       StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
82       buffer.append("ReceiveRequest[");
83       buffer.append("message=").append(message.header.jmsMessageID);
84       buffer.append(" subscription=").append(subscriptionId);
85       return buffer.toString();
86    }
87    
88    // Externalizable implementation ---------------------------------
89

90    public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc
91    {
92       SpyMessage.writeMessage(message, out);
93       if (subscriptionId == null)
94       {
95          out.writeByte(NULL);
96       }
97       else
98       {
99          out.writeByte(NON_NULL);
100          out.writeInt(subscriptionId.intValue());
101       }
102    }
103
104    // Package protected ---------------------------------------------
105

106    // Protected -----------------------------------------------------
107

108    // Private -------------------------------------------------------
109

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