Revision: 9222
Author: jean.deruelle
Date: Mon Jan  4 08:44:02 2010
Log: update Issue 1081

Fix CL issue on JB5, Removing the need to move some jars around to cope with it
http://code.google.com/p/mobicents/source/detail?r=9222

Modified:
/trunk/servers/cluster/cache/src/main/java/org/mobicents/cache/MobicentsCache.java
 /trunk/servers/jain-sip-ha/jboss-5/.classpath
/trunk/servers/jain-sip-ha/jboss-5/src/main/java/org/mobicents/ha/javax/sip/cache/ManagedMobicentsSipCache.java

=======================================
--- /trunk/servers/cluster/cache/src/main/java/org/mobicents/cache/MobicentsCache.java Wed Oct 28 20:38:14 2009 +++ /trunk/servers/cluster/cache/src/main/java/org/mobicents/cache/MobicentsCache.java Mon Jan 4 08:44:02 2010
@@ -3,6 +3,7 @@
 import org.apache.log4j.Logger;
 import org.jboss.cache.Cache;
 import org.jboss.cache.CacheManager;
+import org.jboss.cache.CacheStatus;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Region;
@@ -36,13 +37,20 @@
                this.managedCache = false;
                startCache();
        }
-
+       @Deprecated
public MobicentsCache(CacheManager haCacheManager, String cacheName) throws Exception {
                this.jBossCache = haCacheManager.getCache(cacheName, true);
                this.jBossCache.create();
                this.managedCache = true;
                startCache();
        }
+
+ public MobicentsCache(CacheManager haCacheManager, String cacheName, boolean managedCache) throws Exception {
+               this.jBossCache = haCacheManager.getCache(cacheName, true);
+               this.jBossCache.create();
+               this.managedCache = managedCache;
+               startCache();
+       }

        public MobicentsCache(Cache cache, String cacheName) {
                this.jBossCache = cache;
@@ -50,11 +58,11 @@
                startCache();
        }

-       private void startCache() {
+       protected void startCache() {
                if (jBossCache.getConfiguration().getCacheMode() == 
CacheMode.LOCAL) {
                        localMode = true;
                }
-               if (!managedCache) {
+ if (!managedCache && !(CacheStatus.STARTED == jBossCache.getCacheStatus())) {
                        jBossCache.start();
                }
                if (logger.isInfoEnabled()) {
=======================================
--- /trunk/servers/jain-sip-ha/jboss-5/.classpath       Tue Dec 22 06:14:14 2009
+++ /trunk/servers/jain-sip-ha/jboss-5/.classpath       Mon Jan  4 08:44:02 2010
@@ -22,8 +22,8 @@
<classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar"/> <classpathentry kind="var" path="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.CR5/jboss-metadata-1.0.0.CR5.jar"/> <classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnp-client/5.0.2.GA/jnp-client-5.0.2.GA.jar"/> - <classpathentry kind="var" path="M2_REPO/org/mobicents/cluster/cache/1.0.0BETA1-SNAPSHOT/cache-1.0.0BETA1-SNAPSHOT.jar"/> - <classpathentry kind="var" path="M2_REPO/org/mobicents/cluster/core/1.0.0BETA1-SNAPSHOT/core-1.0.0BETA1-SNAPSHOT.jar"/> + <classpathentry kind="var" path="M2_REPO/org/mobicents/cluster/cache/1.2-SNAPSHOT/cache-1.2-SNAPSHOT.jar"/> + <classpathentry kind="var" path="M2_REPO/org/mobicents/cluster/core/1.2-SNAPSHOT/core-1.2-SNAPSHOT.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/jain-sip-ha-core"/>
        <classpathentry kind="output" path="target/classes"/>
=======================================
--- /trunk/servers/jain-sip-ha/jboss-5/src/main/java/org/mobicents/ha/javax/sip/cache/ManagedMobicentsSipCache.java Wed Nov 4 10:13:06 2009 +++ /trunk/servers/jain-sip-ha/jboss-5/src/main/java/org/mobicents/ha/javax/sip/cache/ManagedMobicentsSipCache.java Mon Jan 4 08:44:02 2010
@@ -64,15 +64,21 @@
        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);
+//                             Context ctx = new InitialContext();
+// CacheManager cacheManager = (CacheManager) ctx.lookup("java:CacheManager"); if (clusteredSipStack.getStackLogger().isLoggingEnabled(StackLogger.TRACE_INFO)) {
                                        
clusteredSipStack.getStackLogger().logInfo(
"Mobicents JAIN SIP JBoss Cache Manager instance : " + cacheManager);
                                }
- cache = new MobicentsCache(cacheManager, configProperties.getProperty(CACHE_NAME,DEFAULT_CACHE_NAME)); + cache = new MobicentsCache(cacheManager, configProperties.getProperty(CACHE_NAME,DEFAULT_CACHE_NAME), false);
+                               
Thread.currentThread().setContextClassLoader(previousClassLoader);
                        } else {
String pojoConfigurationPath = configProperties.getProperty(JBOSS_CACHE_CONFIG_PATH, DEFAULT_FILE_CONFIG_PATH); if (clusteredSipStack.getStackLogger().isLoggingEnabled(StackLogger.TRACE_INFO)) {

Reply via email to