You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by ss...@apache.org on 2013/03/12 00:00:25 UTC

svn commit: r1455358 - in /shindig/trunk/java/common/src/main: java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java resources/org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml

Author: ssievers
Date: Mon Mar 11 23:00:24 2013
New Revision: 1455358

URL: http://svn.apache.org/r1455358
Log:
SHINDIG-1912 | Allow EhCache DiskStore location to be easily configurable

Modified:
    shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java
    shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml

Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java?rev=1455358&r1=1455357&r2=1455358&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java Mon Mar 11 23:00:24 2013
@@ -19,6 +19,8 @@
 package org.apache.shindig.common.cache.ehcache;
 
 import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+
 import org.apache.shindig.common.cache.Cache;
 import org.apache.shindig.common.cache.CacheProvider;
 import org.apache.shindig.common.servlet.GuiceServletContextListener;
@@ -79,7 +81,14 @@ public class EhCacheCacheProvider implem
     // Remove res:// and file:// prefixes.  EhCache can't understand them.
     String normalizedFilterPath = filterPath.replaceFirst(ResourceLoader.RESOURCE_PREFIX, "");
     normalizedFilterPath = normalizedFilterPath.replaceFirst(ResourceLoader.FILE_PREFIX, "");
-    System.getProperties().put("net.sf.ehcache.sizeof.filter", normalizedFilterPath);
+    System.setProperty("net.sf.ehcache.sizeof.filter", normalizedFilterPath);
+
+    // If ehcache.disk.store.dir isn't already set, set it to java.io.tmpdir.
+    // See http://ehcache.org/documentation/user-guide/storage-options#diskstore-configuration-element
+    String diskStoreProperty = System.getProperty("ehcache.disk.store.dir");
+    if (Strings.isNullOrEmpty(diskStoreProperty)) {
+      System.setProperty("ehcache.disk.store.dir", System.getProperty("java.io.tmpdir"));
+    }
 
     cacheManager = CacheManager.create(getConfiguration(configPath));
     create(jmxEnabled, withCacheStats);

Modified: shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml?rev=1455358&r1=1455357&r2=1455358&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml (original)
+++ shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml Mon Mar 11 23:00:24 2013
@@ -42,7 +42,7 @@ under the License.
     The directory where any caches configured as diskPersistent or overflowToDisk
     will end up.
   -->
-  <diskStore path="java.io.tmpdir"/>
+  <diskStore path="ehcache.disk.store.dir"/>
 
   <!-- Default sizeOfPolicy for computing the size of cache elements in memory -->
   <sizeOfPolicy maxDepth="1000" maxDepthExceededBehavior="abort"/>