KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > shared > client > AbstractJmsReply


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - 2006 ScalAgent Distributed Technologies
4  * Copyright (C) 1996 - 2000 Dyade
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA.
20  *
21  * Initial developer(s): Frederic Maistre (INRIA)
22  * Contributor(s): ScalAgent Distributed Technologies
23  */

24 package org.objectweb.joram.shared.client;
25
26 import java.io.Externalizable JavaDoc;
27 import java.io.InputStream JavaDoc;
28 import java.io.OutputStream JavaDoc;
29 import java.io.IOException JavaDoc;
30
31 import org.objectweb.joram.shared.stream.Streamable;
32 import org.objectweb.joram.shared.stream.StreamUtil;
33
34 /**
35  * An <code>AbstractJmsReply</code> is sent by a proxy to a Joram client as a
36  * reply to an <code>AbstractJmsRequest</code>.
37  */

38 public abstract class AbstractJmsReply extends AbstractJmsMessage {
39   /** Identifier of the replied request. */
40   protected int correlationId = -1;
41
42   /** Sets the replied request identifier. */
43   public final void setCorrelationId(int correlationId) {
44     this.correlationId = correlationId;
45   }
46
47   /** Returns the replied request identifier. */
48   public final int getCorrelationId() {
49     return correlationId;
50   }
51
52   /**
53    * Constructs an <code>AbstractJmsReply</code>.
54    */

55   public AbstractJmsReply() {}
56
57   /**
58    * Constructs an <code>AbstractJmsReply</code>.
59    *
60    * @param correlationId Identifier of the replied request.
61    */

62   public AbstractJmsReply(int correlationId) {
63     this.correlationId = correlationId;
64   }
65
66   public final String JavaDoc toString() {
67     StringBuffer JavaDoc strbuf = new StringBuffer JavaDoc();
68     toString(strbuf);
69     return strbuf.toString();
70   }
71
72   public void toString(StringBuffer JavaDoc strbuf) {
73     strbuf.append('(').append(super.toString());
74     strbuf.append("correlationId=").append(correlationId);
75     strbuf.append(')');
76   }
77
78   /* ***** ***** ***** ***** *****
79    * Streamable interface
80    * ***** ***** ***** ***** ***** */

81
82   /**
83    * The object implements the writeTo method to write its contents to
84    * the output stream.
85    *
86    * @param os the stream to write the object to
87    */

88   public void writeTo(OutputStream JavaDoc os) throws IOException JavaDoc {
89     StreamUtil.writeTo(correlationId, os);
90   }
91
92   /**
93    * The object implements the readFrom method to restore its contents from
94    * the input stream.
95    *
96    * @param is the stream to read data from in order to restore the object
97    */

98   public void readFrom(InputStream JavaDoc is) throws IOException JavaDoc {
99     correlationId = StreamUtil.readIntFrom(is);
100   }
101 }
102
Popular Tags