cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jp...@apache.org
Subject [1/2] git commit: Revert "PMUD-5802 added ability to use a global ehcache manager"
Date Sun, 15 Jun 2014 03:13:19 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.6.x-fixes fdbddc706 -> f6e1f67c2


Revert "PMUD-5802 added ability to use a global ehcache manager"

This reverts commit fdbddc70638dca598b1ca1285756353338c6c36b.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/65a2c760
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/65a2c760
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/65a2c760

Branch: refs/heads/2.6.x-fixes
Commit: 65a2c76015a39b15f621b775f426a756cceee613
Parents: fdbddc7
Author: Jason Pell <jpell@apache.org>
Authored: Sun Jun 15 13:12:45 2014 +1000
Committer: Jason Pell <jpell@apache.org>
Committed: Sun Jun 15 13:12:45 2014 +1000

----------------------------------------------------------------------
 .../ws/security/cache/EHCacheManagerHolder.java | 59 ++++++--------------
 .../ws/security/cache/EHCacheReplayCache.java   |  6 --
 .../security/tokenstore/EHCacheTokenStore.java  |  5 --
 .../cache/EHCacheManagerHolderTest.java         | 46 ++-------------
 4 files changed, 23 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/65a2c760/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
index 19ff8d9..2bd8410 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
@@ -40,12 +40,9 @@ import org.apache.cxf.resource.ResourceManager;
  * We need to reference count the EHCacheManager things
  */
 public final class EHCacheManagerHolder {
-    public static final String GLOBAL_EHCACHE_MANAGER_NAME = 
-            "ws-security.global.ehcachemanager";
-    
     private static final ConcurrentHashMap<String, AtomicInteger> COUNTS 
         = new ConcurrentHashMap<String, AtomicInteger>(8, 0.75f, 2);
-    
+
     private static Method cacheManagerCreateMethodNoArg;
     private static Method createMethodURLArg;
     private static Method cacheManagerCreateMethodConfigurationArg;
@@ -94,50 +91,30 @@ public final class EHCacheManagerHolder {
     
     public static CacheManager getCacheManager(Bus bus, URL configFileURL) {
         CacheManager cacheManager = null;
-        
-        String globalCacheManagerName = getGlobalCacheManagerName(bus);
-        if (globalCacheManagerName != null) {
-            cacheManager = CacheManager.getCacheManager(globalCacheManagerName);
-        }
-        
-        // notice for a global cache manager, we skip the count stuff which
-        // means the release cache manager method below is a no op, as the
-        // COUNT will not have been initialised.
+        if (configFileURL == null) {
+            //using the default
+            cacheManager = findDefaultCacheManager(bus);
+        }
         if (cacheManager == null) {
             if (configFileURL == null) {
-                //using the default
-                cacheManager = findDefaultCacheManager(bus);
-            }
-            
-            if (cacheManager == null) {
-                if (configFileURL == null) {
-                    cacheManager = createCacheManager();
-                } else {
-                    cacheManager = createCacheManager(configFileURL);
-                }
-            }
-            
-            AtomicInteger a = COUNTS.get(cacheManager.getName());
-            if (a == null) {
-                COUNTS.putIfAbsent(cacheManager.getName(), new AtomicInteger());
-                a = COUNTS.get(cacheManager.getName());
-            }
-            if (a.incrementAndGet() == 1) {
-                //System.out.println("Create!! " + cacheManager.getName());
+                cacheManager = createCacheManager();
+            } else {
+                cacheManager = createCacheManager(configFileURL);
             }
         }
-        return cacheManager;
-    }
-
-    private static String getGlobalCacheManagerName(Bus bus) {
-        if (bus != null) {
-            return (String) bus.getProperty(GLOBAL_EHCACHE_MANAGER_NAME);
-        } else {
-            return null;
+        AtomicInteger a = COUNTS.get(cacheManager.getName());
+        if (a == null) {
+            COUNTS.putIfAbsent(cacheManager.getName(), new AtomicInteger());
+            a = COUNTS.get(cacheManager.getName());
         }
+        if (a.incrementAndGet() == 1) {
+            //System.out.println("Create!! " + cacheManager.getName());
+        }
+        return cacheManager;
     }
-
+    
     private static CacheManager findDefaultCacheManager(Bus bus) {
+
         String defaultConfigFile = "cxf-ehcache.xml";
         URL configFileURL = null;
         if (bus != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/65a2c760/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
index eef974d..2fef240 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
@@ -129,15 +129,9 @@ public class EHCacheReplayCache implements ReplayCache, Closeable, BusLifeCycleL
 
     public synchronized void close() {
         if (cacheManager != null) {
-            // this step is especially important for global shared cache manager
-            if (cache != null) {
-                cacheManager.removeCache(cache.getName());
-            }
-            
             EHCacheManagerHolder.releaseCacheManger(cacheManager);
             cacheManager = null;
             cache = null;
-            
             if (bus != null) {
                 bus.getExtension(BusLifeCycleManager.class).unregisterLifeCycleListener(this);
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/65a2c760/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
index 7a2660f..1d09401 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
@@ -178,11 +178,6 @@ public class EHCacheTokenStore implements TokenStore, Closeable, BusLifeCycleLis
 
     public void close() {
         if (cacheManager != null) {
-            // this step is especially important for global shared cache manager
-            if (cache != null) {
-                cacheManager.removeCache(cache.getName());
-            }
-            
             EHCacheManagerHolder.releaseCacheManger(cacheManager);
             cacheManager = null;
             cache = null;

http://git-wip-us.apache.org/repos/asf/cxf/blob/65a2c760/rt/ws/security/src/test/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolderTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolderTest.java
b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolderTest.java
index e1a8558..b062230 100644
--- a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolderTest.java
+++ b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolderTest.java
@@ -21,15 +21,18 @@ package org.apache.cxf.ws.security.cache;
 
 import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Status;
+
 import net.sf.ehcache.config.Configuration;
 import net.sf.ehcache.config.ConfigurationFactory;
 
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
 import org.junit.Assert;
 import org.junit.Test;
 
+/**
+ * 
+ */
 public class EHCacheManagerHolderTest extends Assert {
+
     @Test
     public void testCreateCacheManager() {
         Configuration conf = 
@@ -50,45 +53,6 @@ public class EHCacheManagerHolderTest extends Assert {
         
         manager2.shutdown();
         assertEquals(Status.STATUS_SHUTDOWN, manager2.getStatus());
-    }
-    
-    @Test
-    public void testUseGlobalManager() {
-        Bus bus = BusFactory.getThreadDefaultBus();
-        
-        Configuration conf = 
-                ConfigurationFactory.parseConfiguration(
-                        EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
-        conf.setName("myGlobalConfig");
-        
-        EHCacheManagerHolder.createCacheManager(conf);
-        
-        CacheManager manager = EHCacheManagerHolder.getCacheManager(bus, 
-                EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
-        
-        assertFalse(manager.getName().equals("myGlobalConfig"));
-        EHCacheManagerHolder.releaseCacheManger(manager);
-        assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
-        
-        bus.setProperty(EHCacheManagerHolder.GLOBAL_EHCACHE_MANAGER_NAME, "myGlobalConfig");
-        
-        manager = EHCacheManagerHolder.getCacheManager(bus, 
-                EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
-        
-        assertEquals("myGlobalConfig", manager.getName());
-        EHCacheManagerHolder.releaseCacheManger(manager);
-        assertEquals(Status.STATUS_ALIVE, manager.getStatus());
-        
-        manager.shutdown();
-        assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
-        
-        bus.setProperty(EHCacheManagerHolder.GLOBAL_EHCACHE_MANAGER_NAME, "myGlobalConfigXXX");
-        
-        manager = EHCacheManagerHolder.getCacheManager(bus, 
-                EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
         
-        assertFalse(manager.getName().equals("myGlobalConfig"));
-        EHCacheManagerHolder.releaseCacheManger(manager);
-        assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
     }
 }


Mime
View raw message