KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 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): Nicolas Modrzyk
22  * Contributor(s): Emmanuel Cecchet.
23  */

24
25 package org.objectweb.cjdbc.controller.cache.result;
26
27 import org.objectweb.cjdbc.common.i18n.Translate;
28 import org.objectweb.cjdbc.common.log.Trace;
29 import org.objectweb.cjdbc.common.sql.SelectRequest;
30 import org.objectweb.cjdbc.controller.cache.result.entries.AbstractResultCacheEntry;
31 import org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet;
32
33 /**
34  * Abstract class for the different cache actions. We need this class for adding
35  * versatility in the parameters of each Caching action.
36  *
37  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
38  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
39  * @version 1.0
40  */

41 public abstract class CacheBehavior
42 {
43   Trace logger = Trace.getLogger(CacheBehavior.class.getName());
44
45   protected CacheBehavior()
46   {
47     logger.debug(Translate.get("cachebehavior.new.action", getType()));
48   }
49
50   /**
51    * The name of the class instance
52    *
53    * @return class name of the current type
54    */

55   public String JavaDoc getType()
56   {
57     return this.getClass().getName();
58   }
59
60   /**
61    * Builds a cache entry from a <code>SelectRequest</code> and a
62    * <code>ControllerResultSet</code>. This cache entry can then be inserted
63    * in the cache.
64    *
65    * @param sqlQuery entry to add in the cache
66    * @param result value to add in the cache
67    * @param cache reference for EagerCaching in case the entry needs to remove
68    * itself from the cache.
69    * @return the query cache entry to add to the cache
70    */

71   public abstract AbstractResultCacheEntry getCacheEntry(
72       SelectRequest sqlQuery, ControllerResultSet result,
73       AbstractResultCache cache);
74
75   /**
76    * Implementation specific xml dump of the cache behavior.
77    *
78    * @return xml dump of the cache behavior
79    * @see org.objectweb.cjdbc.common.xml.XmlComponent#getXml()
80    */

81   public abstract String JavaDoc getXml();
82 }
Popular Tags