1 /***
2 * Copyright (c) 2002, Reuters America Inc. All rights reserved.<p>
3 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
4 * conditions are met:<p>
5 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
7 * in the documentation and/or other materials provided with the distribution. Neither the name of Reuters America Inc. nor the
8 * names of its contributors may be used to endorse or promote products derived from this software without specific prior written
9 * permission.<p>
10 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
11 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
12 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
13 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
14 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<p>
16 */
17
18 package com.reuters.rc.db.adb;
19
20 import com.reuters.rc.db.*;
21 import com.tibco.tibrv.*;
22
23 /***
24 * The factory for Adb.
25 *
26 * This class is the single source for object creation. Application clients can set/get
27 * their particular choice of DbFactory implementation through the static methods of the
28 * DbManager class.
29 *
30 * @author Jawaid Hakim.
31 */
32 public class AdbFactory implements DbFactory
33 {
34 /***
35 * Ctor.
36 */
37 public AdbFactory()
38 {
39 }
40
41 /***
42 * Get an instance of a DbRequest object.
43 *
44 * @param stmt request statement
45 * @return an instance of DbRequest object
46 * @see DbRequestStmt
47 */
48 public DbRequest getRequest(DbRequestStmt stmt)
49 {
50 return new AdbRequest(stmt);
51 }
52
53 /***
54 * Get an instance of a DbRequest object.
55 *
56 * @param stmt Request statement.
57 * @param timeout Maximum time interval - in seconds - for which to
58 * wait for reply in request/reply mode.
59 * @see DbRequest#sendRequest(TibrvTransport, String)
60 * @see DbRequest#sendRequest(String)
61 * @see DbRequestStmt
62 */
63 public DbRequest getRequest(DbRequestStmt stmt, double timeout)
64 {
65 return new AdbRequest(stmt, timeout);
66 }
67
68 /***
69 * Get an instance of a DbRequest object.
70 *
71 * @param stmt Request statement.
72 * @param timeout Maximum time interval - in seconds - for which to
73 * wait for reply in request/reply mode.
74 * @param closure Closure argument.
75 * @see DbRequest#sendRequest(TibrvTransport, String)
76 * @see DbRequest#sendRequest(String)
77 * @see DbRequestStmt
78 */
79 public DbRequest getRequest(DbRequestStmt stmt, double timeout, Object closure)
80 {
81 return new AdbRequest(stmt, timeout, closure);
82 }
83
84 /***
85 * Get an instance of a DbRequest object.
86 *
87 * @param stmts Request statements.
88 * @see DbRequestStmt
89 */
90 public DbRequest getRequest(DbRequestStmt[] stmts)
91 {
92 return new AdbRequest(stmts);
93 }
94
95 /***
96 * Get an instance of a DbRequest object.
97 *
98 * @param stmts Request statements.
99 * @param timeout Maximum time interval - in seconds - for which to
100 * wait for reply in request/reply mode.
101 * @see DbRequest#sendRequest(TibrvTransport, String)
102 * @see DbRequest#sendRequest(String)
103 * @see DbRequestStmt
104 */
105 public DbRequest getRequest(DbRequestStmt[] stmts, double timeout)
106 {
107 return new AdbRequest(stmts, timeout);
108 }
109
110 /***
111 * Get an instance of a DbRequest object.
112 *
113 * @param stmts Request statements.
114 * @param timeout Maximum time interval - in seconds - for which to
115 * wait for reply in request/reply mode.
116 * @param closure Closure argument.
117 * @see DbRequest#sendRequest(TibrvTransport, String)
118 * @see DbRequest#sendRequest(String)
119 * @see DbRequestStmt
120 */
121 public DbRequest getRequest(DbRequestStmt[] stmts, double timeout, Object closure)
122 {
123 return new AdbRequest(stmts, timeout, closure);
124 }
125
126 ////////////////////////////////////////////////////////
127 // Factory Methods for the DbReply interface //
128 ///////////////////////////////////////////////////////
129
130 /***
131 * Get an instance of a DbReply object.
132 *
133 * @param replyMsg Reply message from ADB.
134 */
135 public DbReply getReply(TibrvMsg replyMsg)
136 {
137 return new AdbReply(replyMsg);
138 }
139
140 ////////////////////////////////////////////////////////
141 // Factory Methods for the DbRequestStmt interface //
142 ///////////////////////////////////////////////////////
143
144
145 /***
146 * Get an instance of a DbRequestStmt object.
147 *
148 * @param sql The SQL statement to execute on the ADB.
149 */
150 public DbRequestStmt getRequestStmt(String sql)
151 {
152 return new AdbRequestStmt(sql);
153 }
154
155 /***
156 * Get an instance of a DbRequestStmt object.
157 *
158 * @param sql The SQL statement to execute on the ADB.
159 * @param maxRows Maximum number of result rows returned from request.
160 */
161 public DbRequestStmt getRequestStmt(String sql, int maxRows)
162 {
163 return new AdbRequestStmt(sql, maxRows);
164 }
165
166
167 /***
168 * Get an instance of a DbRequestStmt object
169 *
170 * @param sql The SQL statement to execute on the ADB.
171 * @param bind Bind data.
172 * @see DbRequestBind
173 */
174 public DbRequestStmt getRequestStmt(String sql, DbRequestBind bind)
175 {
176 return new AdbRequestStmt(sql, bind);
177 }
178
179 /***
180 * Get an instance of a DbRequestStmt object
181 *
182 * @param sql The SQL statement to execute on the ADB.
183 * @param bind Bind data.
184 * @param maxRows Maximum number of result rows returned from request.
185 * @see DbRequestBind
186 */
187 public DbRequestStmt getRequestStmt(String sql, DbRequestBind bind, int maxRows)
188 {
189 return new AdbRequestStmt(sql, bind, maxRows);
190 }
191
192 /***
193 * Get an instance of a DbRequestStmt object
194 *
195 * @param sql The SQL statement to execute on the ADB.
196 * @param binds Bind data.
197 * @see DbRequestBind
198 */
199 public DbRequestStmt getRequestStmt(String sql, DbRequestBind[] binds)
200 {
201 return new AdbRequestStmt(sql, binds);
202 }
203
204 /***
205 * Get an instance of a DbRequestStmt object
206 *
207 * @param sql The SQL statement to execute on the ADB.
208 * @param binds Bind data.
209 * @param maxRows Maximum number of result rows returned from request.
210 * @see DbRequestBind
211 */
212 public DbRequestStmt getRequestStmt(String sql, DbRequestBind[] binds, int maxRows)
213 {
214 return new AdbRequestStmt(sql, binds, maxRows);
215 }
216
217 ////////////////////////////////////////////////////////
218 // Factory Methods for the DbRequestBind interface //
219 ///////////////////////////////////////////////////////
220
221
222 /***
223 * Get an instance of a DbRequestBind object.
224 *
225 * @param position Placeholder position.
226 * @param column Column name.
227 * @param data Column data.
228 */
229 public DbRequestBind getRequestBind(int position, String column, Object data)
230 {
231 return new AdbRequestBind(position, column, data);
232 }
233
234
235 /***
236 * Get an instance of a DbRequestBind object.
237 *
238 * @param column Column name.
239 * @param data Column data.
240 */
241 public DbRequestBind getRequestBind(String column, Object data)
242 {
243 return new AdbRequestBind(column, data);
244 }
245
246 /***
247 * Get an instance of a DbRequestBind object.
248 *
249 * @param position Placeholder position.
250 * @param data Column data.
251 */
252 public DbRequestBind getRequestBind(int position, Object data)
253 {
254 return new AdbRequestBind(position, data);
255 }
256
257 ////////////////////////////////////////////////////////
258 // Factory Methods for the DbOpcode interface //
259 ///////////////////////////////////////////////////////
260
261
262 /***
263 * Get an instance of a DbOpcode object that represents an Insert operation.
264 *
265 * @return DbOpcode instance
266 */
267 public DbOpcode getInsertOpcode()
268 {
269 return AdbOpcode.INSERT;
270 }
271
272 /***
273 * Get an instance of a DbOpcode object that represents a Delete operation.
274 *
275 * @return DbOpcode instance
276 */
277 public DbOpcode getDeleteOpcode()
278 {
279 return AdbOpcode.DELETE;
280 }
281
282 /***
283 * Get an instance of a DbOpcode object that represents an Update operation.
284 *
285 * @return DbOpcode instance
286 */
287 public DbOpcode getUpdateOpcode()
288 {
289 return AdbOpcode.UPDATE;
290 }
291
292 /***
293 * Get an instance of a DbOpcode object that represents an Upsert operation.
294 *
295 * @return DbOpcode instance
296 */
297 public DbOpcode getUpsertOpcode()
298 {
299 return AdbOpcode.UPSERT;
300 }
301
302 /***
303 * Get an instance of a DbOpcode object that represents an Unknown operation.
304 *
305 * @return DbOpcode instance
306 */
307 public DbOpcode getUnknownOpcode()
308 {
309 return AdbOpcode.UNKNOWN;
310 }
311
312 /***
313 * Get the OpCode object corresponding to an integer opcode. Note
314 * that the integer values here are application specific. Subclasses
315 * are free to use any values they want.
316 *
317 * @param opCode an application specific opcode value as an integer
318 * @return DbOpcode instance
319 */
320 public DbOpcode getOpcode(int opCode)
321 {
322 return AdbOpcode.getOpcode(opCode);
323 }
324
325 ////////////////////////////////////////////////////////
326 // Factory Methods for the PubMsg interface //
327 ///////////////////////////////////////////////////////
328
329
330 /***
331 * Get an instance of a PubMsg object constructed from a Tibrv
332 * message.
333 *
334 * @param rvMsg the rvMsg that is published
335 * @return PubMsg instance
336 */
337 public DbPubMsg getPubMsg(TibrvMsg rvMsg)
338 {
339 return new AdbMInstPubMsg(rvMsg);
340 }
341 }
This page was automatically generated by Maven