Return-Path: Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 65182 invoked by uid 500); 26 Jul 2003 13:26:48 -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 65171 invoked by uid 500); 26 Jul 2003 13:26:48 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 65166 invoked from network); 26 Jul 2003 13:26:48 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 26 Jul 2003 13:26:48 -0000 Received: (qmail 78655 invoked by uid 1260); 26 Jul 2003 13:26:47 -0000 Date: 26 Jul 2003 13:26:47 -0000 Message-ID: <20030726132647.78654.qmail@icarus.apache.org> From: cziegeler@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/lib jars.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N cziegeler 2003/07/26 06:26:47 Modified: . gump.xml src/java/org/apache/cocoon/components/store/impl DefaultStore.java src/deprecated/java/org/apache/cocoon/components/store JispFilesystemStore.java JispStringKey.java lib jars.xml Added: lib/core jisp-2.5.1.jar excalibur-store-20030726.jar Removed: lib/core excalibur-store-20030317.jar jisp-2.0.1.jar Log: Updating to latest jisp and excalibur store Revision Changes Path 1.71 +2 -2 cocoon-2.1/gump.xml Index: gump.xml =================================================================== RCS file: /home/cvs/cocoon-2.1/gump.xml,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- gump.xml 14 Jul 2003 02:52:25 -0000 1.70 +++ gump.xml 26 Jul 2003 13:26:47 -0000 1.71 @@ -984,7 +984,7 @@ Java Indexed Serialization Package - + 1.3 +2 -2 cocoon-2.1/src/java/org/apache/cocoon/components/store/impl/DefaultStore.java Index: DefaultStore.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/store/impl/DefaultStore.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultStore.java 14 Jul 2003 19:09:00 -0000 1.2 +++ DefaultStore.java 26 Jul 2003 13:26:47 -0000 1.3 @@ -78,7 +78,7 @@ * @author Vadim Gritsenko * @version CVS $Id$ */ -public final class DefaultStore extends AbstractJispFilesystemStore +public class DefaultStore extends AbstractJispFilesystemStore implements org.apache.excalibur.store.Store, Contextualizable, ThreadSafe, 1.3 +7 -423 cocoon-2.1/src/deprecated/java/org/apache/cocoon/components/store/JispFilesystemStore.java Index: JispFilesystemStore.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/deprecated/java/org/apache/cocoon/components/store/JispFilesystemStore.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JispFilesystemStore.java 27 Apr 2003 15:16:15 -0000 1.2 +++ JispFilesystemStore.java 26 Jul 2003 13:26:47 -0000 1.3 @@ -50,435 +50,19 @@ */ package org.apache.cocoon.components.store; -import com.coyotegulch.jisp.BTreeIndex; -import com.coyotegulch.jisp.BTreeObjectIterator; -import com.coyotegulch.jisp.IndexedObjectDatabase; -import com.coyotegulch.jisp.KeyNotFound; -import com.coyotegulch.jisp.KeyObject; - -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; -import org.apache.avalon.framework.parameters.Parameters; -import org.apache.avalon.framework.thread.ThreadSafe; -import org.apache.cocoon.Constants; -import org.apache.cocoon.util.IOUtils; - -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.util.Enumeration; +import org.apache.cocoon.components.store.impl.DefaultStore; /** * This store is based on the Jisp library * (http://www.coyotegulch.com/jisp/index.html). This store uses B-Tree indexes * to access variable-length serialized data stored in files. - * + * + * @deprecated Use the {@link org.apache.cocoon.components.store.impl.DefaultStore} instead. + * * @author Gerhard Froehlich * @author Vadim Gritsenko * @version CVS $Id$ */ -public final class JispFilesystemStore extends AbstractLogEnabled - implements org.apache.excalibur.store.Store, - Contextualizable, - ThreadSafe, - Initializable, - Parameterizable { - - protected File m_workDir; - protected File m_cacheDir; - - /** - * The directory repository - */ - protected File m_directoryFile; - protected volatile String m_directoryPath; - - /** - * The database - */ - private File m_databaseFile; - private File m_indexFile; - - private int m_Order; - private IndexedObjectDatabase m_Database; - private BTreeIndex m_Index; - - /** - * Sets the repository's location - * - * @param directory the new directory value - * @exception IOException - */ - public void setDirectory(final String directory) - throws IOException { - this.setDirectory(new File(directory)); - } - - /** - * Sets the repository's location - * - * @param directory the new directory value - * @exception IOException - */ - - public void setDirectory(final File directory) - throws IOException { - this.m_directoryFile = directory; - - /* Save directory path prefix */ - this.m_directoryPath = IOUtils.getFullFilename(this.m_directoryFile); - this.m_directoryPath += File.separator; - - if (!this.m_directoryFile.exists()) { - /* Create it new */ - if (!this.m_directoryFile.mkdir()) { - throw new IOException("Error creating store directory '" + - this.m_directoryPath + "'"); - } - } - - /* Is given file actually a directory? */ - if (!this.m_directoryFile.isDirectory()) { - throw new IOException("'" + this.m_directoryPath + "' is not a directory"); - } - - /* Is directory readable and writable? */ - if (!(this.m_directoryFile.canRead() && this.m_directoryFile.canWrite())) { - throw new IOException("Directory '" + this.m_directoryPath + - "' is not readable/writable"); - } - } - - /** - * Contextualize the Component - * - * @param context the Context of the Application - * @exception ContextException - */ - public void contextualize(final Context context) throws ContextException { - this.m_workDir = (File)context.get(Constants.CONTEXT_WORK_DIR); - this.m_cacheDir = (File)context.get(Constants.CONTEXT_CACHE_DIR); - } - - /** - * Configure the Component.
- * A few options can be used - *
    - *
  • datafile = the name of the data file (Default: cocoon.dat) - *
  • - *
  • m_indexFile = the name of the index file (Default: cocoon.idx) - *
  • - *
  • order = The page size of the B-Tree
  • - *
- * - * @param params the configuration paramters - * @exception ParameterException - */ - public void parameterize(Parameters params) throws ParameterException { - - try { - if (params.getParameterAsBoolean("use-cache-directory", false)) { - if (getLogger().isDebugEnabled()) { - getLogger().debug("Using cache directory: " + m_cacheDir); - } - setDirectory(m_cacheDir); - } else if (params.getParameterAsBoolean("use-work-directory", false)) { - if (getLogger().isDebugEnabled()) { - getLogger().debug("Using work directory: " + m_workDir); - } - setDirectory(m_workDir); - } else if (params.getParameter("directory", null) != null) { - String dir = params.getParameter("directory"); - dir = IOUtils.getContextFilePath(m_workDir.getPath(), dir); - if (getLogger().isDebugEnabled()) { - getLogger().debug("Using directory: " + dir); - } - setDirectory(new File(dir)); - } else { - try { - // Default - setDirectory(m_workDir); - } catch (IOException e) { - // Ignored - } - } - } catch (IOException e) { - throw new ParameterException("Unable to set directory", e); - } - - String databaseName = params.getParameter("datafile", "cocoon.dat"); - String indexName = params.getParameter("m_indexFile", "cocoon.idx"); - m_Order = params.getParameterAsInteger("order", 301); - if (getLogger().isDebugEnabled()) { - getLogger().debug("Database file name = " + databaseName); - getLogger().debug("Index file name = " + indexName); - getLogger().debug("Order=" + m_Order); - } - - m_databaseFile = new File(m_directoryFile, databaseName); - m_indexFile = new File(m_directoryFile, indexName); - } - - /** - * Initialize the Component - */ - public void initialize() { - if (getLogger().isDebugEnabled()) { - getLogger().debug("initialize() JispFilesystemStore"); - } - - try { - if (m_databaseFile.exists()) { - if (getLogger().isDebugEnabled()) { - getLogger().debug("initialize(): Datafile exists"); - } - m_Database = new IndexedObjectDatabase(m_databaseFile.toString(), false); - m_Index = new BTreeIndex(m_indexFile.toString()); - m_Database.attachIndex(m_Index); - } else { - if (getLogger().isDebugEnabled()) { - getLogger().debug("initialize(): Datafile does not exist"); - } - m_Database = new IndexedObjectDatabase(m_databaseFile.toString(), false); - m_Index = new BTreeIndex(m_indexFile.toString(), - m_Order, new JispStringKey(), false); - m_Database.attachIndex(m_Index); - } - } catch (KeyNotFound ignore) { - } catch (Exception e) { - getLogger().error("initialize(..) Exception", e); - } - } - - /** - * Returns the repository's full pathname - * - * @return the directory as String - */ - public String getDirectoryPath() { - return this.m_directoryPath; - } - - /** - * Returns a Object from the store associated with the Key Object - * - * @param key the Key object - * @return the Object associated with Key Object - */ - public synchronized Object get(Object key) { - Object value = null; - try { - value = m_Database.read(wrapKeyObject(key), m_Index); - if (getLogger().isDebugEnabled()) { - if (value != null) { - if (getLogger().isDebugEnabled()) { - getLogger().debug("Found key: " + key); - } - } else { - if (getLogger().isDebugEnabled()) { - getLogger().debug("NOT Found key: " + key); - } - } - } - } catch (Exception e) { - getLogger().error("get(..): Exception", e); - } - return value; - } - - /** - * Store the given object in the indexed data file. - * - * @param key the key object - * @param value the value object - * @exception IOException - */ - public synchronized void store(Object key, Object value) - throws IOException { - - if (getLogger().isDebugEnabled()) { - getLogger().debug("store(): Store file with key: " - + key.toString()); - getLogger().debug("store(): Store file with value: " - + value.toString()); - } - - if (value instanceof Serializable) { - try { - KeyObject[] keyArray = new KeyObject[1]; - keyArray[0] = wrapKeyObject(key); - m_Database.write(keyArray, (Serializable) value); - } catch (Exception e) { - getLogger().error("store(..): Exception", e); - } - } else { - throw new IOException("Object not Serializable"); - } - } - - /** - * Holds the given object in the indexed data file. - * - * @param key the key object - * @param value the value object - * @exception IOException - */ - public synchronized void hold(Object key, Object value) - throws IOException { - this.store(key, value); - } - - /** - * Frees some values of the data file.
- */ - public synchronized void free() { - // implementation is missing - } - - /** - * Clear the Store of all elements - */ - public synchronized void clear() { - BTreeObjectEnumeration enum = new BTreeObjectEnumeration(m_Database.createIterator(m_Index),this); - - if (getLogger().isDebugEnabled()) { - getLogger().debug("clear(): Clearing the database "); - } - - while(enum.hasMoreElements()) { - Object tmp = enum.nextElement(); - if (getLogger().isDebugEnabled()) { - getLogger().debug("clear(): Removing key: " + tmp.toString()); - } - this.remove(tmp); - } - } - - /** - * Removes a value from the data file with the given key. - * - * @param key the key object - */ - public synchronized void remove(Object key) { - if (getLogger().isDebugEnabled()) { - getLogger().debug("remove(..) Remove item"); - } - - try { - KeyObject[] keyArray = new KeyObject[1]; - keyArray[0] = wrapKeyObject(key); - m_Database.remove(keyArray); - } catch (KeyNotFound ignore) { - } catch (Exception e) { - getLogger().error("remove(..): Exception", e); - } - } - - /** - * Test if the the index file contains the given key - * - * @param key the key object - * @return true if Key exists and false if not - */ - public synchronized boolean containsKey(Object key) { - long res = -1; - - try { - res = m_Index.findKey(wrapKeyObject(key)); - if (getLogger().isDebugEnabled()) { - getLogger().debug("containsKey(..): res=" + res); - } - } catch (KeyNotFound ignore) { - } catch (Exception e) { - getLogger().error("containsKey(..): Exception", e); - } - - if (res > 0) { - return true; - } else { - return false; - } - } - - /** - * Returns a Enumeration of all Keys in the indexed file.
- * - * @return Enumeration Object with all existing keys - */ - public Enumeration keys() { - BTreeObjectEnumeration enum = new BTreeObjectEnumeration(m_Database.createIterator(m_Index),this); - return enum; - } - - public int size() { - int cnt = 0; - - BTreeObjectEnumeration enum = new BTreeObjectEnumeration(m_Database.createIterator(m_Index),this); - - while(enum.hasMoreElements()) { - cnt++; - } - return cnt; - } - - /** - * This method wraps around the key Object a Jisp KeyObject. - * - * @param key the key object - * @return the wrapped key object - */ - private KeyObject wrapKeyObject(Object key) { - return new JispStringKey(String.valueOf(key)); - } - - class BTreeObjectEnumeration implements Enumeration { - private BTreeObjectIterator m_Iterator; - private JispFilesystemStore m_Store; - - public BTreeObjectEnumeration(BTreeObjectIterator iterator, JispFilesystemStore store) { - m_Iterator = iterator; - m_Store = store; - } - - public boolean hasMoreElements() { - boolean hasMore = false; - Object tmp = null; - - try { - tmp = m_Iterator.getKey(); - - if(m_Iterator.moveNext()) { - hasMore = true; - } - - /* resets iterator to the old state **/ - m_Iterator.moveTo((KeyObject)tmp); - } catch (IOException ioe) { - m_Store.getLogger().error("store(..): Exception", ioe); - } catch (ClassNotFoundException cnfe) { - m_Store.getLogger().error("store(..): Exception", cnfe); - } - return hasMore; - } - - public Object nextElement() { - Object tmp = null; - - try { - tmp = m_Iterator.getKey(); - m_Iterator.moveNext(); - } catch (IOException ioe) { - m_Store.getLogger().error("store(..): Exception", ioe); - } catch (ClassNotFoundException cnfe) { - m_Store.getLogger().error("store(..): Exception", cnfe); - } - // make a string out of it (JispStringKey is not usefull here) - return tmp.toString(); - } - } +public final class JispFilesystemStore +extends DefaultStore { } 1.2 +2 -1 cocoon-2.1/src/deprecated/java/org/apache/cocoon/components/store/JispStringKey.java Index: JispStringKey.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/deprecated/java/org/apache/cocoon/components/store/JispStringKey.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JispStringKey.java 9 Mar 2003 00:07:06 -0000 1.1 +++ JispStringKey.java 26 Jul 2003 13:26:47 -0000 1.2 @@ -60,6 +60,7 @@ * Wrapper class for String Keys to be compatible with the * Jisp KeyObject. * + * @deprecated Use the Avalon Excalibur Store instead. * @author Gerhard Froehlich * @version CVS $Id$ */ 1.1 cocoon-2.1/lib/core/jisp-2.5.1.jar <> 1.1 cocoon-2.1/lib/core/excalibur-store-20030726.jar <> 1.70 +3 -3 cocoon-2.1/lib/jars.xml Index: jars.xml =================================================================== RCS file: /home/cvs/cocoon-2.1/lib/jars.xml,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- jars.xml 25 Jul 2003 16:20:30 -0000 1.69 +++ jars.xml 26 Jul 2003 13:26:47 -0000 1.70 @@ -206,7 +206,7 @@ support high level server development. Cocoon - core/excalibur-store-20030317.jar + core/excalibur-store-20030726.jar http://avalon.apache.org/excalibur/ @@ -479,7 +479,7 @@ JISP JISP file storage - core/jisp-2.0.1.jar + core/jisp-2.5.1.jar http://www.coyotegulch.com/algorithm/jisp/index.html