KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > scheduler > singledb > SingleDBPassThroughScheduler


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2005 French National Institute For Research In Computer
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): Jean-Bernard van Zuylen.
23  */

24
25 package org.objectweb.cjdbc.controller.scheduler.singledb;
26
27 import java.sql.SQLException JavaDoc;
28
29 import org.objectweb.cjdbc.common.exceptions.RollbackException;
30 import org.objectweb.cjdbc.common.sql.AbstractWriteRequest;
31 import org.objectweb.cjdbc.common.sql.ParsingGranularities;
32 import org.objectweb.cjdbc.common.sql.SelectRequest;
33 import org.objectweb.cjdbc.common.sql.StoredProcedure;
34 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags;
35 import org.objectweb.cjdbc.controller.requestmanager.RAIDbLevels;
36 import org.objectweb.cjdbc.controller.scheduler.AbstractScheduler;
37
38 /**
39  * This scheduler provides scheduling for a single backend instance. It is
40  * really trivial and does not yet support distribution.
41  *
42  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
43  * @author <a HREF="mailto:jbvanzuylen@transwide.com">Jean-Bernard van Zuylen
44  * </a>
45  * @version 1.0
46  */

47 public class SingleDBPassThroughScheduler extends AbstractScheduler
48 {
49
50   //
51
// How the code is organized ?
52
//
53
// 1. Member variables
54
// 2. Constructor
55
// 3. Request handling
56
// 4. Transaction management
57
// 5. Debug/Monitoring
58
//
59

60   private long requestId;
61
62   //
63
// Constructor
64
//
65

66   /**
67    * Creates a new Single Database Scheduler
68    */

69   public SingleDBPassThroughScheduler()
70   {
71     super(RAIDbLevels.SingleDB, ParsingGranularities.NO_PARSING);
72
73     requestId = 0;
74   }
75
76   //
77
// Request Handling
78
//
79

80   /**
81    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#scheduleReadRequest(SelectRequest)
82    */

83   public final synchronized void scheduleReadRequest(SelectRequest request)
84   {
85     request.setId(requestId++);
86   }
87
88   /**
89    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#readCompletedNotify(SelectRequest)
90    */

91   public final void readCompletedNotify(SelectRequest request)
92   {
93   }
94
95   /**
96    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#scheduleWriteRequest(AbstractWriteRequest)
97    */

98   public final synchronized void scheduleNonSuspendedWriteRequest(
99       AbstractWriteRequest request)
100   {
101     request.setId(requestId++);
102   }
103
104   /**
105    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#notifyWriteCompleted(AbstractWriteRequest)
106    */

107   public final void notifyWriteCompleted(AbstractWriteRequest request)
108   {
109   }
110
111   /**
112    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#scheduleNonSuspendedStoredProcedure(org.objectweb.cjdbc.common.sql.StoredProcedure)
113    */

114   public final synchronized void scheduleNonSuspendedStoredProcedure(
115       StoredProcedure proc) throws SQLException JavaDoc, RollbackException
116   {
117     proc.setId(requestId++);
118   }
119
120   /**
121    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#notifyStoredProcedureCompleted(org.objectweb.cjdbc.common.sql.StoredProcedure)
122    */

123   public final void notifyStoredProcedureCompleted(StoredProcedure proc)
124   {
125   }
126
127   //
128
// Transaction Management
129
//
130

131   /**
132    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#commitTransaction(long)
133    */

134   protected final void commitTransaction(long transactionId)
135   {
136   }
137
138   /**
139    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#rollbackTransaction(long)
140    */

141   protected final void rollbackTransaction(long transactionId)
142   {
143   }
144
145   /**
146    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#rollbackTransaction(long,
147    * String)
148    */

149   protected final void rollbackTransaction(long transactionId,
150       String JavaDoc savepointName)
151   {
152   }
153
154   /**
155    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#setSavepointTransaction(long,
156    * String)
157    */

158   protected final void setSavepointTransaction(long transactionId, String JavaDoc name)
159   {
160   }
161
162   /**
163    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#releaseSavepointTransaction(long,
164    * String)
165    */

166   protected final void releaseSavepointTransaction(long transactionId,
167       String JavaDoc name)
168   {
169   }
170
171   //
172
// Debug/Monitoring
173
//
174
/**
175    * @see org.objectweb.cjdbc.controller.scheduler.AbstractScheduler#getXmlImpl()
176    */

177   public String JavaDoc getXmlImpl()
178   {
179     return "<" + DatabasesXmlTags.ELT_SingleDBScheduler + " "
180         + DatabasesXmlTags.ATT_level + "=\"" + DatabasesXmlTags.VAL_passThrough
181         + "\"/>";
182   }
183 }
184
Popular Tags