Search in sources :

Example 1 with MobicentsCache

use of org.mobicents.cache.MobicentsCache in project jain-sip.ha by RestComm.

the class ManagedMobicentsSipCache method init.

@Override
public void init() throws SipCacheException {
    try {
        if (configProperties.getProperty(ManagedMobicentsSipCache.STANDALONE) == null || "false".equals(configProperties.getProperty(ManagedMobicentsSipCache.STANDALONE))) {
            ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(CacheManagerLocator.class.getClassLoader());
            CacheManagerLocator locator = CacheManagerLocator.getCacheManagerLocator();
            // Locator accepts as param a set of JNDI properties to help in lookup;
            // this isn't necessary inside the AS
            CacheManager cacheManager = locator.getCacheManager(null);
            // CacheManager cacheManager = (CacheManager) ctx.lookup("java:CacheManager");
            if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_INFO)) {
                clusteredlogger.logInfo("Mobicents JAIN SIP JBoss Cache Manager instance : " + cacheManager);
            }
            cluster = new DefaultMobicentsCluster(new MobicentsCache(cacheManager, configProperties.getProperty(CACHE_NAME, DEFAULT_CACHE_NAME), false), null, null);
            Thread.currentThread().setContextClassLoader(previousClassLoader);
        } else {
            String pojoConfigurationPath = configProperties.getProperty(JBOSS_CACHE_CONFIG_PATH, DEFAULT_FILE_CONFIG_PATH);
            if (clusteredlogger.isLoggingEnabled(StackLogger.TRACE_INFO)) {
                clusteredlogger.logInfo("Mobicents JAIN SIP JBoss Cache Configuration path is : " + pojoConfigurationPath);
            }
            cluster = new DefaultMobicentsCluster(new MobicentsCache(pojoConfigurationPath), null, null);
            JBossJainSipCacheListener listener = new JBossJainSipCacheListener(clusteredSipStack);
            cluster.getMobicentsCache().getJBossCache().addCacheListener(listener);
        }
    } catch (Exception e) {
        throw new SipCacheException("Couldn't init Restcomm Cache", e);
    }
}
Also used : CacheManager(org.jboss.cache.CacheManager) MobicentsCache(org.mobicents.cache.MobicentsCache) CacheManagerLocator(org.jboss.ha.framework.server.CacheManagerLocator) DefaultMobicentsCluster(org.mobicents.cluster.DefaultMobicentsCluster)

Aggregations

CacheManager (org.jboss.cache.CacheManager)1 CacheManagerLocator (org.jboss.ha.framework.server.CacheManagerLocator)1 MobicentsCache (org.mobicents.cache.MobicentsCache)1 DefaultMobicentsCluster (org.mobicents.cluster.DefaultMobicentsCluster)1