KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > Region


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache;
8
9 import org.jboss.cache.config.EvictionRegionConfig;
10 import org.jboss.cache.eviction.EvictedEventNode;
11 import org.jboss.cache.eviction.EvictionPolicy;
12 import org.jboss.cache.eviction.EvictionPolicyConfig;
13 import org.jboss.cache.eviction.LRUPolicy;
14
15 /**
16  * Represents a section of the cache, and characteristics such as class loading and activaton can be applied to regions.
17  *
18  * @author <a HREF="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
19  */

20 public interface Region extends Comparable JavaDoc<Region>
21 {
22    public enum Type
23    {
24       EVICTION, MARSHALLING, ANY
25    }
26
27    /**
28     * Registers a specific {@link ClassLoader} (rather than the default) for a region, represented by a {@link Fqn}.
29     *
30     * @param classLoader
31     */

32    void registerContextClassLoader(ClassLoader JavaDoc classLoader);
33
34    /**
35     * Unregisters any specific {@link ClassLoader}s from a region.
36     */

37    void unregisterContextClassLoader();
38
39    /**
40     * Activates a region for replication (by default, the entire cache is activated)
41     */

42    void activate();
43
44    /**
45     * Deactivates a region from being replicated.
46     */

47    void deactivate();
48
49    /**
50     * @return true if this region has been activated.
51     */

52    boolean isActive();
53
54    /**
55     * Looks up a {@link ClassLoader} for a given region.
56     *
57     * @return a ClassLoader
58     */

59    ClassLoader JavaDoc getClassLoader();
60
61    /**
62     * Configures an eviction policy for the current region.
63     *
64     * @param evictionPolicyConfig
65     */

66    void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig);
67
68    EvictionPolicyConfig getEvictionPolicyConfig();
69
70    EvictionPolicy getEvictionPolicy();
71
72    EvictionRegionConfig getEvictionRegionConfig();
73
74    void resetEvictionQueues();
75
76    int nodeEventQueueSize();
77
78    EvictedEventNode takeLastEventNode();
79
80    void putNodeEvent(EvictedEventNode event);
81
82    /**
83     * Add an event to the eviction queue marking a node as currently in use.
84     * If there is an {@link EvictionPolicy} associated with this region, and
85     * it respects this event ({@link LRUPolicy} does), then the node will not
86     * be evicted until {@link #unmarkNodeCurrentlyInUse(Fqn)} is invoked.
87     * <p/>
88     * This mechanism can be used to prevent eviction of data that the application
89     * is currently using, in the absence of any locks on the node where the
90     * data is stored.
91     *
92     * @param fqn Fqn of the node.
93     * @see #unmarkNodeCurrentlyInUse(Fqn)
94     */

95    void markNodeCurrentlyInUse(Fqn fqn, long timeout);
96
97    /**
98     * Add an event to the eviction queue indicating that a node is no longer in use.
99     *
100     * @param fqn Fqn of the node.
101     * @see #markNodeCurrentlyInUse(Fqn,long)
102     */

103    void unmarkNodeCurrentlyInUse(Fqn fqn);
104
105    Fqn getFqn();
106
107    /**
108     * Sets this region as active - this only marks a flag and does not activate the region. Use {@link #activate()}
109     * and {@link #deactivate()} for the full process.
110     *
111     * @param b
112     */

113    void setActive(boolean b);
114 }
115
Popular Tags