KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > eviction > EvictionPolicy


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.eviction;
8
9 import org.jboss.cache.CacheImpl;
10 import org.jboss.cache.Fqn;
11
12 import java.util.Set JavaDoc;
13
14 /**
15  * Generic eviction policy interface.
16  * <p/>
17  * None of the Eviction classes are thread safe. It is assumed that an individual instance of an EvictionPolicy/
18  * EvictionAlgorithm/EvictionQueue/EvictionConfiguration are only operated on by one thread at any given time.
19  *
20  * @author Ben Wang 2-2004
21  * @author Daniel Huang - dhuang@jboss.org - 10/2005
22  */

23 public interface EvictionPolicy
24 {
25    /**
26     * Evict a node form the underlying cache.
27     *
28     * @param fqn DataNode corresponds to this fqn.
29     * @throws Exception
30     */

31    void evict(Fqn fqn) throws Exception JavaDoc;
32
33    /**
34     * Return children names as Objects
35     *
36     * @param fqn
37     * @return Child names under given fqn
38     */

39    Set JavaDoc getChildrenNames(Fqn fqn);
40
41    /**
42     * Is this a leaf node?
43     *
44     * @param fqn
45     * @return true/false if leaf node.
46     */

47    boolean hasChild(Fqn fqn);
48
49    Object JavaDoc getCacheData(Fqn fqn, Object JavaDoc key);
50
51    /**
52     * Method called to configure this implementation.
53     */

54    void configure(CacheImpl cache);
55
56    /**
57     * Get the associated EvictionAlgorithm used by the EvictionPolicy.
58     * <p/>
59     * This relationship should be 1-1.
60     *
61     * @return An EvictionAlgorithm implementation.
62     */

63    EvictionAlgorithm getEvictionAlgorithm();
64
65    /**
66     * The EvictionPolicyConfig implementation class used by this EvictionPolicy.
67     *
68     * @return EvictionPolicyConfig implementation class.
69     */

70    Class JavaDoc<EvictionPolicyConfig> getEvictionConfigurationClass();
71
72    /**
73     * This method will be invoked prior to an event being processed for a node
74     * with the specified Fqn.
75     * <p/>
76     * This method provides a way to optimize the performance of eviction by
77     * signalling that the node associated with the specified Fqn should not be
78     * subject to normal eviction processing. It can also be used to filter
79     * out certain {@link NodeEventType event types} in which the particular
80     * eviction algorithm has no interest.
81     * </p>
82     * <p/>
83     * If this method returns false then the event is processed normally
84     * and eviction processing for the node continues. As a result, the event
85     * will be added to the {@link org.jboss.cache.Region eviction region's} event queue where
86     * at some later point the particular algorithm of the eviction policy
87     * can use it to decide whether to call {@link #evict(Fqn)}.
88     * </p>
89     * <p/>
90     * If this method returns true, then the event is ignored and will not factor
91     * in any subsequent eviction processing.
92     * </p>
93     *
94     * @param fqn The Fqn of the node associated with the event.
95     * @param eventType the type of the event
96     * @return <code>true</code> to ignore events of this type for this Fqn,
97     * <code>false</code> to process events normally.
98     */

99    boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType);
100 }
101
Popular Tags