Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 62652 invoked from network); 17 Mar 2004 15:00:55 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 17 Mar 2004 15:00:55 -0000 Received: (qmail 14174 invoked by uid 500); 17 Mar 2004 15:00:39 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 14105 invoked by uid 500); 17 Mar 2004 15:00:39 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 14063 invoked by uid 500); 17 Mar 2004 15:00:38 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 14025 invoked from network); 17 Mar 2004 15:00:38 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 17 Mar 2004 15:00:38 -0000 Received: (qmail 62444 invoked by uid 1758); 17 Mar 2004 15:00:42 -0000 Date: 17 Mar 2004 15:00:42 -0000 Message-ID: <20040317150042.62443.qmail@minotaur.apache.org> From: unico@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/src/blocks/scratchpad/conf ehstore.xconf X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N unico 2004/03/17 07:00:41 Modified: src/blocks/scratchpad/java/org/apache/cocoon/components/store EHStore.java src/blocks/scratchpad/conf ehstore.xconf Added: src/blocks/scratchpad/java/org/apache/cocoon/components/store ehcache-defaults.xml Log: default configuration and documentation Revision Changes Path 1.3 +47 -7 cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/store/EHStore.java Index: EHStore.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/store/EHStore.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- EHStore.java 8 Mar 2004 22:44:51 -0000 1.2 +++ EHStore.java 17 Mar 2004 15:00:41 -0000 1.3 @@ -17,6 +17,7 @@ import java.io.IOException; import java.io.Serializable; +import java.net.URL; import java.util.Collections; import java.util.Enumeration; @@ -38,8 +39,15 @@ * Store implementation based on EHCache. * (http://ehcache.sourceforge.net/) * - * TODO: CacheManager expects to be a singleton. So configuring - * multiple EHStore intances could lead to errors. + *

+ * IMPORTANT:
+ * (from http://ehcache.sourceforge.net/documentation/) + * Persistence: + * The Disk Cache used by EHCache is not meant to be persistence mechanism. + * The data file for each cache is deleted, if it exists, on startup. + * No data from a previous instance of an application is persisted through the disk cache. + * The data file for each cache is also deleted on shutdown. + *

*/ public class EHStore extends AbstractLogEnabled implements Store, Parameterizable, Initializable, Disposable, ThreadSafe { @@ -47,30 +55,62 @@ private Cache m_cache; private CacheManager m_cacheManager; + // configuration options private String m_cacheName; private int m_maximumSize; private boolean m_overflowToDisk; + private String m_configFile; + + // ---------------------------------------------------- lifecycle public EHStore() { } + /** + * Configure the store. The following options can be used: + *
    + *
  • cache-name (main) - When configuring multiple + * EHStore intances you must specify a different name for each.
  • + *
  • maxobjects (10000) - The maximum number of in-memory objects.
  • + *
  • overflow-to-disk (true) - Whether to spool elements to disk after + * maxobjects has been exceeded. + *
  • config-file (org/apache/cocoon/components/store/ehcache-defaults.xml) - + * The default configuration file to use. This file is the only way to specify the path where + * the disk store puts its .cache files. The current default value is java.io.tmp. + * (On a standard Linux system this will be /tmp). Note that since the EHCache manager is + * a singleton object the value of this parameter will only have effect when this store is the + * first to create it. Configuring different stores with different values for this parameter + * will have no effect. + *
+ */ public void parameterize(Parameters parameters) throws ParameterException { - m_cacheName = parameters.getParameter("cache-name","main"); - m_maximumSize = parameters.getParameterAsInteger("maxobjects",100); - m_overflowToDisk = parameters.getParameterAsBoolean("overflow-to-disk",true); + m_cacheName = parameters.getParameter("cache-name", "main"); + m_maximumSize = parameters.getParameterAsInteger("maxobjects", 10000); + m_overflowToDisk = parameters.getParameterAsBoolean("overflow-to-disk", true); + m_configFile = parameters.getParameter("config-file", + "org/apache/cocoon/components/store/ehcache-defaults.xml"); } + /** + * Initialize the CacheManager and created the Cache. + */ public void initialize() throws Exception { - m_cacheManager = CacheManager.create(); - m_cache = new Cache(m_cacheName,m_maximumSize,m_overflowToDisk,true,0,0); + URL configFile = Thread.currentThread().getContextClassLoader().getResource(m_configFile); + m_cacheManager = CacheManager.create(configFile); + m_cache = new Cache(m_cacheName, m_maximumSize, m_overflowToDisk, true, 0, 0); m_cacheManager.addCache(m_cache); } + /** + * Shutdown the CacheManager. + */ public void dispose() { m_cacheManager.shutdown(); m_cacheManager = null; m_cache = null; } + + // ---------------------------------------------------- Store implementation /* (non-Javadoc) * @see org.apache.excalibur.store.Store#free() 1.1 cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/store/ehcache-defaults.xml Index: ehcache-defaults.xml =================================================================== 1.2 +5 -4 cocoon-2.1/src/blocks/scratchpad/conf/ehstore.xconf Index: ehstore.xconf =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/conf/ehstore.xconf,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ehstore.xconf 8 Mar 2004 22:43:32 -0000 1.1 +++ ehstore.xconf 17 Mar 2004 15:00:41 -0000 1.2 @@ -20,13 +20,14 @@