KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > cache > result > ResultCacheDatabase


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): Nicolas Modrzyk.
23  */

24
25 package org.objectweb.cjdbc.controller.cache.result;
26
27 import org.objectweb.cjdbc.common.sql.AbstractWriteRequest;
28 import org.objectweb.cjdbc.common.sql.ParsingGranularities;
29 import org.objectweb.cjdbc.common.sql.UpdateRequest;
30 import org.objectweb.cjdbc.controller.cache.result.entries.AbstractResultCacheEntry;
31
32 /**
33  * This is a query cache implementation with a database granularity:
34  * <ul>
35  * <li><code>DATABASE</code>: the cache is flushed each time the database is
36  * updated (every INSERT, UPDATE, DELETE, ... statement).</li>
37  * </ul>
38  *
39  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
40  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
41  * @version 1.0
42  */

43
44 public class ResultCacheDatabase extends ResultCache
45 {
46
47   /**
48    * Builds a new ResultCache with a database granularity.
49    *
50    * @param maxEntries maximum number of entries
51    * @param pendingTimeout pending timeout for concurrent queries
52    */

53   public ResultCacheDatabase(int maxEntries, int pendingTimeout)
54   {
55     super(maxEntries, pendingTimeout);
56     parsingGranularity = ParsingGranularities.NO_PARSING;
57   }
58
59   /**
60    * @see org.objectweb.cjdbc.controller.cache.result.ResultCache#processAddToCache
61    */

62   protected void processAddToCache(AbstractResultCacheEntry qe)
63   {
64     return;
65   }
66
67   /**
68    * @see org.objectweb.cjdbc.controller.cache.result.AbstractResultCache#isUpdateNecessary(org.objectweb.cjdbc.common.sql.UpdateRequest)
69    */

70   public boolean isUpdateNecessary(UpdateRequest request)
71   {
72     return true;
73   }
74
75   /**
76    * @see org.objectweb.cjdbc.controller.cache.result.ResultCache#processWriteNotify(org.objectweb.cjdbc.common.sql.AbstractWriteRequest)
77    */

78   protected void processWriteNotify(AbstractWriteRequest request)
79   {
80     flushCache();
81   }
82
83   /**
84    * @see org.objectweb.cjdbc.controller.cache.result.ResultCache#getName()
85    */

86   public String JavaDoc getName()
87   {
88     return "database";
89   }
90
91 }
Popular Tags