KickJava   Java API By Example, From Geeks To Geeks.

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


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.buddyreplication.BuddyManager;
10 import org.jboss.cache.buddyreplication.GravitateResult;
11 import org.jboss.cache.interceptors.Interceptor;
12 import org.jboss.cache.loader.CacheLoader;
13 import org.jboss.cache.loader.CacheLoaderManager;
14 import org.jboss.cache.lock.NodeLock;
15 import org.jboss.cache.marshall.VersionAwareMarshaller;
16 import org.jboss.cache.notifications.Notifier;
17 import org.jboss.cache.statetransfer.StateTransferManager;
18
19 import javax.transaction.Transaction JavaDoc;
20 import javax.transaction.TransactionManager JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Map JavaDoc;
23
24 /**
25  * A more detailed interface to {@link Cache}, which is used when writing plugins for or extending JBoss Cache. A reference
26  * to this interface should only be obtained when it is passed in to your code, for example when you write an
27  * {@link Interceptor}, {@link CacheLoader} or {@link CacheListener}.
28  * <p/>
29  * <B><I>You should not attempt to directly cast a {@link Cache} instance to this interface, as in future, the implementation may not allow it.</I></B>
30  * <p/>
31  * This interface contains overridden method signatures of some methods from {@link Cache}, overridden to ensure return
32  * types of {@link Node} are replaced with {@link NodeSPI}.
33  * <p/>
34  *
35  * @author <a HREF="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
36  * @see NodeSPI
37  * @see Cache
38  * @since 2.0.0
39  */

40 public interface CacheSPI extends Cache
41 {
42    /**
43     * Overrides {@link org.jboss.cache.Cache#getRoot()} to return a {@link org.jboss.cache.NodeSPI} instead of a {@link org.jboss.cache.Node}.
44     */

45    NodeSPI getRoot();
46
47    /**
48     * Retrieves a reference to a running {@link javax.transaction.TransactionManager}, if one is configured.
49     *
50     * @return a TransactionManager
51     */

52    TransactionManager JavaDoc getTransactionManager();
53
54    /**
55     * @return an immutable {@link List} of {@link Interceptor}s configured for this cache.
56     */

57    List JavaDoc<Interceptor> getInterceptorChain();
58
59    /**
60     * Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain
61     * is at position 0 and the last one at getInterceptorChain().size() - 1.
62     *
63     * @param i the interceptor to add
64     * @param position the position to add the interceptor
65     */

66    void addInterceptor(Interceptor i, int position);
67
68    /**
69     * Removes the interceptor at a specified position, where the first interceptor in the chain
70     * is at position 0 and the last one at getInterceptorChain().size() - 1.
71     *
72     * @param position the position at which to remove an interceptor
73     */

74    void removeInterceptor(int position);
75
76    /**
77     * @return Retrieves a reference to the currently configured {@link org.jboss.cache.loader.CacheLoaderManager} if one or more cache loaders are configured, null otherwise.
78     */

79    CacheLoaderManager getCacheLoaderManager();
80
81    /**
82     * @return an instance of {@link BuddyManager} if buddy replication is enabled, null otherwise.
83     */

84    BuddyManager getBuddyManager();
85
86    /**
87     * @return the current {@link TransactionTable}
88     */

89    TransactionTable getTransactionTable();
90
91    /**
92     * Gets a handle of the RPC manager.
93     *
94     * @return the {@link org.jboss.cache.RPCManager} configured.
95     */

96    RPCManager getRPCManager();
97
98    /**
99     * @return the current {@link org.jboss.cache.statetransfer.StateTransferManager}
100     */

101    StateTransferManager getStateTransferManager();
102
103    /**
104     * @return the name of the cluster. Null if running in local mode.
105     */

106    String JavaDoc getClusterName();
107
108    /**
109     * @return the number of attributes in the cache.
110     */

111    int getNumberOfAttributes();
112
113    /**
114     * @return the number of nodes in the cache.
115     */

116    int getNumberOfNodes();
117
118    /**
119     * Retrieves the current table of locks.
120     *
121     * @return lock table.
122     */

123    Map JavaDoc<Thread JavaDoc, List JavaDoc<NodeLock>> getLockTable();
124
125    /**
126     * @return the {@link org.jboss.cache.RegionManager}
127     */

128    RegionManager getRegionManager();
129
130    /**
131     * Returns the global transaction for this local transaction.
132     * Optionally creates a new global transaction if it does not exist.
133     *
134     * @param tx the current transaction
135     * @param createIfNotExists if true creates a new transaction if none exists
136     * @return a GlobalTransaction
137     */

138    GlobalTransaction getCurrentTransaction(Transaction JavaDoc tx, boolean createIfNotExists);
139
140    /**
141     * @return the notifier attached with this instance of the cache. See {@link Notifier}, a class
142     * that is responsible for emitting notifications to registered {@link CacheListener}s.
143     */

144    Notifier getNotifier();
145
146    /**
147     * Returns a node without accessing the interceptor chain.
148     *
149     * @param fqn the Fqn to look up.
150     * @return a node if one exists or null
151     */

152    NodeSPI peek(Fqn fqn);
153
154    /**
155     * Used with buddy replication's data gravitation interceptor
156     *
157     * @param fqn the fqn to gravitate
158     * @param searchBuddyBackupSubtrees if true, buddy backup subtrees are searched and if false, they are not.
159     * @param marshal if true, the data is marshalled using the {@link org.jboss.cache.marshall.VersionAwareMarshaller}
160     * @return a List which should be a data structure
161     */

162    GravitateResult gravitateData(Fqn fqn, boolean searchBuddyBackupSubtrees, boolean marshal);
163
164    /**
165     * Retrieves an instance of a {@link VersionAwareMarshaller}, which is capable of
166     * converting Java objects to bytestreams and back in an efficient manner, which is
167     * also interoperable with bytestreams produced/consumed by other versions of JBoss
168     * Cache.
169     * <p/>
170     * The use of this marshaller is the <b>recommended</b> way of creating efficient,
171     * compatible, version-aware byte streams from objects.
172     *
173     * @return an instance of {@link VersionAwareMarshaller}
174     */

175    VersionAwareMarshaller getMarshaller();
176 }
177
Popular Tags