Author: coheigea
Date: Wed Jun 6 15:45:05 2012
New Revision: 1346955
URL: http://svn.apache.org/viewvc?rev=1346955&view=rev
Log:
Keep ReplayCache instances per-context name instead of per-bus
Modified:
cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java
cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java
cxf/fediz/trunk/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java
cxf/fediz/trunk/pom.xml
Modified:
cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java?rev=1346955&r1=1346954&r2=1346955&view=diff
==============================================================================
---
cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java
(original)
+++
cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java
Wed Jun 6 15:45:05 2012
@@ -37,29 +37,28 @@ public class EHCacheTokenReplayCache imp
public static final long DEFAULT_TTL = 3600L;
public static final long MAX_TTL = DEFAULT_TTL * 12L;
- private static final String CACHE_KEY = "fediz-replay-cache";
private Ehcache cache;
private CacheManager cacheManager;
private long ttl = DEFAULT_TTL;
- public EHCacheTokenReplayCache() {
+ public EHCacheTokenReplayCache(String key) {
String defaultConfigFile = "fediz-ehcache.xml";
URL configFileURL = Loader.getResource(defaultConfigFile);
- createCache(configFileURL);
+ createCache(key, configFileURL);
}
- public EHCacheTokenReplayCache(URL configFileURL) {
- createCache(configFileURL);
+ public EHCacheTokenReplayCache(String key, URL configFileURL) {
+ createCache(key, configFileURL);
}
- private void createCache(URL configFileURL) {
+ private void createCache(String key, URL configFileURL) {
if (configFileURL == null) {
cacheManager = CacheManager.create();
} else {
cacheManager = CacheManager.create(configFileURL);
}
- Ehcache newCache = new Cache(CACHE_KEY, 50000, true, false,
DEFAULT_TTL, DEFAULT_TTL);
+ Ehcache newCache = new Cache(key, 50000, true, false, DEFAULT_TTL,
DEFAULT_TTL);
cache = cacheManager.addCacheIfAbsent(newCache);
}
Modified:
cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java?rev=1346955&r1=1346954&r2=1346955&view=diff
==============================================================================
---
cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java
(original)
+++
cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java
Wed Jun 6 15:45:05 2012
@@ -136,18 +136,19 @@ public class FederationContext implement
return replayCache;
}
String replayCacheString = config.getTokenReplayCache();
+ String cacheKey = "fediz-replay-cache-" + config.getName();
if (replayCacheString == null || "".equals(replayCacheString)) {
- replayCache = new EHCacheTokenReplayCache();
+ replayCache = new EHCacheTokenReplayCache(cacheKey);
} else {
try {
Class<?> replayCacheClass =
Loader.loadClass(replayCacheString);
replayCache = (TokenReplayCache<String>)
replayCacheClass.newInstance();
} catch (ClassNotFoundException e) {
- replayCache = new EHCacheTokenReplayCache();
+ replayCache = new EHCacheTokenReplayCache(cacheKey);
} catch (InstantiationException e) {
- replayCache = new EHCacheTokenReplayCache();
+ replayCache = new EHCacheTokenReplayCache(cacheKey);
} catch (IllegalAccessException e) {
- replayCache = new EHCacheTokenReplayCache();
+ replayCache = new EHCacheTokenReplayCache(cacheKey);
}
}
return replayCache;
Modified:
cxf/fediz/trunk/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java?rev=1346955&r1=1346954&r2=1346955&view=diff
==============================================================================
---
cxf/fediz/trunk/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java
(original)
+++
cxf/fediz/trunk/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java
Wed Jun 6 15:45:05 2012
@@ -32,10 +32,13 @@ public final class SecurityTestUtil {
public static void cleanup() {
String tmpDir = System.getProperty("java.io.tmpdir");
if (tmpDir != null) {
- File replayCacheFile =
- new File(tmpDir + File.separator + "fediz-replay-cache.data");
- if (replayCacheFile.exists()) {
- replayCacheFile.delete();
+ File[] tmpFiles = new File(tmpDir).listFiles();
+ if (tmpFiles != null) {
+ for (File tmpFile : tmpFiles) {
+ if (tmpFile.exists() &&
tmpFile.getName().startsWith("fediz-replay-cache")) {
+ tmpFile.delete();
+ }
+ }
}
}
}
Modified: cxf/fediz/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/pom.xml?rev=1346955&r1=1346954&r2=1346955&view=diff
==============================================================================
--- cxf/fediz/trunk/pom.xml (original)
+++ cxf/fediz/trunk/pom.xml Wed Jun 6 15:45:05 2012
@@ -526,6 +526,7 @@
<enableAssertions>${fediz.surefire.enable.assertions}</enableAssertions>
<parallel>${fediz.surefire.parallel.mode}</parallel>
<systemPropertyVariables>
+ <java.io.tmpdir>${basedir}/target</java.io.tmpdir>
<cxf.useRandomFirstPort>true</cxf.useRandomFirstPort>
<org.apache.ws.commons.schema.protectReadOnlyCollections>${fediz.protect-xmlschema-collections}</org.apache.ws.commons.schema.protectReadOnlyCollections>
<cxf.validateServiceSchemas>${fediz.validateServices}</cxf.validateServiceSchemas>