cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: rev 37335 - cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/store
Date Wed, 01 Sep 2004 12:16:52 GMT
Author: pier
Date: Wed Sep  1 05:16:51 2004
New Revision: 37335

Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/store/EHStore.java
Log:
Make sure that cache is created into the Cocoon cache directory

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/store/EHStore.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/store/EHStore.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/store/EHStore.java
Wed Sep  1 05:16:51 2004
@@ -26,8 +26,13 @@
 import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Element;
 
+import org.apache.cocoon.Constants;
+
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameterizable;
@@ -54,7 +59,7 @@
  * </p>
  */
 public class EHStore extends AbstractLogEnabled 
-implements Store, Parameterizable, Initializable, Disposable, ThreadSafe, Serviceable {
+implements Store, Parameterizable, Initializable, Disposable, ThreadSafe, Serviceable, Contextualizable
{
     
     private Cache cache;
     private CacheManager cacheManager;
@@ -70,8 +75,18 @@
     
     /** The store janitor */
     private StoreJanitor storeJanitor;
+
+    /** The context containing the work and the cache directory */
+    private Context context;
     
     /* (non-Javadoc)
+     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     */
+    public void contextualize(Context aContext) throws ContextException {
+        this.context = aContext;
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager aManager) throws ServiceException {
@@ -109,7 +124,11 @@
      */
     public void initialize() throws Exception {
         URL configFileURL = Thread.currentThread().getContextClassLoader().getResource(this.configFile);
+        String tempDir = System.getProperty("java.io.tmpdir");
+        Object cacheDir = this.context.get(Constants.CONTEXT_CACHE_DIR);
+        if (cacheDir != null) System.setProperty("java.io.tmpdir", cacheDir.toString());
         this.cacheManager = CacheManager.create(configFileURL);
+        if (tempDir != null) System.setProperty("java.io.tmpdir", tempDir);
         this.cache = new Cache(this.cacheName, this.maximumSize, this.overflowToDisk, true,
0, 0);
         this.cacheManager.addCache(this.cache);
         this.storeJanitor.register(this);

Mime
View raw message