org.jboss.cache
Interface CacheSPI<K,V>

All Superinterfaces:
Cache<K,V>
All Known Implementing Classes:
CacheImpl

@ThreadSafe
public interface CacheSPI<K,V>
extends Cache<K,V>

A more detailed interface to Cache, which is used when writing plugins for or extending JBoss Cache. A reference to this interface should only be obtained when it is passed in to your code, for example when you write an Interceptor or CacheLoader.

You should NEVER attempt to directly cast a Cache instance to this interface. In future, the implementation may not allow it.

This interface contains overridden method signatures of some methods from Cache, overridden to ensure return types of Node are replaced with NodeSPI.

Since:
2.0.0
Author:
Manik Surtani (manik@jboss.org)
See Also:
NodeSPI, Cache, CacheLoader, Interceptor

Method Summary
 void addInterceptor(Interceptor i, int position)
          Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.
 BuddyManager getBuddyManager()
           
 CacheLoaderManager getCacheLoaderManager()
           
 java.lang.String getClusterName()
           
 GlobalTransaction getCurrentTransaction(javax.transaction.Transaction tx, boolean createIfNotExists)
          Returns the global transaction for this local transaction.
 java.util.List<Interceptor> getInterceptorChain()
           
 java.util.Map<java.lang.Thread,java.util.List<NodeLock>> getLockTable()
          Retrieves the current table of locks.
 Marshaller getMarshaller()
          Retrieves an instance of a Marshaller, which is capable of converting Java objects to bytestreams and back in an efficient manner, which is also interoperable with bytestreams produced/consumed by other versions of JBoss Cache.
 Notifier getNotifier()
           
 int getNumberOfAttributes()
           
 int getNumberOfNodes()
           
 RegionManager getRegionManager()
           
 NodeSPI<K,V> getRoot()
          Overrides Cache.getRoot() to return a NodeSPI instead of a Node.
 RPCManager getRPCManager()
          Gets a handle of the RPC manager.
 StateTransferManager getStateTransferManager()
           
 javax.transaction.TransactionManager getTransactionManager()
          Retrieves a reference to a running TransactionManager, if one is configured.
 TransactionTable getTransactionTable()
           
 GravitateResult gravitateData(Fqn<?> fqn, boolean searchBuddyBackupSubtrees)
          Used with buddy replication's data gravitation interceptor.
 NodeSPI<K,V> peek(Fqn<?> fqn, boolean includeDeletedNodes)
          Returns a node without accessing the interceptor chain.
 void removeInterceptor(int position)
          Removes the interceptor at a specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.
 
Methods inherited from interface org.jboss.cache.Cache
addCacheListener, addCacheListener, create, destroy, evict, get, getCacheListeners, getCacheListeners, getCacheStatus, getConfiguration, getInvocationContext, getLocalAddress, getMembers, getRegion, getVersion, move, put, put, putForExternalRead, remove, removeCacheListener, removeCacheListener, removeNode, removeRegion, setInvocationContext, start, stop
 

Method Detail

getRoot

NodeSPI<K,V> getRoot()
Overrides Cache.getRoot() to return a NodeSPI instead of a Node.

Specified by:
getRoot in interface Cache<K,V>
Returns:
the root node

getTransactionManager

javax.transaction.TransactionManager getTransactionManager()
Retrieves a reference to a running TransactionManager, if one is configured.

Returns:
a TransactionManager

getInterceptorChain

java.util.List<Interceptor> getInterceptorChain()
Returns:
an immutable List of Interceptors configured for this cache, or null if create() has not been invoked and the interceptors thus do not exist.

addInterceptor

void addInterceptor(Interceptor i,
                    int position)
Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.

Parameters:
i - the interceptor to add
position - the position to add the interceptor

removeInterceptor

void removeInterceptor(int position)
Removes the interceptor at a specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.

Parameters:
position - the position at which to remove an interceptor

getCacheLoaderManager

CacheLoaderManager getCacheLoaderManager()
Returns:
Retrieves a reference to the currently configured CacheLoaderManager if one or more cache loaders are configured, null otherwise.

getBuddyManager

BuddyManager getBuddyManager()
Returns:
an instance of BuddyManager if buddy replication is enabled, null otherwise.

getTransactionTable

TransactionTable getTransactionTable()
Returns:
the current TransactionTable

getRPCManager

RPCManager getRPCManager()
Gets a handle of the RPC manager.

Returns:
the RPCManager configured.

getStateTransferManager

StateTransferManager getStateTransferManager()
Returns:
the current StateTransferManager

getClusterName

java.lang.String getClusterName()
Returns:
the name of the cluster. Null if running in local mode.

getNumberOfAttributes

int getNumberOfAttributes()
Returns:
the number of attributes in the cache.

getNumberOfNodes

int getNumberOfNodes()
Returns:
the number of nodes in the cache.

getLockTable

java.util.Map<java.lang.Thread,java.util.List<NodeLock>> getLockTable()
Retrieves the current table of locks.

Returns:
lock table.

getRegionManager

RegionManager getRegionManager()
Returns:
the RegionManager

getCurrentTransaction

GlobalTransaction getCurrentTransaction(javax.transaction.Transaction tx,
                                        boolean createIfNotExists)
Returns the global transaction for this local transaction. Optionally creates a new global transaction if it does not exist.

Parameters:
tx - the current transaction
createIfNotExists - if true creates a new transaction if none exists
Returns:
a GlobalTransaction

getNotifier

Notifier getNotifier()
Returns:
the notifier attached with this instance of the cache. See Notifier, a class that is responsible for emitting notifications to registered CacheListeners.

peek

NodeSPI<K,V> peek(Fqn<?> fqn,
                  boolean includeDeletedNodes)
Returns a node without accessing the interceptor chain.

Parameters:
fqn - the Fqn to look up.
includeDeletedNodes - if you intend to see nodes marked as deleted within the current tx, set this to true
Returns:
a node if one exists or null

gravitateData

GravitateResult gravitateData(Fqn<?> fqn,
                              boolean searchBuddyBackupSubtrees)
Used with buddy replication's data gravitation interceptor. If marshalling is necessary, ensure that the cache is configured to use Configuration.useRegionBasedMarshalling and the Region pertaining to the Fqn passed in is activated, and has an appropriate ClassLoader.

Parameters:
fqn - the fqn to gravitate
searchBuddyBackupSubtrees - if true, buddy backup subtrees are searched and if false, they are not.
Returns:
a GravitateResult which contains the data for the gravitation

getMarshaller

Marshaller getMarshaller()
Retrieves an instance of a Marshaller, which is capable of converting Java objects to bytestreams and back in an efficient manner, which is also interoperable with bytestreams produced/consumed by other versions of JBoss Cache.

The use of this marshaller is the recommended way of creating efficient, compatible, byte streams from objects.

Returns:
an instance of Marshaller