KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > cache > QueryCache


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  */

20 package org.enhydra.dods.cache;
21
22 import java.util.Vector JavaDoc;
23
24 /**
25  * This abstract class contains data and mechanisms needed for caching data
26  * objects (or DataStruct objects) and queries and provides cache configuration
27  * and administration.
28  *
29  * @author Tanja Jovanovic
30  * @author Nenad Vico
31  * @author Zorica Suvajdzin
32  * @version 2.0 15.06.2003.
33  */

34 public abstract class QueryCache extends DataStructCache {
35
36     /**
37      * Creates new QueryCacheItem instance.
38      *
39      * @param dbName Database name.
40      * @return Created QueryCacheItem.
41      */

42     public abstract QueryCacheItem newQueryCacheItemInstance(String JavaDoc dbName);
43
44     /**
45      * Returns QueryCacheItem object for specified database and simple query,
46      * if exists, otherwise null.
47      *
48      * @param dbName Database name.
49      * @param query Query in form of String.
50      * @return QueryCacheItem object.
51      */

52     public abstract QueryCacheItem getSimpleQueryCacheItem(String JavaDoc dbName, String JavaDoc query);
53
54     /**
55      * Returns QueryCacheItem object for specified database and complex query,
56      * if exists, otherwise null.
57      *
58      * @param dbName Database name.
59      * @param query Query in form of String.
60      * @return QueryCacheItem object.
61      */

62     public abstract QueryCacheItem getComplexQueryCacheItem(String JavaDoc dbName, String JavaDoc query);
63
64     /**
65      * Returns QueryCacheItem object for specified database and multi join query,
66      * if exists, otherwise null.
67      *
68      * @param dbName Database name.
69      * @param query Query in form of String.
70      * @return QueryCacheItem object.
71      */

72     public abstract QueryCacheItem getMultiJoinQueryCacheItem(String JavaDoc dbName, String JavaDoc query);
73     
74     /**
75      * Adds simple query to simple query cache.
76      *
77      * @param queryItem Query that will be added to simple query cache.
78      * @return Query added to simple query cache.
79      */

80     public abstract QueryCacheItem addSimpleQuery(QueryCacheItem queryItem);
81
82     /**
83      * Removes simple query from simple query cache.
84      *
85      * @param queryItem QueryItem that will be removed from simple query cache.
86      * @return QueryItem removed from simple query cache.
87      */

88     public abstract QueryCacheItem removeSimpleQuery(QueryCacheItem queryItem);
89
90     /**
91      * Adds complex query to complex query cache.
92      *
93      * @param queryItem Query that will be added to complex query cache.
94      * @return Query added to complex query cache.
95      */

96     public abstract QueryCacheItem addComplexQuery(QueryCacheItem queryItem);
97
98     /**
99      * Removes complex query from complex query cache.
100      *
101      * @param queryItem Query that will be removed from complex query cache.
102      * @return Query removed from complex query cache.
103      */

104     public abstract QueryCacheItem removeComplexQuery(QueryCacheItem queryItem);
105     
106     /**
107      * Adds multi join query to complex query cache.
108      *
109      * @param queryItem Query that will be added to multi join query cache.
110      * @return Query added to multi join query cache.
111      */

112     public abstract QueryCacheItem addMultiJoinQuery(QueryCacheItem queryItem);
113
114     /**
115      * Removes multi join query from complex query cache.
116      *
117      * @param queryItem Query that will be removed from multi join query cache.
118      * @return Query removed from multi join query cache.
119      */

120     public abstract QueryCacheItem removeMultiJoinQuery(QueryCacheItem queryItem);
121
122     /**
123      * Returns query results from simple query cache.
124      *
125      * @param dbName Database name.
126      * @param query Query for which are results searched in simple query cache.
127      * @return Query results retrieved from simple cache, or null, if there are
128      * no results retrieved from simple query cache.
129      */

130     public abstract QueryResult getSimpleQueryResults(String JavaDoc dbName, String JavaDoc query);
131
132     /**
133      * Returns query results from simple query cache.
134      *
135      * @param dbName Database name.
136      * @param query Query for which are results searched in simple query cache.
137      * @param limit Specified number of results (database limit and read skip).
138      * @param maxdb Number of rows retrieved from database (or cache).
139      * @return Query results retrieved from simple cache, or null, if there are
140      * no results retrieved from simple query cache.
141      */

142     public abstract QueryResult getSimpleQueryResults(String JavaDoc dbName, String JavaDoc query, int limit, int maxdb);
143
144     /**
145      * Returns query results from simple query cache.
146      *
147      * @param dbName Database name.
148      * @param query Query for which are results searched in simple query cache.
149      * @param limit Specified number of results (database limit and read skip).
150      * @param maxdb Number of rows retrieved from database (or cache).
151      * @param unique If true, only unique results are returned.
152      * @return Query results retrieved from simple cache, or null, if there are
153      * no results retrieved from simple query cache.
154      */

155     public abstract QueryResult getSimpleQueryResults(String JavaDoc dbName, String JavaDoc query, int limit, int maxdb, boolean unique);
156
157     /**
158      * Returns query results from complex query cache.
159      *
160      * @param dbName Database name.
161      * @param query Query for which are results searched in complex query cache.
162      * @return Query results retrieved from complex cache, or null, if there are
163      * no results retrieved from complex query cache.
164      */

165     public abstract QueryResult getComplexQueryResults(String JavaDoc dbName, String JavaDoc query);
166
167     /**
168      * Returns query results from complex query cache.
169      *
170      * @param dbName Database name.
171      * @param query Query for which are results searched in complex query cache.
172      * @param limit Specified number of results (database limit and read skip).
173      * @param maxdb Number of rows retrieved from database (or cache).
174      * @return Query results retrieved from complex cache, or null, if there are
175      * no results retrieved from complex query cache.
176      */

177     public abstract QueryResult getComplexQueryResults(String JavaDoc dbName, String JavaDoc query, int limit, int maxdb);
178
179     /**
180      * Returns query results from complex query cache.
181      *
182      * @param dbName Database name.
183      * @param query Query for which are results searched in complex query cache.
184      * @param limit Specified number of results (database limit and read skip).
185      * @param maxdb Number of rows retrieved from database (or cache).
186      * @param unique If true, only unique results are returned.
187      * @return Query results retrieved from complex cache, or null, if there are
188      * no results retrieved from complex query cache.
189      */

190     public abstract QueryResult getComplexQueryResults(String JavaDoc dbName, String JavaDoc query, int limit, int maxdb, boolean unique);
191
192     /**
193      * Returns query results from multi join query cache.
194      *
195      * @param dbName Database name.
196      * @param query Query for which are results searched in multi join query cache.
197      * @return Query results retrieved from multi join cache, or null, if there are
198      * no results retrieved from multi join query cache.
199      */

200     public abstract QueryResult getMultiJoinQueryResults(String JavaDoc dbName, String JavaDoc query);
201
202     /**
203      * Returns query results from multi join query cache.
204      *
205      * @param dbName Database name.
206      * @param query Query for which are results searched in multi join query cache.
207      * @param limit Specified number of results (database limit and read skip).
208      * @param maxdb Number of rows retrieved from database (or cache).
209      * @return Query results retrieved from multi join cache, or null, if there
210      * are no results retrieved from multi join query cache.
211      */

212     public abstract QueryResult getMultiJoinQueryResults(String JavaDoc dbName, String JavaDoc query, int limit, int maxdb);
213
214     /**
215      * Returns query results from multi join query cache.
216      *
217      * @param dbName Database name.
218      * @param query Query for which are results searched in multi join query cache.
219      * @param limit Specified number of results (database limit and read skip).
220      * @param maxdb Number of rows retrieved from database (or cache).
221      * @param unique If true, only unique results are returned.
222      * @return Query results retrieved from multi join cache, or null, if there
223      * are no results retrieved from multi join query cache.
224      */

225     public abstract QueryResult getMultiJoinQueryResults(String JavaDoc dbName, String JavaDoc query, int limit, int maxdb, boolean unique);
226     
227     /**
228      * Returns query results from simple or complex query cache.
229      *
230      * @param dbName Database name.
231      * @param query Query for which are results searched in simple and complex
232      * query cache.
233      * @return Query results retrieved from simple or complex cache, or null,
234      * if there are no results retrieved from simple and complex query cache.
235      */

236     public abstract QueryResult getQueryResults(String JavaDoc dbName, String JavaDoc query);
237     
238     /**
239      *
240      */

241     final synchronized void lockSimpleComplexQCache() {
242         lockedSimpleComplexQCache = true;
243     }
244
245     /**
246      *
247      */

248     final synchronized void unlockSimpleComplexQCache() {
249         lockedSimpleComplexQCache = false;
250     }
251
252     /**
253      *
254      */

255     protected final synchronized boolean isLockedSimpleComplexQCache() {
256         return lockedSimpleComplexQCache;
257     }
258     
259    /**
260      *
261      */

262     final synchronized void lockMultiJoinQCache() {
263         lockedMultiJoinQCache = true;
264     }
265
266     /**
267      *
268      */

269     final synchronized void unlockMultiJoinQCache() {
270         lockedMultiJoinQCache = false;
271     }
272
273     /**
274      *
275      */

276     protected final synchronized boolean isLockedMultiJoinQCache() {
277         return lockedMultiJoinQCache;
278     }
279
280     /**
281      *
282      */

283     public abstract void removeEntries(Vector JavaDoc vec);
284
285     /**
286      *
287      */

288     public abstract void removeEntries() ;
289
290     /**
291      *
292      */

293     public abstract void emptyEntries(Vector JavaDoc vec, boolean incrementVersion) ;
294
295     /**
296      *
297      */

298     public abstract void emptyEntries() ;
299
300     /**
301      *
302      */

303     public abstract void makeInvisible(String JavaDoc cacheHandle) ;
304
305
306     /**
307      *
308      */

309     public abstract void makeVisible(String JavaDoc cacheHandle);
310     
311
312     public abstract CacheAdministration getCacheAdministration(int cacheType);
313     
314     /**
315      *
316      */

317     private boolean lockedSimpleComplexQCache = false;
318     
319     /**
320      *
321      */

322     private boolean lockedMultiJoinQCache = false;
323 }
324
Popular Tags