KickJava   Java API By Example, From Geeks To Geeks.

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


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>XACnxCommit</code> instance is used by an <code>XAConnection</code>
36  * for commiting the messages and acknowledgements it sent to the proxy.
37  */

38 public final class XACnxCommit extends AbstractJmsRequest {
39   /** Transaction branch qualifier. */
40   private byte[] bq;
41
42   /** Returns the transaction branch qualifier. */
43   public byte[] getBQ() {
44     return bq;
45   }
46
47   public void setBQ(byte[] bq) {
48     this.bq = bq;
49   }
50
51   /** Transaction identifier format. */
52   private int fi;
53
54   /** Returns the transaction identifier format. */
55   public int getFI() {
56     return fi;
57   }
58
59   public void setFI(int fi) {
60     this.fi = fi;
61   }
62
63   /** Global transaction identifier. */
64   private byte[] gti;
65
66   /** Returns the global transaction identifier. */
67   public byte[] getGTI() {
68     return gti;
69   }
70
71   public void setGTI(byte[] gti) {
72     this.gti = gti;
73   }
74
75   protected int getClassId() {
76     return XA_CNX_COMMIT;
77   }
78
79   /**
80    * Constructs an <code>XACnxCommit</code> instance.
81    *
82    * @param bq Transaction branch qualifier.
83    * @param fi Transaction identifier format.
84    * @param gti Global transaction identifier.
85    */

86   public XACnxCommit(byte[] bq, int fi, byte[] gti) {
87     super();
88     this.bq = bq;
89     this.fi = fi;
90     this.gti = gti;
91   }
92
93   /**
94    * Constructs an <code>XACnxCommit</code> instance.
95    */

96   public XACnxCommit() {}
97
98   /* ***** ***** ***** ***** *****
99    * Streamable interface
100    * ***** ***** ***** ***** ***** */

101
102   /**
103    * The object implements the writeTo method to write its contents to
104    * the output stream.
105    *
106    * @param os the stream to write the object to
107    */

108   public void writeTo(OutputStream JavaDoc os) throws IOException JavaDoc {
109     super.writeTo(os);
110     StreamUtil.writeTo(bq, os);
111     StreamUtil.writeTo(fi, os);
112     StreamUtil.writeTo(gti, os);
113   }
114
115   /**
116    * The object implements the readFrom method to restore its contents from
117    * the input stream.
118    *
119    * @param is the stream to read data from in order to restore the object
120    */

121   public void readFrom(InputStream JavaDoc is) throws IOException JavaDoc {
122     super.readFrom(is);
123     bq = StreamUtil.readByteArrayFrom(is);
124     fi = StreamUtil.readIntFrom(is);
125     gti = StreamUtil.readByteArrayFrom(is);
126   }
127 }
128
Popular Tags