You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by cz...@apache.org on 2002/05/02 12:04:05 UTC

cvs commit: jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt TraxErrorHandler.java XSLTProcessor.java XSLTProcessorException.java XSLTProcessorImpl.java

cziegeler    02/05/02 03:04:05

  Modified:    .        build.xml depchecker.xml
               io/src/java/org/apache/avalon/excalibur/io FileUtil.java
               store    build.xml default.properties
               xmlbundle build.xml default.properties
               xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt
                        TraxErrorHandler.java XSLTProcessor.java
                        XSLTProcessorException.java XSLTProcessorImpl.java
  Added:       store/src/java/org/apache/excalibur/store/impl
                        AbstractFilesystemStore.java
  Removed:     store/src/java/org/apache/excalibur/store/impl
                        FilesystemStore.java
  Log:
  Removed dependency from store to io, and added store support to the xslt processor
  
  Revision  Changes    Path
  1.166     +5 -4      jakarta-avalon-excalibur/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/build.xml,v
  retrieving revision 1.165
  retrieving revision 1.166
  diff -u -r1.165 -r1.166
  --- build.xml	2 May 2002 08:55:38 -0000	1.165
  +++ build.xml	2 May 2002 10:04:04 -0000	1.166
  @@ -25,12 +25,13 @@
           <ant dir="threadcontext" target="dist"/>
           <ant dir="sourceresolve" target="dist"/>
           <ant dir="monitor" target="dist"/>
  +        <ant dir="store" target="dist"/>             
           
           <!-- Sub projects with dependencies. -->
           <ant dir="pool" target="dist"/>               <!-- collections, concurrent, instrument -->
           <ant dir="thread" target="dist"/>             <!-- lang, instrument, threadcontext, pool -->
           <ant dir="component" target="dist"/>          <!-- collections, logger, instrument, pool -->
  -        <ant dir="xmlbundle" target="dist"/>          <!-- component -->
  +        <ant dir="xmlbundle" target="dist"/>          <!-- component, store -->
           <ant dir="util" target="dist"/>               <!-- component -->
           <ant dir="testcase" target="dist"/>           <!-- logger, component -->
           <ant dir="event" target="dist"/>              <!-- collections, concurrent, lang, pool, thread, util, event -->
  @@ -46,7 +47,6 @@
           <ant dir="extension" target="dist"/>
           <ant dir="i18n" target="dist"/>
           <ant dir="io" target="dist"/>
  -        <ant dir="store" target="dist"/>              <!-- io -->
           <ant dir="naming" target="dist"/>
           <ant dir="tar" target="dist"/>
           <ant dir="zip" target="dist"/>
  @@ -204,6 +204,7 @@
                       <include name="cli/dist/*.jar"/>
                       <include name="naming/dist/*.jar"/>
                       <include name="monitor/dist/*.jar"/>
  +                    <include name="store/dist/*.jar"/>
                       <!--
                       <include name="instrument-manager/dist/*.jar"/>
                       <include name="instrument-client/dist/*.jar"/>
  @@ -241,13 +242,14 @@
           <ant dir="threadcontext" target="jar"/>
           <ant dir="sourceresolve" target="jar"/>
           <ant dir="monitor" target="jar"/>
  +        <ant dir="store" target="jar"/>              
           
           <!-- Sub projects with dependencies. -->
           <ant dir="pool" target="jar"/>               <!-- collections, concurrent, instrument, sourceresolve -->
           <ant dir="datasource" target="jar"/>         <!-- pool -->
           <ant dir="thread" target="jar"/>             <!-- lang, instrument, threadcontext, pool -->
           <ant dir="component" target="jar"/>          <!-- collections, logger, instrument, pool -->
  -        <ant dir="xmlbundle" target="jar"/>          <!-- component -->
  +        <ant dir="xmlbundle" target="jar"/>          <!-- component, store -->
           <ant dir="util" target="jar"/>               <!-- component -->
           <ant dir="testcase" target="jar"/>           <!-- logger, component -->
           <ant dir="event" target="jar"/>              <!-- collections, concurrent, lang, pool, thread, util, event -->
  @@ -263,7 +265,6 @@
           <ant dir="extension" target="jar"/>
           <ant dir="i18n" target="jar"/>
           <ant dir="io" target="jar"/>
  -        <ant dir="store" target="jar"/>              <!-- io -->
           <ant dir="naming" target="jar"/>
           <ant dir="tar" target="jar"/>
           <ant dir="zip" target="jar"/>
  
  
  
  1.26      +8 -1      jakarta-avalon-excalibur/depchecker.xml
  
  Index: depchecker.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/depchecker.xml,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- depchecker.xml	2 May 2002 08:55:38 -0000	1.25
  +++ depchecker.xml	2 May 2002 10:04:04 -0000	1.26
  @@ -3,7 +3,7 @@
   <!--
   ============================================================
                   Dependency updater
  -                   Version $Revision: 1.25 $
  +                   Version $Revision: 1.26 $
              Jeff Turner <je...@apache.org>
   
   This Ant script provides "functions" to check if
  @@ -387,6 +387,13 @@
               <property name="name" value="excalibur-io.jar"/>
               <property name="path" value="${excalibur-io.jar}"/>
               <property name="proj.home" value="${basedir}/../io"/>
  +        </ant>
  +    </target>
  +    <target name="checkStore">
  +        <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkRequiredFile">
  +            <property name="name" value="excalibur-store.jar"/>
  +            <property name="path" value="${excalibur-store.jar}"/>
  +            <property name="proj.home" value="${basedir}/../store"/>
           </ant>
       </target>
       <target name="checkLogkit">
  
  
  
  1.27      +1 -23     jakarta-avalon-excalibur/io/src/java/org/apache/avalon/excalibur/io/FileUtil.java
  
  Index: FileUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/io/src/java/org/apache/avalon/excalibur/io/FileUtil.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- FileUtil.java	2 May 2002 08:55:38 -0000	1.26
  +++ FileUtil.java	2 May 2002 10:04:04 -0000	1.27
  @@ -44,7 +44,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:jefft@apache.org">Jeff Turner</a>
  - * @version CVS $Revision: 1.26 $ $Date: 2002/05/02 08:55:38 $
  + * @version CVS $Revision: 1.27 $ $Date: 2002/05/02 10:04:04 $
    * @since 4.0
    */
   public final class FileUtil
  @@ -776,28 +776,6 @@
           }
   
           return size;
  -    }
  -
  -    /**
  -     * Get the complete filename corresponding to a (typically relative)
  -     * <code>File</code>.
  -     * This method accounts for the possibility of an error in getting
  -     * the filename's <i>canonical</i> path, returning the io/error-safe
  -     * <i>absolute</i> form instead
  -     *
  -     * @param file The file
  -     * @return The file's absolute filename
  -     */
  -    public static String getFullFilename(File file)
  -    {
  -        try
  -        {
  -            return file.getCanonicalPath();
  -        }
  -        catch (Exception e)
  -        {
  -            return file.getAbsolutePath();
  -        }
       }
   
   }
  
  
  
  1.2       +0 -2      jakarta-avalon-excalibur/store/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/store/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	2 May 2002 08:55:38 -0000	1.1
  +++ build.xml	2 May 2002 10:04:04 -0000	1.2
  @@ -14,7 +14,6 @@
           <pathelement location="${build.classes}"/>
           <pathelement location="${avalon-framework.jar}"/>
           <pathelement location="${excalibur-pool.jar}"/>
  -        <pathelement location="${excalibur-io.jar}"/>
           <pathelement location="${checkstyle.jar}"/>
           <pathelement path="${java.class.path}"/>
       </path>
  @@ -40,7 +39,6 @@
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkCommon"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkFramework"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkPool"/>
  -        <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkIO"/>
       </target>
   
       <target name="dependencies-test" depends="dist-jar, dependencies"
  
  
  
  1.2       +0 -5      jakarta-avalon-excalibur/store/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/store/default.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- default.properties	2 May 2002 08:55:38 -0000	1.1
  +++ default.properties	2 May 2002 10:04:04 -0000	1.2
  @@ -25,11 +25,6 @@
   excalibur-pool.lib=${excalibur-pool.home}
   excalibur-pool.jar=${excalibur-pool.lib}/excalibur-pool-1.0.jar
   
  -# ----- Excalibur IO, version 1.1 or later -----
  -excalibur-io.home=${basedir}/../io/dist
  -excalibur-io.lib=${excalibur-io.home}
  -excalibur-io.jar=${excalibur-io.lib}/excalibur-io-1.1.jar
  -
   # --------------------------------------------------
   
   #  Settings used to configure compile environment
  
  
  
  1.1                  jakarta-avalon-excalibur/store/src/java/org/apache/excalibur/store/impl/AbstractFilesystemStore.java
  
  Index: AbstractFilesystemStore.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.store.impl;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.excalibur.store.Store;
  import java.io.*;
  import java.util.BitSet;
  import java.util.Enumeration;
  
  /**
   * Stores objects on the filesystem: String objects as text files,
   * all other objects are serialized. This class must be subclassed
   * in order to set the directory the store should work on.
   *
   * @author ?
   * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
   * @version CVS $Id: AbstractFilesystemStore.java,v 1.1 2002/05/02 10:04:05 cziegeler Exp $
   */
  public abstract class AbstractFilesystemStore
  extends AbstractLogEnabled
  implements Store, ThreadSafe {
  
      /** The directory repository */
      protected File directoryFile;
      protected volatile String directoryPath;
  
      /**
       * Sets the repository's location
       */
      public void setDirectory(final String directory)
      throws IOException {
          this.setDirectory(new File(directory));
      }
  
      /**
       * Sets the repository's location
       */
      public void setDirectory(final File directory)
      throws IOException {
          this.directoryFile = directory;
  
          /* Save directory path prefix */
          this.directoryPath = this.getFullFilename(this.directoryFile);
          this.directoryPath += File.separator;
  
          /* Does directory exist? */
          if (!this.directoryFile.exists()) {
              /* Create it anew */
              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"
              );
          }
      }
  
      /**
       * Returns the repository's full pathname
       */
      public String getDirectoryPath() {
          return this.directoryPath;
      }
  
      /**
       * Get the File object associated with the given unique key name.
       */
      public synchronized Object get(final Object key) {
          final File file = fileFromKey(key);
  
          if (file != null && file.exists()) {
              if (this.getLogger().isDebugEnabled()) {
                  getLogger().debug("Found file: " + key);
              }
              try {
                  return this.deserializeObject(file);
              } catch (Exception any) {
                  getLogger().error("Error during deseralization.", any);
              }
          } else {
              if (this.getLogger().isDebugEnabled()) {
                  getLogger().debug("NOT Found file: " + key);
              }
          }
  
          return null;
      }
  
      /**
       * Store the given object in a persistent state.
       * 1) Null values generate empty directories.
       * 2) String values are dumped to text files
       * 3) Object values are serialized
       */
      public synchronized void store(final Object key, final Object value)
      throws IOException {
          final File file = fileFromKey(key);
  
          /* Create subdirectories as needed */
          final File parent = file.getParentFile();
          if (parent != null) {
              parent.mkdirs();
          }
  
          /* Store object as file */
          if (value == null) { /* Directory */
              if (file.exists()) {
                  if (!file.delete()) { /* FAILURE */
                      getLogger().error("File cannot be deleted: " + file.toString());
                      return;
                  }
              }
  
              file.mkdir();
          } else if (value instanceof String) {
              /* Text file */
              this.serializeString(file, (String) value);
          } else {
              /* Serialized Object */
              this.serializeObject(file, value);
          }
      }
  
      /**
       * Holds the given object in a volatile state.
       */
      public synchronized void hold(final Object key, final Object value)
      throws IOException {
          this.store(key, value);
          final File file = (File) this.fileFromKey(key);
          if (file != null) {
            file.deleteOnExit();
          }
      }
  
      /**
       * Remove the object associated to the given key.
       */
      public synchronized void remove(final Object key) {
          final File file = fileFromKey(key);
          if (file != null) {
              file.delete();
          }
      }
  
      /**
       * Indicates if the given key is associated to a contained object.
       */
      public synchronized boolean containsKey(final Object key) {
          final File file = fileFromKey(key);
          if (file == null) {
              return false;
          }
          return file.exists();
      }
  
      /**
       * Returns the list of stored files as an Enumeration of Files
       */
      public synchronized Enumeration keys() {
          final FSEnumeration enum = new FSEnumeration();
          this.addKeys(enum, this.directoryFile);
          return enum;
      }
  
      /**
       * Returns count of the objects in the store, or -1 if could not be
       * obtained.
       */
      public synchronized int size() {
          return countKeys(this.directoryFile);
      }
  
      protected void addKeys(FSEnumeration enum, File directory) {
          final int subStringBegin = this.directoryFile.getAbsolutePath().length() + 1;
          final File[] files = directory.listFiles();
          for (int i=0; i<files.length; i++) {
              if (files[i].isDirectory()) {
                  this.addKeys(enum, files[i]);
              } else {
                  enum.add(this.decode(files[i].getAbsolutePath().substring(subStringBegin)));
              }
          }
      }
  
      protected int countKeys(File directory) {
          int count = 0;
          final File[] files = directory.listFiles();
          for (int i=0; i<files.length; i++) {
              if (files[i].isDirectory()) {
                  count += this.countKeys(files[i]);
              } else {
                  count ++;
              }
          }
          return count;
      }
  
      final class FSEnumeration implements Enumeration {
          private String[] array;
          private int      index;
          private int      length;
  
          FSEnumeration() {
              this.array = new String[16];
              this.length = 0;
              this.index = 0;
          }
  
          public void add(String key) {
              if (this.length == array.length) {
                  String[] newarray = new String[this.length + 16];
                  System.arraycopy(this.array, 0, newarray, 0, this.array.length);
                  this.array = newarray;
              }
              this.array[this.length] = key;
              this.length++;
          }
  
          public boolean hasMoreElements() {
              return (this.index < this.length);
          }
  
          public Object nextElement() {
              if (this.hasMoreElements()) {
                  this.index++;
                  return this.array[index-1];
              }
              return null;
          }
      }
  
      /* Utility Methods*/
      protected File fileFromKey(final Object key) {
          File file = new File(this.directoryFile, this.encode(key.toString()));
          File parent = file.getParentFile();
          if (parent != null) parent.mkdirs();
          return file;
      }
  
      public String getString(final Object key)
      throws IOException {
          final File file = (File) this.fileFromKey(key);
          if (file != null) {
              return this.deserializeString(file);
          }
  
          return null;
      }
  
      public synchronized void free() {}
  
      public synchronized Object getObject(final Object key)
      throws IOException, ClassNotFoundException
      {
          final File file = (File) this.fileFromKey(key);
          if (file != null) {
              return this.deserializeObject(file);
          }
  
          return null;
      }
  
      /**
       * Inverse of encode exept it do not use path.
       * So decode(encode(s) - m_path) = s.
       * In other words it returns a String that can be used as key to retive
       * the record contained in the 'filename' file.
       */
      protected String decode( String filename )
      {
          return java.net.URLDecoder.decode( filename );
      }
  
      /** A BitSet defining the characters which don't need encoding */
      static BitSet charactersDontNeedingEncoding;
      static final int characterCaseDiff = ('a' - 'A');
  
      /** Initialize the BitSet */
      static
      {
          charactersDontNeedingEncoding = new BitSet(256);
          int i;
          for (i = 'a'; i <= 'z'; i++)
          {
              charactersDontNeedingEncoding.set(i);
          }
          for (i = 'A'; i <= 'Z'; i++)
          {
              charactersDontNeedingEncoding.set(i);
          }
          for (i = '0'; i <= '9'; i++)
          {
              charactersDontNeedingEncoding.set(i);
          }
          charactersDontNeedingEncoding.set('-');
          charactersDontNeedingEncoding.set('_');
          charactersDontNeedingEncoding.set('(');
          charactersDontNeedingEncoding.set(')');
      }
  
      /**
       * Returns a String that uniquely identifies the object.
       * <b>Note:</b> since this method uses the Object.toString()
       * method, it's up to the caller to make sure that this method
       * doesn't change between different JVM executions (like
       * it may normally happen). For this reason, it's highly recommended
       * (even if not mandated) that Strings be used as keys.
       */
      public String encode(String s) {
          final StringBuffer out = new StringBuffer( s.length() );
          final ByteArrayOutputStream buf = new ByteArrayOutputStream( 32 );
          final OutputStreamWriter writer = new OutputStreamWriter( buf );
          for (int i = 0; i < s.length(); i++)
          {
              int c = (int)s.charAt(i);
              if (charactersDontNeedingEncoding.get(c))
              {
                  out.append((char)c);
              }
              else
              {
                  try
                  {
                      writer.write(c);
                      writer.flush();
                  }
                  catch(IOException e)
                  {
                      buf.reset();
                      continue;
                  }
                  byte[] ba = buf.toByteArray();
                  for (int j = 0; j < ba.length; j++)
                  {
                      out.append('%');
                      char ch = Character.forDigit((ba[j] >> 4) & 0xF, 16);
                      // converting to use uppercase letter as part of
                      // the hex value if ch is a letter.
                      if (Character.isLetter(ch))
                      {
                          ch -= characterCaseDiff;
                      }
                      out.append(ch);
                      ch = Character.forDigit(ba[j] & 0xF, 16);
                      if (Character.isLetter(ch))
                      {
                          ch -= characterCaseDiff;
                      }
                      out.append(ch);
                  }
                  buf.reset();
              }
          }
  
          return out.toString();
      }
  
      /**
       * Dump a <code>String</code> to a text file.
       *
       * @param file The output file
       * @param string The string to be dumped
       * @exception IOException IO Error
       */
      public void serializeString(File file, String string)
      throws IOException {
          final Writer fw = new FileWriter(file);
          try {
              fw.write(string);
              fw.flush();
          } finally {
              if (fw != null) fw.close();
          }
      }
  
      /**
       * Load a text file contents as a <code>String<code>.
       * This method does not perform enconding conversions
       *
       * @param file The input file
       * @return The file contents as a <code>String</code>
       * @exception IOException IO Error
       */
      public String deserializeString(File file)
      throws IOException {
          int len;
          char[] chr = new char[4096];
          final StringBuffer buffer = new StringBuffer();
          final FileReader reader = new FileReader(file);
          try {
              while ((len = reader.read(chr)) > 0) {
                  buffer.append(chr, 0, len);
              }
          } finally {
              if (reader != null) reader.close();
          }
          return buffer.toString();
      }
  
      /**
       * This method serializes an object to an output stream.
       *
       * @param file The output file
       * @param object The object to be serialized
       * @exception IOException IOError
       */
  
      public void serializeObject(File file, Object object)
      throws IOException {
          FileOutputStream fos = new FileOutputStream(file);
          try {
              ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(fos));
              oos.writeObject(object);
              oos.flush();
          } finally {
              if (fos != null) fos.close();
          }
      }
  
      /**
       * This method deserializes an object from an input stream.
       *
       * @param file The input file
       * @return The deserialized object
       * @exception IOException IOError
       */
      public Object deserializeObject(File file)
      throws IOException, ClassNotFoundException {
          FileInputStream fis = new FileInputStream(file);
          Object object = null;
          try {
              ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(fis));
              object = ois.readObject();
          } finally {
              if (fis != null) fis.close();
          }
          return object;
      }
  
      /**
       * Get the complete filename corresponding to a (typically relative)
       * <code>File</code>.
       * This method accounts for the possibility of an error in getting
       * the filename's <i>canonical</i> path, returning the io/error-safe
       * <i>absolute</i> form instead
       *
       * @param file The file
       * @return The file's absolute filename
       */
      public String getFullFilename(File file)
      {
          try
          {
              return file.getCanonicalPath();
          }
          catch (Exception e)
          {
              return file.getAbsolutePath();
          }
      }
  
  }
  
  
  
  1.19      +2 -0      jakarta-avalon-excalibur/xmlbundle/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xmlbundle/build.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- build.xml	26 Apr 2002 01:36:23 -0000	1.18
  +++ build.xml	2 May 2002 10:04:05 -0000	1.19
  @@ -19,6 +19,7 @@
           <pathelement location="${excalibur-component.jar}"/>
           <pathelement location="${excalibur-pool.jar}"/>
           <pathelement location="${excalibur-sourceresolve.jar}"/>
  +        <pathelement location="${excalibur-store.jar}"/>
           <pathelement location="${checkstyle.jar}"/>
           <pathelement location="${xalan.jar}"/>
           <pathelement location="${xerces.jar}"/>
  @@ -67,6 +68,7 @@
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkComponent"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkPool"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkSourceResolve"/>
  +        <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkStore"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkRequiredFile">
               <property name="name" value="xerces.jar"/>
               <property name="path" value="${xerces.jar}"/>
  
  
  
  1.11      +5 -0      jakarta-avalon-excalibur/xmlbundle/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xmlbundle/default.properties,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- default.properties	27 Apr 2002 12:47:50 -0000	1.10
  +++ default.properties	2 May 2002 10:04:05 -0000	1.11
  @@ -45,6 +45,11 @@
   excalibur-sourceresolve.lib=${excalibur-sourceresolve.home}
   excalibur-sourceresolve.jar=${excalibur-sourceresolve.lib}/excalibur-sourceresolve-1.0.jar
   
  +# ----- Excalibur Store, version 1.0 or later -----
  +excalibur-store.home=${basedir}/../store/dist
  +excalibur-store.lib=${excalibur-store.home}
  +excalibur-store.jar=${excalibur-store.lib}/excalibur-store-1.0.jar
  +
   # --------------------------------------------------
   tools.dir=${basedir}/../../jakarta-avalon/tools
   
  
  
  
  1.2       +7 -50     jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt/TraxErrorHandler.java
  
  Index: TraxErrorHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt/TraxErrorHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TraxErrorHandler.java	24 Apr 2002 18:23:27 -0000	1.1
  +++ TraxErrorHandler.java	2 May 2002 10:04:05 -0000	1.2
  @@ -1,53 +1,10 @@
   /*
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  -
  - Copyright (C) 1999-2002 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  <st...@apache.org>. For more  information on the Apache
  - Software Foundation, please see <http://www.apache.org/>.
  -
  -*/
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
   package org.apache.avalon.excalibur.xml.xslt;
   
   import javax.xml.transform.ErrorListener;
  @@ -62,7 +19,7 @@
    * Warnings and errors are ignored.
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Id: TraxErrorHandler.java,v 1.1 2002/04/24 18:23:27 proyal Exp $
  + * @version CVS $Id: TraxErrorHandler.java,v 1.2 2002/05/02 10:04:05 cziegeler Exp $
    */
   public class TraxErrorHandler implements ErrorListener {
   
  
  
  
  1.3       +7 -50     jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt/XSLTProcessor.java
  
  Index: XSLTProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt/XSLTProcessor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSLTProcessor.java	25 Apr 2002 07:09:53 -0000	1.2
  +++ XSLTProcessor.java	2 May 2002 10:04:05 -0000	1.3
  @@ -1,53 +1,10 @@
   /*
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  -
  - Copyright (C) 1999-2002 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  <st...@apache.org>. For more  information on the Apache
  - Software Foundation, please see <http://www.apache.org/>.
  -
  -*/
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
   package org.apache.avalon.excalibur.xml.xslt;
   
   import javax.xml.transform.Result;
  @@ -65,7 +22,7 @@
    *
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
    * @author <a href="mailto:proyal@apache.org">Peter Royal</a>
  - * @version CVS $Id: XSLTProcessor.java,v 1.2 2002/04/25 07:09:53 cziegeler Exp $
  + * @version CVS $Id: XSLTProcessor.java,v 1.3 2002/05/02 10:04:05 cziegeler Exp $
    * @version 1.0
    * @since   July 11, 2001
    */
  
  
  
  1.2       +6 -49     jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt/XSLTProcessorException.java
  
  Index: XSLTProcessorException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt/XSLTProcessorException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSLTProcessorException.java	24 Apr 2002 18:23:27 -0000	1.1
  +++ XSLTProcessorException.java	2 May 2002 10:04:05 -0000	1.2
  @@ -1,53 +1,10 @@
   /*
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  -
  - Copyright (C) 1999-2002 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  <st...@apache.org>. For more  information on the Apache
  - Software Foundation, please see <http://www.apache.org/>.
  -
  -*/
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
   package org.apache.avalon.excalibur.xml.xslt;
   
   import org.apache.avalon.framework.CascadingException;
  
  
  
  1.3       +63 -104   jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt/XSLTProcessorImpl.java
  
  Index: XSLTProcessorImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/xmlbundle/src/java/org/apache/avalon/excalibur/xml/xslt/XSLTProcessorImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSLTProcessorImpl.java	25 Apr 2002 07:09:53 -0000	1.2
  +++ XSLTProcessorImpl.java	2 May 2002 10:04:05 -0000	1.3
  @@ -1,53 +1,10 @@
   /*
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  -
  - Copyright (C) 1999-2002 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  <st...@apache.org>. For more  information on the Apache
  - Software Foundation, please see <http://www.apache.org/>.
  -
  -*/
  + * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *
  + * This software is published under the terms of the Apache Software License
  + * version 1.1, a copy of which has been included  with this distribution in
  + * the LICENSE.txt file.
  + */
   package org.apache.avalon.excalibur.xml.xslt;
   
   import java.io.File;
  @@ -80,7 +37,9 @@
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceException;
   import org.apache.excalibur.source.SourceResolver;
  +import org.apache.excalibur.source.SourceValidity;
   import org.apache.excalibur.xmlizer.XMLizer;
  +import org.apache.excalibur.store.Store;
   
   /**
    * This class defines the implementation of the {@link XSLTProcessor}
  @@ -96,11 +55,10 @@
    * classpath. If this property is not set, the transformer uses the standard TRAX mechanism
    * (<code>TransformerFactory.newInstance()</code>).
    *
  - * Currently the Store code is non-operational
    *
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
    * @author <a href="mailto:proyal@apache.org">Peter Royal</a>
  - * @version CVS $Id: XSLTProcessorImpl.java,v 1.2 2002/04/25 07:09:53 cziegeler Exp $
  + * @version CVS $Id: XSLTProcessorImpl.java,v 1.3 2002/05/02 10:04:05 cziegeler Exp $
    * @version 1.0
    * @since   July 11, 2001
    */
  @@ -111,7 +69,7 @@
       protected ComponentManager manager;
   
       /** The store service instance */
  -//    protected Store store;
  +    protected Store store;
   
       /** The trax TransformerFactory */
       protected SAXTransformerFactory tfactory;
  @@ -139,7 +97,7 @@
       {
           this.manager = manager;
           this.getLogger().debug( "XSLTProcessorImpl component initialized." );
  -//        this.store = (Store)manager.lookup(Store.TRANSIENT_CACHE);
  +        this.store = (Store)manager.lookup(Store.TRANSIENT_STORE);
           this.errorHandler = new TraxErrorHandler( this.getLogger() );
           this.resolver = (SourceResolver)this.manager.lookup( SourceResolver.ROLE );
       }
  @@ -153,8 +111,8 @@
           {
               this.manager.release( this.resolver );
               this.resolver = null;
  -//            this.manager.release(this.store);
  -//            this.store = null;
  +            this.manager.release(this.store);
  +            this.store = null;
           }
           this.errorHandler = null;
           this.manager = null;
  @@ -391,55 +349,56 @@
           return tfactory;
       }
   
  -// TODO: Can't implement until the we have a store. Change to use SourceValidity instead
  -//
  -//    private Templates getTemplates(Source stylesheet, String id)
  -//    throws IOException, XSLTProcessorException {
  -//        if (!useStore)
  -//            return null;
  -//
  -//        if (getLogger().isDebugEnabled()) getLogger().debug("XSLTProcessorImpl getTemplates: stylesheet " + id);
  -//
  -//        Templates templates = null;
  -//        // only stylesheets with a last modification date are stored
  -//
  -//        if (stylesheet.getLastModified() != 0) {
  -//            // Stored is an array of the template and the caching time
  -//            if (store.containsKey(id)) {
  -//                Object[] templateAndTime = (Object[])store.get(id);
  -//
  -//                if(templateAndTime != null && templateAndTime[1] != null) {
  -//                    long storedTime = ((Long)templateAndTime[1]).longValue();
  -//
  -//                    if (storedTime < stylesheet.getLastModified()) {
  -//                        store.remove(id);
  -//                    } else {
  -//                        templates = (Templates)templateAndTime[0];
  -//                    }
  -//                }
  -//            }
  -//        } else if (store.containsKey(id)) {
  -//            // remove an old template if it exists
  -//            store.remove(id);
  -//        }
  -//        return templates;
  -//    }
  -//
  -//    private void putTemplates (Templates templates, Source stylesheet, String id)
  -//    throws IOException, XSLTProcessorException {
  -//        if (!useStore)
  -//            return;
  -//
  -//        // only stylesheets with a last modification date are stored
  -//        if (stylesheet.getLastModified() != 0) {
  -//
  -//            // Stored is an array of the template and the current time
  -//            Object[] templateAndTime = new Object[2];
  -//            templateAndTime[0] = templates;
  -//            templateAndTime[1] = new Long(stylesheet.getLastModified());
  -//            store.hold(id, templateAndTime);
  -//        }
  -//    }
  +    private Templates getTemplates(Source stylesheet, String id)
  +    throws IOException, XSLTProcessorException {
  +        if (!useStore)
  +            return null;
  +
  +        if (getLogger().isDebugEnabled()) getLogger().debug("XSLTProcessorImpl getTemplates: stylesheet " + id);
  +
  +        Templates templates = null;
  +        // only stylesheets with a validity are stored
  +
  +        if (store.containsKey(id)) {
  +            Object[] templateAndValidity = (Object[])store.get(id);
  +
  +            SourceValidity storedValidity = (SourceValidity)templateAndValidity[1];
  +            boolean isValid = storedValidity.isValid();
  +            if ( !isValid ) {
  +                SourceValidity validity = stylesheet.getValidity();
  +                if ( null != validity) {
  +
  +                    isValid = storedValidity.isValid( validity );
  +
  +                }
  +            }
  +
  +            if ( isValid ) {
  +                templates = (Templates)templateAndValidity[0];
  +            } else {
  +                // remove an old template if it exists
  +                store.remove(id);
  +            }
  +        }
  +        return templates;
  +    }
  +
  +    private void putTemplates (Templates templates, Source stylesheet, String id)
  +    throws IOException, XSLTProcessorException {
  +        if (!useStore)
  +            return;
  +
  +        // only stylesheets with a last modification date are stored
  +        SourceValidity validity = stylesheet.getValidity();
  +        if ( null != validity ) {
  +
  +            // Stored is an array of the template and the current time
  +            Object[] templateAndValidity = new Object[2];
  +            templateAndValidity[0] = templates;
  +            templateAndValidity[1] = validity;
  +            store.hold(id, templateAndValidity);
  +        }
  +    }
   
       /**
        * Called by the processor when it encounters
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>