cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1336269 - in /cxf/branches/2.4.x-fixes: ./ rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/
Date Wed, 09 May 2012 16:13:39 GMT
Author: dkulp
Date: Wed May  9 16:13:39 2012
New Revision: 1336269

URL: http://svn.apache.org/viewvc?rev=1336269&view=rev
Log:
Merged revisions 1336257 via  svn merge from
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes

........
  r1336257 | dkulp | 2012-05-09 12:07:06 -0400 (Wed, 09 May 2012) | 10 lines
  
  Merged revisions 1332833 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1332833 | dkulp | 2012-05-01 17:15:00 -0400 (Tue, 01 May 2012) | 3 lines
  
    [CXF-4279] Try to make sure the ehcache cache manager gets shutdown when
    we're done with it.
  
  ........
........

Added:
    cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
      - copied unchanged from r1336257, cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
    cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java

Propchange: cxf/branches/2.4.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java?rev=1336269&r1=1336268&r2=1336269&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
Wed May  9 16:13:39 2012
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.ws.security.cache;
 
+import java.io.Closeable;
+import java.io.IOException;
 import java.net.URL;
 
 import net.sf.ehcache.Cache;
@@ -31,7 +33,7 @@ import org.apache.ws.security.cache.Repl
  * An in-memory EHCache implementation of the ReplayCache interface. The default TTL is 60
minutes and the
  * max TTL is 12 hours.
  */
-public class EHCacheReplayCache implements ReplayCache {
+public class EHCacheReplayCache implements ReplayCache, Closeable {
     
     public static final long DEFAULT_TTL = 3600L;
     public static final long MAX_TTL = DEFAULT_TTL * 12L;
@@ -40,13 +42,7 @@ public class EHCacheReplayCache implemen
     private long ttl = DEFAULT_TTL;
     
     public EHCacheReplayCache(String key, URL configFileURL) {
-        if (cacheManager == null) {
-            if (configFileURL == null) {
-                cacheManager = CacheManager.create();
-            } else {
-                cacheManager = CacheManager.create(configFileURL);
-            }
-        }
+        cacheManager = EHCacheManagerHolder.getCacheManager(configFileURL);
         if (!cacheManager.cacheExists(key)) {
             cache = new Cache(key, 50000, true, false, DEFAULT_TTL, DEFAULT_TTL);
             cacheManager.addCache(cache);
@@ -117,5 +113,13 @@ public class EHCacheReplayCache implemen
         }
         return false;
     }
+
+    public void close() throws IOException {
+        if (cacheManager != null) {
+            EHCacheManagerHolder.releaseCacheManger(cacheManager);
+            cacheManager = null;
+            cache = null;
+        }
+    }
     
 }

Modified: cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java?rev=1336269&r1=1336268&r2=1336269&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
Wed May  9 16:13:39 2012
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.ws.security.policy;
 
+import java.io.Closeable;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 
@@ -26,12 +28,20 @@ import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientLifeCycleListener;
+import org.apache.cxf.endpoint.ClientLifeCycleManager;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerLifeCycleListener;
+import org.apache.cxf.endpoint.ServerLifeCycleManager;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.ws.policy.AssertionBuilderLoader;
 import org.apache.cxf.ws.policy.AssertionBuilderRegistry;
 import org.apache.cxf.ws.policy.PolicyBuilder;
 import org.apache.cxf.ws.policy.PolicyInterceptorProviderLoader;
 import org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry;
 import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder;
+import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.cxf.ws.security.policy.builders.AlgorithmSuiteBuilder;
 import org.apache.cxf.ws.security.policy.builders.AsymmetricBindingBuilder;
 import org.apache.cxf.ws.security.policy.builders.ContentEncryptedElementsBuilder;
@@ -76,6 +86,7 @@ import org.apache.cxf.ws.security.policy
 import org.apache.cxf.ws.security.policy.interceptors.UsernameTokenInterceptorProvider;
 import org.apache.cxf.ws.security.policy.interceptors.WSSecurityInterceptorProvider;
 import org.apache.cxf.ws.security.policy.interceptors.WSSecurityPolicyInterceptorProvider;
+import org.apache.ws.security.cache.ReplayCache;
 
 @NoJSR250Annotations
 public final class WSSecurityPolicyLoader implements PolicyInterceptorProviderLoader, AssertionBuilderLoader
{
@@ -92,6 +103,45 @@ public final class WSSecurityPolicyLoade
             //and error out at that point.  If nothing uses ws-securitypolicy
             //no warnings/errors will display
         }
+        ServerLifeCycleManager m = b.getExtension(ServerLifeCycleManager.class);
+        if (m != null) {
+            m.registerListener(new ServerLifeCycleListener() {
+                public void startServer(Server server) {
+                }
+                public void stopServer(Server server) {
+                    shutdownResources(server.getEndpoint().getEndpointInfo());
+                }
+            });
+        }
+        ClientLifeCycleManager cm = b.getExtension(ClientLifeCycleManager.class);
+        if (cm != null) {
+            cm.registerListener(new ClientLifeCycleListener() {
+                public void clientCreated(Client client) {
+                }
+                @Override
+                public void clientDestroyed(Client client) {
+                    shutdownResources(client.getEndpoint().getEndpointInfo());
+                }
+            });
+        }
+    }
+    protected void shutdownResources(EndpointInfo info) {
+        ReplayCache rc = (ReplayCache)info.getProperty(SecurityConstants.NONCE_CACHE_INSTANCE);
+        if (rc instanceof Closeable) {
+            close((Closeable)rc);
+        }
+        rc = (ReplayCache)info.getProperty(SecurityConstants.TIMESTAMP_CACHE_INSTANCE);
+        if (rc instanceof Closeable) {
+            close((Closeable)rc);
+        }
+    }
+    
+    private void close(Closeable ts) {
+        try {
+            ts.close();
+        } catch (IOException ex) {
+            //ignore, we're shutting down and nothing we can do
+        }
     }
     public void registerBuilders() {
         AssertionBuilderRegistry reg = bus.getExtension(AssertionBuilderRegistry.class);



Mime
View raw message