use of org.mobicents.cluster.DefaultMobicentsCluster 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);
}
}
Aggregations