forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stev...@apache.org
Subject cvs commit: xml-forrest/src/scratchpad/src/java/org/outerj/yer/use/cocoon HierarchyGenerator.java
Date Wed, 24 Jul 2002 14:46:19 GMT
stevenn     2002/07/24 07:46:19

  Modified:    src/scratchpad/src/java/org/apache/forrest/components/generator
                        XNIConfigurableFileGenerator.java
               src/scratchpad/src/java/org/outerj/yer/use/cocoon
                        HierarchyGenerator.java
  Log:
  eradicating excalibur Source depreciation warnings, due to mpo@outerthought.org
  
  Revision  Changes    Path
  1.4       +22 -31    xml-forrest/src/scratchpad/src/java/org/apache/forrest/components/generator/XNIConfigurableFileGenerator.java
  
  Index: XNIConfigurableFileGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-forrest/src/scratchpad/src/java/org/apache/forrest/components/generator/XNIConfigurableFileGenerator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XNIConfigurableFileGenerator.java	12 Jul 2002 07:14:29 -0000	1.3
  +++ XNIConfigurableFileGenerator.java	24 Jul 2002 14:46:19 -0000	1.4
  @@ -57,14 +57,11 @@
   package org.apache.forrest.components.generator;
   
   import org.apache.cocoon.generation.ComposerGenerator;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.TimeStampCacheValidity;
  -import org.apache.cocoon.environment.Source;
  -import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  -//import org.apache.cocoon.components.resolver.Resolver;
  +import org.apache.cocoon.components.source.SourceUtil;
  +import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.avalon.excalibur.pool.Recyclable;
   import org.apache.avalon.excalibur.xml.EntityResolver;
   import org.apache.avalon.framework.parameters.Parameters;
  @@ -73,8 +70,9 @@
   import org.apache.xerces.xni.parser.XMLConfigurationException;
   import org.apache.xerces.util.EntityResolverWrapper;
   import org.apache.xerces.parsers.AbstractSAXParser;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.XMLReader;
  +import org.apache.excalibur.source.*;
  +
  +import org.xml.sax.*;
   
   import java.util.Map;
   import java.io.IOException;
  @@ -106,7 +104,7 @@
    * @version CVS $Id$
    */
   public class XNIConfigurableFileGenerator
  -extends ComposerGenerator implements Cacheable, Recyclable
  +extends ComposerGenerator implements CacheableProcessingComponent, Recyclable
   {
   
     /** Default constructor
  @@ -131,12 +129,12 @@
      * All instance variables are set to <code>null</code>.
      */
     public void recycle() {
  -    super.recycle();
       if (this.inputSource != null) {
  -      this.inputSource.recycle();
  +      this.resolver.release(inputSource);
         this.inputSource = null;
       }
  -  }
  +    super.recycle();
  + }
   
     /**
      * Copy paste en serious cut from cocoon HTML Generator
  @@ -144,12 +142,12 @@
     public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
     throws ProcessingException, SAXException, IOException {
       super.setup(resolver, objectModel, src, par);
  -    this.inputSource = resolver.resolve(super.source);
       String parserName = null;
   
       try {
  -      parserName = par.getParameter(CONFIGCLASS_PARAMETER);
  -      parserConfig = (XMLParserConfiguration)Class.forName(parserName).newInstance();
  +        this.inputSource = resolver.resolveURI(super.source);
  +        parserName = par.getParameter(CONFIGCLASS_PARAMETER);
  +        parserConfig = (XMLParserConfiguration)Class.forName(parserName).newInstance();
       } catch(ParameterException e) {
         getLogger().error("Missing parameter " + CONFIGCLASS_PARAMETER, e);
         throw new ProcessingException("XNIConfigurable.setup()",e);
  @@ -162,6 +160,9 @@
       } catch(ClassNotFoundException e) {
         getLogger().error("Can not find " + parserName, e);
         throw new ProcessingException("XNIConfigurable.setup()",e);
  +    } catch (SourceException e) {
  +      getLogger().error("Can not resolve " + super.source);
  +      throw SourceUtil.handle("Unable to resolve " + super.source, e);
       }
     }
   
  @@ -173,16 +174,8 @@
      * @return The generated key or <code>0</code> if the component
      *              is currently not cacheable.
      */
  -  public long generateKey() {
  -/* TODO: investigate how we can handle dependend files
  -   this work was originally for DTD stuff, and external entities to this
  -   will not be known to have changed, so currently no cache.
  -
  -   if (this.inputSource.getLastModified() != 0) {
  -      return HashUtil.hash(this.inputSource.getSystemId());
  -    }
  - */
  -    return 0;
  +  public java.io.Serializable generateKey() {
  +    return this.inputSource.getSystemId();
     }
   
     /**
  @@ -193,9 +186,9 @@
      * @return The generated validity object or <code>null</code> if the
      *         component is currently not cacheable.
      */
  -  public CacheValidity generateValidity() {
  +  public SourceValidity generateValidity() {
       if (this.inputSource.getLastModified() != 0) {
  -      return new TimeStampCacheValidity(this.inputSource.getLastModified());
  +      this.inputSource.getValidity();
       }
       return null;
     }
  @@ -224,7 +217,7 @@
         parser.setFeature("http://xml.org/sax/features/namespaces", true);
         parser.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
         parser.setContentHandler(this.contentHandler);
  -      parser.parse(this.inputSource.getInputSource());
  +      parser.parse(new InputSource(this.inputSource.getInputStream()));
   
       } catch (IOException e){
         getLogger().warn("XNIConfigurable.generate()", e);
  @@ -232,8 +225,6 @@
                 + "src = " + this.inputSource.getSystemId() + "]\n", e);
       } catch (SAXException e){
         getLogger().error("XNIConfigurable.generate()", e);
  -      throw e;
  -    } catch (ProcessingException e){
         throw e;
       } catch (XMLConfigurationException e) {
         getLogger().error( "Misconfig " + e.getType(), e);
  
  
  
  1.2       +21 -18    xml-forrest/src/scratchpad/src/java/org/outerj/yer/use/cocoon/HierarchyGenerator.java
  
  Index: HierarchyGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-forrest/src/scratchpad/src/java/org/outerj/yer/use/cocoon/HierarchyGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HierarchyGenerator.java	11 Jun 2002 13:19:21 -0000	1.1
  +++ HierarchyGenerator.java	24 Jul 2002 14:46:19 -0000	1.2
  @@ -6,12 +6,14 @@
   import org.apache.avalon.excalibur.pool.Recyclable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.generation.ComposerGenerator;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.CacheValidity;
  +
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  -import org.apache.cocoon.environment.Source;
  +import org.apache.cocoon.components.source.SourceUtil;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceValidity;
   import org.xml.sax.SAXException;
   import org.outerj.yer.hierarchy.EntryFactory;
   import org.outerj.yer.hierarchy.Entry;
  @@ -26,13 +28,14 @@
    * @version CVS $Id$
    */
   public class HierarchyGenerator
  -extends ComposerGenerator implements Cacheable, Recyclable {
  +extends ComposerGenerator implements CacheableProcessingComponent, Recyclable {
   
     /** Default constructor
      * 
      */
     public HierarchyGenerator()
     {
  +      System.out.println();
     }
   
     /** The  source */
  @@ -61,8 +64,13 @@
     throws ProcessingException, SAXException, IOException {
       super.setup(resolver, objectModel, src, par);
       //this is a dirty hack!
  -    this.startLocation = resolver.resolve(super.source).getSystemId();
  -    this.theDepth = par.getParameterAsInteger(DEPTH_PARAMETER, DEPTH_DEFAULT);
  +      try {
  +          this.startLocation = resolver.resolveURI(super.source).getSystemId();
  +          this.theDepth = par.getParameterAsInteger(DEPTH_PARAMETER, DEPTH_DEFAULT);
  +      } catch (SourceException e) {
  +          getLogger().error("Can not resolve " + super.source);
  +          throw SourceUtil.handle("Unable to resolve " + super.source, e);
  +      }
     }
   
     /**
  @@ -70,17 +78,12 @@
      * This key must be unique inside the space of this component.
      * This method must be invoked before the generateValidity() method.
      *
  -   * @return The generated key or <code>0</code> if the component
  +   * @return The generated key or <code>null</code> if the component
      *              is currently not cacheable.
      */
  -  public long generateKey() {
  -/* TODO: could we possibly find some test to actually ever find some
  -   easy way of finding out the lastModified of anything in the dir?
  -   if (this.inputSource.getLastModified() != 0) {
  -      return HashUtil.hash(this.inputSource.getSystemId());
  -    }
  - */
  -    return 0;
  +  public java.io.Serializable generateKey() {
  +    //TODO: think about making it cacheable!
  +    return null;
     }
   
     /**
  @@ -91,7 +94,7 @@
      * @return The generated validity object or <code>null</code> if the
      *         component is currently not cacheable.
      */
  -  public CacheValidity generateValidity() {
  +  public SourceValidity generateValidity() {
       /*
       if (this.inputSource.getLastModified() != 0) {
         return new TimeStampCacheValidity(this.inputSource.getLastModified());
  
  
  

Mime
View raw message