KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > virtualdatabase > protocol > DistributedTransactionMarker


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2005 Emic Networks
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.controller.virtualdatabase.protocol;
26
27 import java.io.Serializable JavaDoc;
28 import java.sql.SQLException JavaDoc;
29
30 import org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager;
31
32 /**
33  * This class defines a DistributedTransactionMarker which is used to transport
34  * commit/rollback/savepoint type of commands.
35  *
36  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
37  * </a>
38  * @version 1.0
39  */

40 public abstract class DistributedTransactionMarker implements Serializable JavaDoc
41 {
42
43   protected long transactionId;
44
45   /**
46    * Creates a new <code>DistributedTransactionMarker</code> object
47    *
48    * @param transactionId the transaction identifier
49    */

50   public DistributedTransactionMarker(long transactionId)
51   {
52     this.transactionId = transactionId;
53   }
54
55   /**
56    * Schedule the command (i.e. commit or rollback). This method blocks until
57    * the command is scheduled.
58    *
59    * @param drm a distributed request manager
60    * @throws SQLException if an error occurs.
61    */

62   public abstract void scheduleCommand(DistributedRequestManager drm)
63       throws SQLException JavaDoc;
64
65   /**
66    * Code to be executed by the distributed request manager receiving the
67    * command.
68    *
69    * @param drm a distributed request manager
70    * @return an Object to be sent back to the caller
71    * @throws SQLException if an error occurs.
72    */

73   public abstract Object JavaDoc executeCommand(DistributedRequestManager drm)
74       throws SQLException JavaDoc;
75
76   /**
77    * Returns the transactionId value.
78    *
79    * @return Returns the transactionId.
80    */

81   public long getTransactionId()
82   {
83     return transactionId;
84   }
85
86   /**
87    * @see java.lang.Object#equals(java.lang.Object)
88    */

89   public boolean equals(Object JavaDoc obj)
90   {
91     if (obj == null)
92       return false;
93     if (obj.getClass().equals(this.getClass()))
94       return transactionId == ((DistributedTransactionMarker) obj)
95           .getTransactionId();
96     else
97       return false;
98   }
99 }
100
Popular Tags