KickJava   Java API By Example, From Geeks To Geeks.

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


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  * A <code>CnxConnectReply</code> is sent by a JMS proxy as a reply to a
36  * connection <code>CnxConnectRequest</code> and holds the connection's key
37  * and the proxy identifier.
38  */

39 public final class CnxConnectReply extends AbstractJmsReply {
40   /** The connection's key. */
41   private int cnxKey;
42
43    /** Sets the connection key. */
44   public void setCnxKey(int cnxKey) {
45     this.cnxKey = cnxKey;
46   }
47  
48   /** Returns the connection's key. */
49   public int getCnxKey() {
50     return cnxKey;
51   }
52
53   /** The proxy's identifier. */
54   private String JavaDoc proxyId;
55
56   /** Sets the proxy's identifier */
57   public void setProxyId(String JavaDoc proxyId) {
58     this.proxyId = proxyId;
59   }
60
61   /** Returns the proxy's identifier */
62   public String JavaDoc getProxyId() {
63     return proxyId;
64   }
65
66   protected int getClassId() {
67     return CNX_CONNECT_REPLY;
68   }
69
70   /**
71    * Constructs a <code>CnxConnectReply</code>.
72    *
73    * @param req The replied request.
74    * @param cnxKey The connection's key.
75    * @param proxyId The proxy's identifier.
76    */

77   public CnxConnectReply(CnxConnectRequest req, int cnxKey, String JavaDoc proxyId) {
78     super(req.getRequestId());
79     this.cnxKey = cnxKey;
80     this.proxyId = proxyId;
81   }
82
83   /**
84    * Constructs a <code>CnxConnectReply</code>.
85    */

86   public CnxConnectReply() {}
87
88   /* ***** ***** ***** ***** *****
89    * Streamable interface
90    * ***** ***** ***** ***** ***** */

91
92   /**
93    * The object implements the writeTo method to write its contents to
94    * the output stream.
95    *
96    * @param os the stream to write the object to
97    */

98   public void writeTo(OutputStream JavaDoc os) throws IOException JavaDoc {
99     super.writeTo(os);
100     StreamUtil.writeTo(cnxKey, os);
101     StreamUtil.writeTo(proxyId, os);
102   }
103
104   /**
105    * The object implements the readFrom method to restore its contents from
106    * the input stream.
107    *
108    * @param is the stream to read data from in order to restore the object
109    */

110   public void readFrom(InputStream JavaDoc is) throws IOException JavaDoc {
111     super.readFrom(is);
112     cnxKey = StreamUtil.readIntFrom(is);
113     proxyId = StreamUtil.readStringFrom(is);
114   }
115 }
116
Popular Tags