org.jboss.cache.loader
Class CacheLoaderManager

java.lang.Object
  extended by org.jboss.cache.loader.CacheLoaderManager

public class CacheLoaderManager
extends Object

Manages all cache loader functionality. This class is typically initialised with an XML DOM Element, represeting a cache loader configuration, or a CacheLoaderConfig object.

Usage:

CacheLoaderManager manager = new CacheLoaderManager(); manager.setConfig(myXmlSnippet, myTreeCache); CacheLoader loader = manager.getCacheLoader();

The XML configuration passed in would typically look like:

false /

org.jboss.cache.loader.FileCacheLoader true false false location=/tmp/file ]]>

Author:
Manik Surtani (manik AT jboss DOT org), Galder Zamarreno

Constructor Summary
CacheLoaderManager()
           
 
Method Summary
 CacheLoader getCacheLoader()
          Returns the cache loader
 CacheLoaderConfig getCacheLoaderConfig()
          Returns the configuration element of the cache loaders
 void injectDependencies(CacheSPI cache, Configuration configuration, RegionManager regionManager, ComponentRegistry registry)
           
 boolean isFetchPersistentState()
          Returns true if at least one of the configured cache loaders has set fetchPersistentState to true.
 boolean isPassivation()
          Tests if we're using passivation
 void preload(Fqn fqn, boolean preloadParents, boolean preloadChildren)
          Preloads a specific Fqn into the cache from the configured cacheloader
 void preloadCache()
          Performs a preload on the cache based on the cache loader preload configs used when configuring the cache.
 void purgeLoaders(boolean force)
           
protected  void setCacheInLoader(CacheSPI c, CacheLoader loader)
          Sets the cache instance associated with the given cache loader.
 void setConfig(CacheLoaderConfig config, CacheSPI cache, Configuration configuration)
          Sets a configuration object and creates a cacheloader accordingly.
 void startCacheLoader()
           
 void stopCacheLoader()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheLoaderManager

public CacheLoaderManager()
Method Detail

injectDependencies

public void injectDependencies(CacheSPI cache,
                               Configuration configuration,
                               RegionManager regionManager,
                               ComponentRegistry registry)

setConfig

public void setConfig(CacheLoaderConfig config,
                      CacheSPI cache,
                      Configuration configuration)
               throws CacheException
Sets a configuration object and creates a cacheloader accordingly. Primarily used for testing.

Parameters:
config -
cache -
Throws:
CacheException

setCacheInLoader

protected void setCacheInLoader(CacheSPI c,
                                CacheLoader loader)
Sets the cache instance associated with the given cache loader. This method was created for testing purpouses so that it can be overriden in the mock version of the CacheLoaderManager.

Parameters:
c - instance of cache to be set in cache loader
loader - cache loader to which assign the cache instance

preloadCache

public void preloadCache()
                  throws CacheException
Performs a preload on the cache based on the cache loader preload configs used when configuring the cache.

Throws:
Exception
CacheException

preload

public void preload(Fqn fqn,
                    boolean preloadParents,
                    boolean preloadChildren)
             throws CacheException
Preloads a specific Fqn into the cache from the configured cacheloader

Parameters:
fqn - fqn to preload
preloadParents - whether we preload parents
preloadChildren - whether we preload children
Throws:
CacheException - if we are unable to preload

getCacheLoaderConfig

public CacheLoaderConfig getCacheLoaderConfig()
Returns the configuration element of the cache loaders


getCacheLoader

public CacheLoader getCacheLoader()
Returns the cache loader


isPassivation

public boolean isPassivation()
Tests if we're using passivation


isFetchPersistentState

public boolean isFetchPersistentState()
Returns true if at least one of the configured cache loaders has set fetchPersistentState to true.


stopCacheLoader

public void stopCacheLoader()

startCacheLoader

public void startCacheLoader()
                      throws CacheException
Throws:
CacheException

purgeLoaders

public void purgeLoaders(boolean force)
                  throws Exception
Throws:
Exception


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.