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.Externalizable;
025: import java.io.IOException;
026: import java.io.ObjectInput;
027: import java.io.ObjectOutput;
028:
029: /**
030: * This class contians all the data needed to perform a JMS transaction
031: *
032: * @author Hiram Chirino (Cojonudo14@hotmail.com)
033: * @author David Maplesden (David.Maplesden@orion.co.nz)
034: * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
035: * @version $Revision: 57198 $
036: */
037: public class ReceiveRequest implements Externalizable {
038: // Constants -----------------------------------------------------
039:
040: /** The serialVersionUID */
041: private static final long serialVersionUID = 8632752498878645170L;
042:
043: /** Whether the subscription is null */
044: protected final static byte NULL = 0;
045:
046: /** Whether the subscription is non null */
047: protected final static byte NON_NULL = 1;
048:
049: // Attributes ----------------------------------------------------
050:
051: // Static --------------------------------------------------------
052:
053: /** The message */
054: public SpyMessage message;
055: /** Is this an exlusive message? Then subscriptionId != null */
056: public Integer subscriptionId;
057:
058: // Constructors --------------------------------------------------
059:
060: // Public --------------------------------------------------------
061:
062: public void readExternal(ObjectInput in) throws IOException {
063: message = SpyMessage.readMessage(in);
064: byte b = in.readByte();
065: if (b == NON_NULL) {
066: subscriptionId = new Integer(in.readInt());
067: } else {
068: subscriptionId = null;
069: }
070: }
071:
072: // Object overrides ----------------------------------------------
073:
074: public String toString() {
075: StringBuffer buffer = new StringBuffer();
076: buffer.append("ReceiveRequest[");
077: buffer.append("message=").append(message.header.jmsMessageID);
078: buffer.append(" subscription=").append(subscriptionId);
079: return buffer.toString();
080: }
081:
082: // Externalizable implementation ---------------------------------
083:
084: public void writeExternal(ObjectOutput out) throws IOException {
085: SpyMessage.writeMessage(message, out);
086: if (subscriptionId == null) {
087: out.writeByte(NULL);
088: } else {
089: out.writeByte(NON_NULL);
090: out.writeInt(subscriptionId.intValue());
091: }
092: }
093:
094: // Package protected ---------------------------------------------
095:
096: // Protected -----------------------------------------------------
097:
098: // Private -------------------------------------------------------
099:
100: // Inner classes -------------------------------------------------
101: }
|