cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/servlet BootstrapServlet.java ParanoidClassLoader.java ParanoidCocoonServlet.java
Date Thu, 11 Dec 2003 18:20:08 GMT
sylvain     2003/12/11 10:20:08

  Modified:    src/java/org/apache/cocoon cocoon.roles
               src/java/org/apache/cocoon/caching/impl CacheImpl.java
               src/java/org/apache/cocoon/components/store/impl
                        DefaultStore.java
  Added:       src/java/org/apache/cocoon/components/store/impl
                        DefaultPersistentStore.java
                        DefaultTransientStore.java
  Removed:     src/java/org/apache/cocoon/servlet BootstrapServlet.java
                        ParanoidClassLoader.java ParanoidCocoonServlet.java
  Log:
  Fix the store: transient store is now really transient
  
  Revision  Changes    Path
  1.11      +6 -2      cocoon-2.1/src/java/org/apache/cocoon/cocoon.roles
  
  Index: cocoon.roles
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/cocoon.roles,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- cocoon.roles	5 Sep 2003 11:40:42 -0000	1.10
  +++ cocoon.roles	11 Dec 2003 18:20:08 -0000	1.11
  @@ -61,12 +61,16 @@
   
     <!-- Stores: -->
     <role name="org.apache.excalibur.store.Store"
  -       shorthand="persistent-store"
  +       shorthand="store"
          default-class="org.apache.cocoon.components.store.impl.DefaultStore"/>
   
  +  <role name="org.apache.excalibur.store.Store/PersistentStore"
  +        shorthand="persistent-store"
  +        default-class="org.apache.cocoon.components.store.impl.DefaultPersistentStore"/>
  +
     <role name="org.apache.excalibur.store.Store/TransientStore"
           shorthand="transient-store"
  -        default-class="org.apache.excalibur.store.impl.MRUMemoryStore"/>
  +        default-class="org.apache.cocoon.components.store.impl.DefaultTransientStore"/>
   
     <role name="org.apache.excalibur.store.StoreJanitor"
          shorthand="store-janitor"
  
  
  
  1.8       +2 -2      cocoon-2.1/src/java/org/apache/cocoon/caching/impl/CacheImpl.java
  
  Index: CacheImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/caching/impl/CacheImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CacheImpl.java	8 Aug 2003 11:15:11 -0000	1.7
  +++ CacheImpl.java	11 Dec 2003 18:20:08 -0000	1.8
  @@ -173,7 +173,7 @@
        * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
        */
       public void parameterize(Parameters parameters) throws ParameterException {
  -        String storeName = parameters.getParameter("store", Store.TRANSIENT_STORE);
  +        String storeName = parameters.getParameter("store", Store.ROLE);
           try {
               this.store = (Store)this.manager.lookup(storeName);
           } catch (ComponentException ce) {
  
  
  
  1.7       +12 -145   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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultStore.java	12 Aug 2003 16:01:01 -0000	1.6
  +++ DefaultStore.java	11 Dec 2003 18:20:08 -0000	1.7
  @@ -50,158 +50,25 @@
   */
   package org.apache.cocoon.components.store.impl;
   
  -import java.io.File;
  -import java.io.IOException;
  -
  -import com.coyotegulch.jisp.BTreeIndex;
  -import com.coyotegulch.jisp.IndexedObjectDatabase;
  -import com.coyotegulch.jisp.KeyNotFound;
  -
  -import org.apache.avalon.framework.activity.Disposable;
  -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.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 org.apache.excalibur.store.impl.AbstractJispFilesystemStore;
  +import org.apache.excalibur.store.impl.MRUMemoryStore;
   
   /**
  - * 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:g-froehlich@gmx.de">Gerhard Froehlich</a>
  - * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
  + * Default implementation of Cocoon's store. It's a <code>MRUMemoryStore</code>
whose
  + * "<code>use-persistent-cache</code>" parameter defaults to <code>true</code>.
  + * <p>
  + * This default setting allows the store to be an in-memory front-end to the persistent
store.
  + * 
  + * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
    * @version CVS $Id$
    */
  -public class DefaultStore extends AbstractJispFilesystemStore
  -    implements org.apache.excalibur.store.Store,
  -               Contextualizable,
  -               ThreadSafe,
  -               Parameterizable,
  -               Disposable {
  -
  -    /** The context containing the work and the cache directory */
  -    protected Context context;
  +public class DefaultStore extends MRUMemoryStore {
       
  -    /**
  -     * Contextualize the Component
  -     *
  -     * @param  context the Context of the Application
  -     * @exception  ContextException
  -     */
  -    public void contextualize(final Context context) throws ContextException {
  -        this.context = context;
  -    }
  -
  -    /**
  -     *  Configure the Component.<br>
  -     *  A few options can be used
  -     *  <UL>
  -     *    <LI> datafile = the name of the data file (Default: cocoon.dat)
  -     *    </LI>
  -     *    <LI> m_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 {
  -        
  -        // get the directory to use
  -        try {
  -            final File workDir = (File)context.get(Constants.CONTEXT_WORK_DIR);
  -            if (params.getParameterAsBoolean("use-cache-directory", false)) {
  -                final File cacheDir = (File)context.get(Constants.CONTEXT_CACHE_DIR);
  -                if (getLogger().isDebugEnabled()) {
  -                    getLogger().debug("Using cache directory: " + cacheDir);
  -                }
  -                this.setDirectory(cacheDir);
  -            } else if (params.getParameterAsBoolean("use-work-directory", false)) {
  -                if (getLogger().isDebugEnabled()) {
  -                    getLogger().debug("Using work directory: " + workDir);
  -                }
  -                this.setDirectory(workDir);
  -            } else if (params.getParameter("directory", null) != null) {
  -                String dir = params.getParameter("directory");
  -                dir = IOUtils.getContextFilePath(workDir.getPath(), dir);
  -                if (getLogger().isDebugEnabled()) {
  -                    getLogger().debug("Using directory: " + dir);
  -                }
  -                this.setDirectory(new File(dir));
  -            } else {
  -                try {
  -                    // Default
  -                    this.setDirectory(workDir);
  -                } catch (IOException e) {
  -                    // Ignored
  -                }
  -            }
  -        } catch (ContextException ce) {
  -            throw new ParameterException("Unable to get directory information from context.",
ce);
  -        } catch (IOException e) {
  -            throw new ParameterException("Unable to set directory", e);
  -        }
  -
  -        // get store configuration
  -        final String databaseName = params.getParameter("datafile", "cocoon.dat");
  -        final String indexName = params.getParameter("m_indexFile", "cocoon.idx");
  -        final int order = params.getParameterAsInteger("order", 301);
  -        if (getLogger().isDebugEnabled()) {
  -            getLogger().debug("Database file name = " + databaseName);
  -            getLogger().debug("Index file name = " + indexName);
  -            getLogger().debug("Order=" + order);
  -        }
  -
  -        // open index and dat file
  -        final File databaseFile = new File(m_directoryFile, databaseName);
  -        final File indexFile = new File(m_directoryFile, indexName);
  -
  -        if (getLogger().isDebugEnabled()) {
  -            getLogger().debug("Initializing JispFilesystemStore");
  -        }
  -        try {
  -            final boolean databaseExists = databaseFile.exists();
  -            if (getLogger().isDebugEnabled()) {
  -                getLogger().debug("Datafile exists: " + databaseExists);
  -            }
  -            super.m_Database = new IndexedObjectDatabase(databaseFile.toString(),
  -                                                         !databaseExists);
  -
  -            if (!databaseExists) {
  -                // Create new index
  -                super.m_Index = new BTreeIndex(indexFile.toString(),
  -                                               order, super.getNullKey(), false);
  -            } else {
  -                // Open existing index
  -                super.m_Index = new BTreeIndex(indexFile.toString());
  -            }
  -            super.m_Database.attachIndex(super.m_Index);
  -        } catch (KeyNotFound ignore) {
  -        } catch (Exception e) {
  -            getLogger().error("Exception during initialization of jisp store.", e);
  -        }
  -    }
  -
  -    public void dispose() {
  -        try {
  -            getLogger().debug("Disposing");
  -
  -            if (super.m_Index != null) {
  -                super.m_Index.close();
  -            }
  -
  -            if (super.m_Database != null) {
  -                super.m_Database.close();
  -            }
  -        } catch (Exception e) {
  -            getLogger().error("dispose(..) Exception", e);
  +        if (!params.isParameter("use-persistent-cache")) {
  +            params.setParameter("use-persistent-cache", "true");
           }
  +        super.parameterize(params);
       }
   }
  
  
  
  1.1                  cocoon-2.1/src/java/org/apache/cocoon/components/store/impl/DefaultPersistentStore.java
  
  Index: DefaultPersistentStore.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.store.impl;
  
  import java.io.File;
  import java.io.IOException;
  
  import com.coyotegulch.jisp.BTreeIndex;
  import com.coyotegulch.jisp.IndexedObjectDatabase;
  import com.coyotegulch.jisp.KeyNotFound;
  
  import org.apache.avalon.framework.activity.Disposable;
  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.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 org.apache.excalibur.store.impl.AbstractJispFilesystemStore;
  
  /**
   * 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:g-froehlich@gmx.de">Gerhard Froehlich</a>
   * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
   * @version CVS $Id: DefaultPersistentStore.java,v 1.1 2003/12/11 18:20:08 sylvain Exp $
   */
  public class DefaultPersistentStore extends AbstractJispFilesystemStore
      implements org.apache.excalibur.store.Store,
                 Contextualizable,
                 ThreadSafe,
                 Parameterizable,
                 Disposable {
  
      /** The context containing the work and the cache directory */
      protected Context context;
      
      /**
       * Contextualize the Component
       *
       * @param  context the Context of the Application
       * @exception  ContextException
       */
      public void contextualize(final Context context) throws ContextException {
          this.context = context;
      }
  
      /**
       *  Configure the Component.<br>
       *  A few options can be used
       *  <UL>
       *    <LI> datafile = the name of the data file (Default: cocoon.dat)
       *    </LI>
       *    <LI> m_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 {
          
          // get the directory to use
          try {
              final File workDir = (File)context.get(Constants.CONTEXT_WORK_DIR);
              if (params.getParameterAsBoolean("use-cache-directory", false)) {
                  final File cacheDir = (File)context.get(Constants.CONTEXT_CACHE_DIR);
                  if (getLogger().isDebugEnabled()) {
                      getLogger().debug("Using cache directory: " + cacheDir);
                  }
                  this.setDirectory(cacheDir);
              } else if (params.getParameterAsBoolean("use-work-directory", false)) {
                  if (getLogger().isDebugEnabled()) {
                      getLogger().debug("Using work directory: " + workDir);
                  }
                  this.setDirectory(workDir);
              } else if (params.getParameter("directory", null) != null) {
                  String dir = params.getParameter("directory");
                  dir = IOUtils.getContextFilePath(workDir.getPath(), dir);
                  if (getLogger().isDebugEnabled()) {
                      getLogger().debug("Using directory: " + dir);
                  }
                  this.setDirectory(new File(dir));
              } else {
                  try {
                      // Default
                      this.setDirectory(workDir);
                  } catch (IOException e) {
                      // Ignored
                  }
              }
          } catch (ContextException ce) {
              throw new ParameterException("Unable to get directory information from context.",
ce);
          } catch (IOException e) {
              throw new ParameterException("Unable to set directory", e);
          }
  
          // get store configuration
          final String databaseName = params.getParameter("datafile", "cocoon.dat");
          final String indexName = params.getParameter("m_indexFile", "cocoon.idx");
          final int order = params.getParameterAsInteger("order", 301);
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("Database file name = " + databaseName);
              getLogger().debug("Index file name = " + indexName);
              getLogger().debug("Order=" + order);
          }
  
          // open index and dat file
          final File databaseFile = new File(m_directoryFile, databaseName);
          final File indexFile = new File(m_directoryFile, indexName);
  
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("Initializing JispFilesystemStore");
          }
          try {
              final boolean databaseExists = databaseFile.exists();
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("Datafile exists: " + databaseExists);
              }
              super.m_Database = new IndexedObjectDatabase(databaseFile.toString(),
                                                           !databaseExists);
  
              if (!databaseExists) {
                  // Create new index
                  super.m_Index = new BTreeIndex(indexFile.toString(),
                                                 order, super.getNullKey(), false);
              } else {
                  // Open existing index
                  super.m_Index = new BTreeIndex(indexFile.toString());
              }
              super.m_Database.attachIndex(super.m_Index);
          } catch (KeyNotFound ignore) {
          } catch (Exception e) {
              getLogger().error("Exception during initialization of jisp store.", e);
          }
      }
  
      public void dispose() {
          try {
              getLogger().debug("Disposing");
  
              if (super.m_Index != null) {
                  super.m_Index.close();
              }
  
              if (super.m_Database != null) {
                  super.m_Database.close();
              }
          } catch (Exception e) {
              getLogger().error("dispose(..) Exception", e);
          }
      }
  }
  
  
  
  1.1                  cocoon-2.1/src/java/org/apache/cocoon/components/store/impl/DefaultTransientStore.java
  
  Index: DefaultTransientStore.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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
      apache@apache.org.
  
   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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.store.impl;
  
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.excalibur.store.impl.MRUMemoryStore;
  
  /**
   * Default implementation of Cocoon's transient store. This is a <code>MRUMemoryStore</code>
   * that cannot be backed by a persistent store (this ensure it is really transient).
   * 
   * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
   * @version CVS $Id: DefaultTransientStore.java,v 1.1 2003/12/11 18:20:08 sylvain Exp $
   */
  public class DefaultTransientStore extends MRUMemoryStore {
      
      public void parameterize(Parameters params) throws ParameterException {
          if (params.getParameterAsBoolean("use-persistent-cache", false)) {
              throw new ParameterException("A transient store cannot be backed by a persistent
store.");
          }
          super.parameterize(params);
      }
  }
  
  
  

Mime
View raw message