use of net.jforum.cache.Cacheable in project jforum2 by rafaelsteil.
the class ConfigLoader method startCacheEngine.
public static void startCacheEngine() {
try {
String cacheImplementation = SystemGlobals.getValue(ConfigKeys.CACHE_IMPLEMENTATION);
logger.info("Using cache engine: " + cacheImplementation);
cache = (CacheEngine) Class.forName(cacheImplementation).newInstance();
cache.init();
String s = SystemGlobals.getValue(ConfigKeys.CACHEABLE_OBJECTS);
if (s == null || s.trim().equals("")) {
logger.warn("Cannot find Cacheable objects to associate the cache engine instance.");
return;
}
String[] cacheableObjects = s.split(",");
for (int i = 0; i < cacheableObjects.length; i++) {
logger.info("Creating an instance of " + cacheableObjects[i]);
Object o = Class.forName(cacheableObjects[i].trim()).newInstance();
if (o instanceof Cacheable) {
((Cacheable) o).setCacheEngine(cache);
} else {
logger.error(cacheableObjects[i] + " is not an instance of net.jforum.cache.Cacheable");
}
}
} catch (Exception e) {
throw new CacheEngineStartupException("Error while starting the cache engine", e);
}
}
Aggregations