Search in sources :

Example 1 with Cacheable

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);
    }
}
Also used : Cacheable(net.jforum.cache.Cacheable) CacheEngineStartupException(net.jforum.exceptions.CacheEngineStartupException) IOException(java.io.IOException) CacheEngineStartupException(net.jforum.exceptions.CacheEngineStartupException) SchedulerException(org.quartz.SchedulerException) ForumException(net.jforum.exceptions.ForumException)

Aggregations

IOException (java.io.IOException)1 Cacheable (net.jforum.cache.Cacheable)1 CacheEngineStartupException (net.jforum.exceptions.CacheEngineStartupException)1 ForumException (net.jforum.exceptions.ForumException)1 SchedulerException (org.quartz.SchedulerException)1