KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > perseus > cache > replacement > api > ReplacementManager


1 /**
2  * Copyright (C) 2001-2002
3  * - France Telecom R&D
4  * - Laboratoire Logiciels, Systemes, Reseaux - UMR 5526, CNRS-INPG-UJF
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Release: 1.0
21  *
22  * Authors:
23  *
24  */

25
26 package org.objectweb.perseus.cache.replacement.api;
27
28 import org.objectweb.perseus.cache.api.CacheException;
29 import org.objectweb.perseus.cache.api.FixableCacheEntry;
30 import org.objectweb.perseus.cache.api.UnbindManager;
31
32 /**
33  * It defines the commun methods associated to ReplacementManager
34  * implementations. Every Cache must have a ReplacementManager.
35  * The role of a ReplacementManager is to chose a set of objects to be
36  * evicted from the cache, whenever cache space is needed (e.g. to
37  * store a recently arrived object). Typical implementations for
38  * ReplacementManagers include LRU, MRU, FIFO based.
39  *
40  * @author Luciano Garcia-Banuelos (Luciano.Garcia@imag.fr)
41  */

42 public interface ReplacementManager extends UnbindManager {
43
44     /**
45      *
46      * @param entry The cache entry that has been accessed.
47      * @exception CacheException Whenever an internal error occurs.
48      */

49     void addForReplacement(FixableCacheEntry entry) throws CacheException;
50
51     /**
52      * This method is called by the CacheManager in order to signal that an
53      * entry has been really evicted. In fact the eviction has been previously
54      * requested by the ReplacementManager, and now the GC garbaged an entry.
55      * @param oid is the evicted cache entry
56      */

57     void removeForReplacement(Object JavaDoc oid);
58
59     /**
60      * Called whenever an object has been accessed. Thus, this method,
61      * gives hints about recency/frequency of use. This hints are used
62      * within the replacement algorithm.
63      *
64      * @param entry The cache entry that has been accessed.
65      * @exception CacheException Whenever an internal error occurs.
66      **/

67     void adjustForReplacement(FixableCacheEntry entry) throws CacheException;
68
69
70     /**
71      * It forces the replacement manager to free CacheEntry instances from the
72      * cahce.
73      * @param capacity is the quantity of space required by the cache.
74      */

75     int forceFree(int capacity) throws CacheException;
76 }
77
Popular Tags