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:12:29 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 7c44ccddb -> 5c3be52b1


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

This reverts commit 7c44ccddb359442b47d327bf8e65d2bac1cd1832.


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

Branch: refs/heads/2.7.x-fixes
Commit: 34f2ec94fb8c8d514ad97c77e0a7e7a161253276
Parents: 7c44ccd
Author: Jason Pell <jpell@apache.org>
Authored: Sun Jun 15 13:08:34 2014 +1000
Committer: Jason Pell <jpell@apache.org>
Committed: Sun Jun 15 13:08:34 2014 +1000

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/34f2ec94/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 df40b2c..3b343b8 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;
         String busId = "";

http://git-wip-us.apache.org/repos/asf/cxf/blob/34f2ec94/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/34f2ec94/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 3ee6c84..cc894f7 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
@@ -177,11 +177,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/34f2ec94/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());
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/34f2ec94/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/EHCacheIdentityCache.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/EHCacheIdentityCache.java
b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/EHCacheIdentityCache.java
index 64a825f..b9257c0 100644
--- a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/EHCacheIdentityCache.java
+++ b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/cache/EHCacheIdentityCache.java
@@ -231,11 +231,6 @@ public class EHCacheIdentityCache
     
     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;


Mime
View raw message