Search in sources :

Example 1 with InitializationException

use of org.jivesoftware.util.InitializationException in project Openfire by igniterealtime.

the class CacheFactory method initialize.

public static synchronized void initialize() throws InitializationException {
    try {
        localCacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(localCacheFactoryClass).newInstance();
        cacheFactoryStrategy = localCacheFactoryStrategy;
        // Update the JID-internal caches, if they're configured differently than their default.
        JID.NODEPREP_CACHE.policy().eviction().get().setMaximum(getMaxCacheSize("jidNodeprep"));
        JID.NODEPREP_CACHE.policy().expireAfterWrite().get().setExpiresAfter(getMaxCacheLifetime("jidNodeprep"), TimeUnit.MILLISECONDS);
        JID.DOMAINPREP_CACHE.policy().eviction().get().setMaximum(getMaxCacheSize("jidDomainprep"));
        JID.DOMAINPREP_CACHE.policy().expireAfterWrite().get().setExpiresAfter(getMaxCacheLifetime("jidDomainprep"), TimeUnit.MILLISECONDS);
        JID.RESOURCEPREP_CACHE.policy().eviction().get().setMaximum(getMaxCacheSize("jidResourceprep"));
        JID.RESOURCEPREP_CACHE.policy().expireAfterWrite().get().setExpiresAfter(getMaxCacheLifetime("jidResourceprep"), TimeUnit.MILLISECONDS);
        // Mock cache creation for the JID-internal classes, by wrapping them in a compatibility layer.
        caches.put("JID Node-parts", CaffeineCache.of(JID.NODEPREP_CACHE, "JID Node-parts"));
        caches.put("JID Domain-parts", CaffeineCache.of(JID.DOMAINPREP_CACHE, "JID Domain-parts"));
        caches.put("JID Resource-parts", CaffeineCache.of(JID.RESOURCEPREP_CACHE, "JID Resource-parts"));
    } catch (Exception e) {
        log.error("Failed to instantiate local cache factory strategy: " + localCacheFactoryClass, e);
        throw new InitializationException(e);
    }
    consistencyMonitor = ConsistencyMonitor.getInstance();
}
Also used : InitializationException(org.jivesoftware.util.InitializationException) InitializationException(org.jivesoftware.util.InitializationException)

Aggregations

InitializationException (org.jivesoftware.util.InitializationException)1