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/01/08 13:55:51 UTC

cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source ModifiableSource.java ResourceSource.java Source.java

cziegeler    02/01/08 04:55:51

  Modified:    src/scratchpad/org/apache/avalon/excalibur/monitor
                        SourceResource.java
               src/scratchpad/org/apache/avalon/excalibur/source
                        ModifiableSource.java ResourceSource.java
                        Source.java
  Log:
  Cleaned up source interface - this finished the working draft - some more javadocs are following
  
  Revision  Changes    Path
  1.2       +19 -4     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/monitor/SourceResource.java
  
  Index: SourceResource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/monitor/SourceResource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceResource.java	17 Dec 2001 10:02:21 -0000	1.1
  +++ SourceResource.java	8 Jan 2002 12:55:51 -0000	1.2
  @@ -7,6 +7,7 @@
    */
   package org.apache.avalon.excalibur.monitor;
   
  +import org.apache.avalon.excalibur.source.ModifiableSource;
   import org.apache.avalon.excalibur.source.Source;
   import org.apache.avalon.excalibur.source.SourceValidity;
   
  @@ -20,15 +21,20 @@
   /**
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version $Id: SourceResource.java,v 1.1 2001/12/17 10:02:21 cziegeler Exp $
  + * @version $Id: SourceResource.java,v 1.2 2002/01/08 12:55:51 cziegeler Exp $
    */
   public final class SourceResource extends StreamResource
   {
  +    /** The wrapped source object */
       private final Source source;
  +    /** Is this a modifiable source? */
  +    private final boolean isModifiableSource;
  +
  +    /** The last validity object */
       private SourceValidity validity;
   
       /**
  -     * Instantiate the SourceResource 
  +     * Instantiate the SourceResource
        */
       public SourceResource ( Source source)
       throws Exception
  @@ -37,7 +43,13 @@
   
           this.source = source;
           m_previousModified = System.currentTimeMillis();
  -        this.validity = source.getValidity();
  +        if (source instanceof ModifiableSource)
  +        {
  +            this.isModifiableSource = true;
  +            this.validity = ((ModifiableSource)source).getValidity();
  +        } else {
  +            this.isModifiableSource = false;
  +        }
       }
   
       /**
  @@ -45,10 +57,13 @@
        */
       public long lastModified()
       {
  +        if ( !this.isModifiableSource )
  +            return 1;
  +
           if (this.validity == null) {
               return System.currentTimeMillis();
           } else {
  -            SourceValidity newVal = this.source.getValidity();
  +            SourceValidity newVal = ((ModifiableSource) this.source).getValidity();
               if ( newVal != null && this.validity.isValid( newVal ) == true) {
                   return m_previousModified;
               } else {
  
  
  
  1.4       +16 -6     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/ModifiableSource.java
  
  Index: ModifiableSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/ModifiableSource.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ModifiableSource.java	11 Dec 2001 09:53:36 -0000	1.3
  +++ ModifiableSource.java	8 Jan 2002 12:55:51 -0000	1.4
  @@ -11,12 +11,22 @@
    * Describes a {@link Source} object whose data content can change.
    *
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
  + * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    */
  -public interface ModifiableSource extends Source
  +public interface ModifiableSource
  +  extends Source
   {
  -  /**
  -   * Refresh the content of this object after the underlying data
  -   * content has changed.
  -   */
  -  void refresh();
  +    /**
  +     *  Get the Validity object. This can either wrap the last modification
  +     *  date or the expires information or...
  +     *  If it is currently not possible to calculate such an information
  +     *  <code>null</code> is returned.
  +     */
  +    SourceValidity getValidity();
  +
  +    /**
  +     * Refresh the content of this object after the underlying data
  +     * content has changed.
  +     */
  +    void refresh();
   }
  
  
  
  1.2       +3 -34     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/ResourceSource.java
  
  Index: ResourceSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/ResourceSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceSource.java	3 Jan 2002 13:03:31 -0000	1.1
  +++ ResourceSource.java	8 Jan 2002 12:55:51 -0000	1.2
  @@ -9,7 +9,6 @@
   
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.excalibur.source.validity.TimeStampValidity;
   import org.apache.avalon.excalibur.xml.Parser;
   import org.apache.avalon.excalibur.xml.XMLConsumer;
   import org.apache.avalon.excalibur.xml.XMLizable;
  @@ -23,19 +22,15 @@
   
   /**
    * Description of a source which is described by the resource protocol
  - * which gets a resource from the cloassload
  + * which gets a resource from the classloader.
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 13:03:31 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/08 12:55:51 $
    */
   
   public final class ResourceSource
   implements Composable, Source, XMLizable
   {
  -    /** Instantiation time of this class for validity. The resources do not
  -     *  change until the jars do not change. (Is this correct?) */
  -    private static SourceValidity initTime = new TimeStampValidity( System.currentTimeMillis() );
  -
       /** The system identifier */
       private String systemId;
   
  @@ -75,21 +70,6 @@
       }
   
       /**
  -     * Return an <code>InputSource</code> object to read the XML
  -     * content.
  -     *
  -     * @return an <code>InputSource</code> value
  -     * @exception IOException if an error occurs
  -     */
  -    public InputSource getInputSource()
  -    throws IOException
  -    {
  -        InputSource newObject = new InputSource(this.getInputStream());
  -        newObject.setSystemId(this.systemId);
  -        return newObject;
  -    }
  -
  -    /**
        * Stream content to a content handler or to an XMLConsumer.
        *
        * @throws ResourceNotFoundException if file not found or
  @@ -103,7 +83,7 @@
           try {
               parser = (Parser)this.manager.lookup(Parser.ROLE);
   
  -            parser.parse(this.getInputSource(), handler);
  +            parser.parse( SourceUtil.getInputSource(this), handler);
           }
           catch (SAXException e)
           {
  @@ -125,17 +105,6 @@
       public String getSystemId()
       {
           return this.systemId;
  -    }
  -
  -    /**
  -     *  Get the Validity object. This can either wrap the last modification
  -     *  date or the expires information or...
  -     *  If it is currently not possible to calculate such an information
  -     *  <code>null</code> is returned.
  -     */
  -    public SourceValidity getValidity()
  -    {
  -        return initTime;
       }
   
   }
  
  
  
  1.9       +5 -10     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/Source.java
  
  Index: Source.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/Source.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Source.java	3 Jan 2002 13:03:31 -0000	1.8
  +++ Source.java	8 Jan 2002 12:55:51 -0000	1.9
  @@ -15,16 +15,19 @@
    * for accessing a source of data. The source of data is assumed to
    * <b>not change</b> during the lifetime of the Source object. If you
    * have a data source that can change its content and you want it to
  - * reflect in Cocoon, use a {@link ModifiableSource} object instead.
  + * reflect it, use a {@link ModifiableSource} object instead.
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
  - * @version CVS $Revision: 1.8 $ $Date: 2002/01/03 13:03:31 $
  + * @version CVS $Revision: 1.9 $ $Date: 2002/01/08 12:55:51 $
    */
   public interface Source {
   
       /**
        * Return an <code>InputStream</code> object to read from the source.
  +     * This is the data at the point of invocation of this method,
  +     * so if this is an {@link ModifiableSource} object, you might get
  +     * different content from two invocations.
        */
       InputStream getInputStream()
       throws IOException;
  @@ -33,13 +36,5 @@
        * Return the unique identifer for this source
        */
       String getSystemId();
  -
  -    /**
  -     *  Get the Validity object. This can either wrap the last modification
  -     *  date or the expires information or...
  -     *  If it is currently not possible to calculate such an information
  -     *  <code>null</code> is returned.
  -     */
  -    SourceValidity getValidity();
   
   }
  
  
  

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