01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2002-2004 French National Institute For Research In Computer
04: * Science And Control (INRIA).
05: * Contact: sequoia@continuent.org
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: *
19: * Initial developer(s): Nicolas Modrzyk
20: * Contributor(s): Emmanuel Cecchet.
21: */package org.continuent.sequoia.controller.cache.result;
22:
23: import org.continuent.sequoia.common.i18n.Translate;
24: import org.continuent.sequoia.common.log.Trace;
25: import org.continuent.sequoia.controller.backend.result.ControllerResultSet;
26: import org.continuent.sequoia.controller.cache.result.entries.AbstractResultCacheEntry;
27: import org.continuent.sequoia.controller.requests.SelectRequest;
28:
29: /**
30: * Abstract class for the different cache actions. We need this class for adding
31: * versatility in the parameters of each Caching action.
32: *
33: * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
34: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
35: * @version 1.0
36: */
37: public abstract class CacheBehavior {
38: Trace logger = Trace.getLogger(CacheBehavior.class.getName());
39:
40: protected CacheBehavior() {
41: logger.debug(Translate.get("cachebehavior.new.action",
42: getType()));
43: }
44:
45: /**
46: * The name of the class instance
47: *
48: * @return class name of the current type
49: */
50: public String getType() {
51: return this .getClass().getName();
52: }
53:
54: /**
55: * Builds a cache entry from a <code>SelectRequest</code> and a
56: * <code>ControllerResultSet</code>. This cache entry can then be inserted
57: * in the cache.
58: *
59: * @param sqlQuery entry to add in the cache
60: * @param result value to add in the cache
61: * @param cache reference for EagerCaching in case the entry needs to remove
62: * itself from the cache.
63: * @return the query cache entry to add to the cache
64: */
65: public abstract AbstractResultCacheEntry getCacheEntry(
66: SelectRequest sqlQuery, ControllerResultSet result,
67: AbstractResultCache cache);
68:
69: /**
70: * Implementation specific xml dump of the cache behavior.
71: *
72: * @return xml dump of the cache behavior
73: * @see org.continuent.sequoia.common.xml.XmlComponent#getXml()
74: */
75: public abstract String getXml();
76: }
|