vgritsenko 02/02/05 06:47:36 Modified: . build.xml src/webapp cocoon.xconf Added: legal LICENSE.jisp lib/optional jisp_1_0_2.jar src/java/org/apache/cocoon/components/store JispFilesystemStore.java JispStringKey.java Removed: src/scratchpad/lib jisp_1_0_2.jar src/scratchpad/src/org/apache/cocoon/components/store JispFilesystemStore.java JispStringKey.java Log: Move Jisp store to the main trunk Revision Changes Path 1.158 +18 -1 xml-cocoon2/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/build.xml,v retrieving revision 1.157 retrieving revision 1.158 diff -u -r1.157 -r1.158 --- build.xml 3 Feb 2002 22:41:08 -0000 1.157 +++ build.xml 5 Feb 2002 14:47:35 -0000 1.158 @@ -396,6 +396,10 @@ <class-available classpathref="classpath" property="hsqldb.present" classname="org.hsqldb.Server"/> + + <class-available classpathref="classpath" + property="jisp.present" + classname="com.coyotegulch.jisp.IndexedObjectDatabase"/> </target> <target name="prepare-jdbc" depends="filter-jdbc,nofilter-jdbc"/> @@ -581,12 +585,22 @@ value="The resolver allows entity resolving."/> </antcall> </target> + <target name="jisp-warn" unless="jisp.present" depends="optional-tests" + description="Outputs a warning if com.coyotegulch.jisp.* classes are missing during compilation"> + <antcall target="op-warning"> + <param name="thing" value="jisp"/> + <param name="recovery" + value="Get jisp and place the jar in the lib/optional dir"/> + <param name="message" + value="jisp is required for the JispFilesystemStore."/> + </antcall> + </target> <!-- =================================================================== --> <!-- Print out warnings for optional components --> <!-- =================================================================== --> <target name="optional-warnings" - depends="bsf-warn, jfor-warn, xmldb-warn, xt-warn, php-warn, naming-warn, svg-warn, fop-warn, tidy-warn, maybeupload-warn, lucene-warn, deli-warn, velocity-warn, hsqldb-warn, resolver-warn" + depends="bsf-warn, jfor-warn, xmldb-warn, xt-warn, php-warn, naming-warn, svg-warn, fop-warn, tidy-warn, maybeupload-warn, lucene-warn, deli-warn, velocity-warn, hsqldb-warn, resolver-warn, jisp-warn" description="Outputs warnings if some optional jars are missing from the environment"> </target> @@ -677,6 +691,9 @@ <exclude name="**/components/search/*" unless="lucene.present"/> <exclude name="**/generation/SearchGenerator.java" unless="lucene.present"/> <exclude name="**/lucene.xconf" unless="lucene.present"/> + + <exclude name="**/components/store/Jisp*.java" unless="jisp.present"/> + <exclude name="**/jisp.xconf" unless="jisp.present"/> <exclude name="**/http/RequestWrapper*.java"/> <exclude name="**/browser/*.x*"/> 1.1 xml-cocoon2/legal/LICENSE.jisp Index: LICENSE.jisp =================================================================== ------------------------------------------------------------------------------------------------ JISP - Java Index Serialization Package version 1.0.2 5 August 2001 ------------------------------------------------------------------------------------------------ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: If you modify this file, you may insert additional notices immediately following this sentence. Copyright 2001 Scott Robert Ladd. All rights reserved, except as noted herein. This computer program source file is supplied "AS IS". Scott Robert Ladd (hereinafter referred to as "Author") disclaims all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose. The Author assumes no liability for direct, indirect, incidental, special, exemplary, or consequential damages, which may result from the use of the PNG Reference Library, even if advised of the possibility of such damage. The Author hereby grants anyone permission to use, copy, modify, and distribute this source code, or portions hereof, for any purpose, without fee, subject to the following restrictions: 1. The origin of this source code must not be misrepresented. 2. Altered versions must be plainly marked as such and must not be misrepresented as being the original source. 3. This Copyright notice may not be removed or altered from any source or altered source distribution. The Author specifically permits (without fee) and encourages the use of this source code for entertainment, education, or decoration. If you use this source code in a product, acknowledgment is not required but would be appreciated. The Author's contact information is: Scott Robert Ladd [EMAIL PROTECTED] http://www.coyotegulch.com Acknowledgement: This document is based on the wonderful simple license that accompanies libpng. 1.1 xml-cocoon2/lib/optional/jisp_1_0_2.jar <<Binary file>> 1.1 xml-cocoon2/src/java/org/apache/cocoon/components/store/JispFilesystemStore.java Index: JispFilesystemStore.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache Cocoon" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.cocoon.components.store; 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.AbstractLoggable; 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 com.coyotegulch.jisp.BTreeIndex; import com.coyotegulch.jisp.IndexedObjectDatabase; import com.coyotegulch.jisp.KeyNotFound; import com.coyotegulch.jisp.KeyObject; import java.io.File; import java.io.IOException; import java.io.Serializable; import java.util.Enumeration; import java.util.Vector; /** * 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. * * @author <a href="mailto:[EMAIL PROTECTED]">Gerhard Froehlich</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> * @version CVS $Id: JispFilesystemStore.java,v 1.1 2002/02/05 14:47:35 vgritsenko Exp $ */ public final class JispFilesystemStore extends AbstractLoggable implements Store, Contextualizable, ThreadSafe, Initializable, Parameterizable { protected File workDir; protected File cacheDir; /** * The directory repository */ protected File directoryFile; protected volatile String directoryPath; /** * The database */ private File databaseFile; private File indexFile; private int mOrder; private IndexedObjectDatabase mDatabase; private BTreeIndex mIndex; /** * 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.directoryFile = directory; /* Save directory path prefix */ this.directoryPath = IOUtils.getFullFilename(this.directoryFile); this.directoryPath += File.separator; if (!this.directoryFile.exists()) { /* Create it new */ if (!this.directoryFile.mkdir()) { throw new IOException("Error creating store directory '" + this.directoryPath + "'"); } } /* Is given file actually a directory? */ if (!this.directoryFile.isDirectory()) { throw new IOException("'" + this.directoryPath + "' is not a directory"); } /* Is directory readable and writable? */ if (!(this.directoryFile.canRead() && this.directoryFile.canWrite())) { throw new IOException("Directory '" + this.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.workDir = (File)context.get(Constants.CONTEXT_WORK_DIR); this.cacheDir = (File)context.get(Constants.CONTEXT_CACHE_DIR); } /** * Configure the Component.<br> * A few options can be used * <UL> * <LI> datafile = the name of the data file (Default: cocoon.dat) * </LI> * <LI> indexfile = the name of the index file (Default: cocoon.idx) * </LI> * <LI> order = The page size of the B-Tree</LI> * </UL> * * @param params the configuration paramters * @exception ParameterException */ public void parameterize(Parameters params) throws ParameterException { try { if (params.getParameterAsBoolean("use-cache-directory", false)) { if (this.getLogger().isDebugEnabled()) getLogger().debug("Using cache directory: " + cacheDir); setDirectory(cacheDir); } else if (params.getParameterAsBoolean("use-work-directory", false)) { if (this.getLogger().isDebugEnabled()) getLogger().debug("Using work directory: " + workDir); setDirectory(workDir); } else if (params.getParameter("directory", null) != null) { String dir = params.getParameter("directory"); dir = IOUtils.getContextFilePath(workDir.getPath(), dir); if (this.getLogger().isDebugEnabled()) getLogger().debug("Using directory: " + dir); setDirectory(new File(dir)); } else { try { // Default setDirectory(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("indexfile", "cocoon.idx"); mOrder = params.getParameterAsInteger("order", 301); if (getLogger().isDebugEnabled()) { this.getLogger().debug("Database file name = " + databaseName); this.getLogger().debug("Index file name = " + indexName); this.getLogger().debug("Order=" + mOrder); } databaseFile = new File(directoryFile, databaseName); indexFile = new File(directoryFile, indexName); } /** * Initialize the Component */ public void initialize() { if (getLogger().isDebugEnabled()) { getLogger().debug("initialize() JispFilesystemStore"); } try { if (databaseFile.exists()) { if (getLogger().isDebugEnabled()) { this.getLogger().debug("initialize(): Datafile exists"); } mDatabase = new IndexedObjectDatabase(databaseFile.toString(), false); mIndex = new BTreeIndex(indexFile.toString()); mDatabase.attachIndex(mIndex); } else { if (getLogger().isDebugEnabled()) { this.getLogger().debug("initialize(): Datafile does not exist"); } mDatabase = new IndexedObjectDatabase(databaseFile.toString(), false); mIndex = new BTreeIndex(indexFile.toString(), mOrder, new JispStringKey(), false); mDatabase.attachIndex(mIndex); } } 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.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 Object get(Object key) { Object value = null; try { value = mDatabase.read(this.wrapKeyObject(key), mIndex); if (getLogger().isDebugEnabled()) { if (value != null) { getLogger().debug("Found key: " + key); } else { 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 void store(Object key, Object value) throws IOException { if (getLogger().isDebugEnabled()) { this.getLogger().debug("store(): Store file with key: " + key.toString()); this.getLogger().debug("store(): Store file with value: " + value.toString()); } if (value instanceof Serializable) { try { KeyObject[] keyArray = new KeyObject[1]; keyArray[0] = this.wrapKeyObject(key); mDatabase.write(keyArray, (Serializable) value); } catch (Exception e) { this.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 void hold(Object key, Object value) throws IOException { this.store(key, value); } /** * Frees some values of the data file.<br> * TODO: implementation */ public void free() { //TODO: implementation } /** * Removes a value from the data file with the given key. * * @param key the key object */ public void remove(Object key) { if (getLogger().isDebugEnabled()) { this.getLogger().debug("remove(..) Remove item"); } try { KeyObject[] keyArray = new KeyObject[1]; keyArray[0] = this.wrapKeyObject(key); mDatabase.remove(keyArray); } catch (KeyNotFound ignore) { } catch (Exception e) { this.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 boolean containsKey(Object key) { long res = -1; try { res = mIndex.findKey(this.wrapKeyObject(key)); if (getLogger().isDebugEnabled()) { this.getLogger().debug("containsKey(..): res=" + res); } } catch (KeyNotFound ignore) { } catch (Exception e) { this.getLogger().error("containsKey(..): Exception", e); } if (res > 0) { return true; } else { return false; } } /** * Returns a Enumeration of all Keys in the indexed file.<br> * * @return Enumeration Object with all existing keys */ public Enumeration keys() { // TODO: Implementation return new Vector(0).elements(); } public int size() { // TODO: Unsupported return 0; } /** * 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) { // TODO: Implementation of Integer and Long keys String skey = String.valueOf(key); return new JispStringKey(key.toString()); } } 1.1 xml-cocoon2/src/java/org/apache/cocoon/components/store/JispStringKey.java Index: JispStringKey.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache Cocoon" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.cocoon.components.store; import com.coyotegulch.jisp.KeyObject; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; /** * Wrapper class for String Keys to be compatible with the * Jisp KeyObject. * * @author <a href="mailto:[EMAIL PROTECTED]">Gerhard Froehlich</a> * @version CVS $Id: JispStringKey.java,v 1.1 2002/02/05 14:47:35 vgritsenko Exp $ */ final class JispStringKey extends KeyObject { final static long serialVersionUID = -6894793231339165076L; private String mKey; /** * Constructor for the JispStringKey object */ public JispStringKey() { mKey = new String(""); } /** * Constructor for the JispStringKey object * * @param keyValue the Value of the Key as String */ public JispStringKey(String keyValue) { mKey = keyValue; } /** * Compares two String Keys * * @param key the KeyObject to be compared * @return 0 if equal, 1 if greater, -1 if less */ public int compareTo(KeyObject key) { if (key instanceof JispStringKey) { int comp = mKey.trim().compareTo(((JispStringKey) key).mKey.trim()); if (comp == 0) { return KEY_EQUAL; } else { if (comp < 0) { return KEY_LESS; } else { return KEY_MORE; } } } else { return KEY_ERROR; } } /** * Composes a null Kewy * * @return a null Key */ public KeyObject makeNullKey() { return new JispStringKey(); } /** * The object implements the writeExternal method to save its contents * by calling the methods of DataOutput for its primitive values or * calling the writeObject method of ObjectOutput for objects, strings, * and arrays. * * @param out the stream to write the object to * @exception IOException */ public void writeExternal(ObjectOutput out) throws IOException { String outKey; outKey = new String(mKey); out.writeUTF(outKey); } /** * The object implements the readExternal method to restore its contents * by calling the methods of DataInput for primitive types and readObject * for objects, strings and arrays. The readExternal method must read the * values in the same sequence and with the same types as were written by writeExternal. * * @param in the stream to read data from in order to restore the object * @exception IOException * @exception ClassNotFoundException */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { mKey = in.readUTF(); } /** * Overrides the toString() method * * @return the Key as String */ public String toString() { return mKey; } } 1.23 +0 -14 xml-cocoon2/src/webapp/cocoon.xconf Index: cocoon.xconf =================================================================== RCS file: /home/cvs/xml-cocoon2/src/webapp/cocoon.xconf,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- cocoon.xconf 4 Feb 2002 14:39:48 -0000 1.22 +++ cocoon.xconf 5 Feb 2002 14:47:35 -0000 1.23 @@ -59,25 +59,11 @@ web.xml should be used. directory: Specifies directory to use. Absolute or relative to the work directory. - - JispFilesystemStore configuration: - datafile: name of the store file to use. - indexfile: name of the index file to use. - order: FIXME: put description here. --> <cache-persistent class="org.apache.cocoon.components.store.FilesystemStore" logger="core.store.persistent"> <parameter name="use-cache-directory" value="true"/> </cache-persistent> - <!-- - <cache-persistent class="org.apache.cocoon.components.store.JispFilesystemStore" - logger="core.store.persistent"> - <parameter name="use-cache-directory" value="true"/> - <parameter name="datafile" value="cocoon-cache.dat"/> - <parameter name="indexfile" value="cocoon-cache.idx"/> - <parameter name="order" value="301"/> - </cache-persistent> - --> <!-- Memory Storing: --> <cache-transient class="org.apache.cocoon.components.store.MRUMemoryStore"
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]