cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/source/impl InspectableTraversableCachingSource.java
Date Thu, 08 Jul 2004 10:18:14 GMT
unico       2004/07/08 03:18:14

  Modified:    src/blocks/scratchpad/java/org/apache/cocoon/components/source/impl
                        InspectableTraversableCachingSource.java
  Log:
  initialize cached response by getting all properties at once instead of lazily
  getting them one at a time
  
  Revision  Changes    Path
  1.2       +17 -13    cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/source/impl/InspectableTraversableCachingSource.java
  
  Index: InspectableTraversableCachingSource.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/source/impl/InspectableTraversableCachingSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InspectableTraversableCachingSource.java	1 Jul 2004 14:24:36 -0000	1.1
  +++ InspectableTraversableCachingSource.java	8 Jul 2004 10:18:14 -0000	1.2
  @@ -58,6 +58,13 @@
           final InspectableSourceMeta imeta = ((InspectableSourceMeta) super.response.getExtra());
           SourceProperty property = imeta.getSourceProperty(namespace, name);
           if (property == null) {
  +            // In the case of webdav the source cannot
  +            // determine all available properties beforehand.
  +            // Therefore, although we initialized the cached
  +            // response by calling getSourceProperties(),
  +            // this does not mean this particular property
  +            // was returned and cached. Hence we try to 
  +            // get it here still and remember if it was null.
               property = isource.getSourceProperty(namespace, name);
               if (property == null) {
                   // remember that this property is null
  @@ -96,12 +103,7 @@
               return null;
           }
           final InspectableSourceMeta imeta = ((InspectableSourceMeta) super.response.getExtra());
  -        SourceProperty[] properties = imeta.getSourceProperties();
  -        if (properties == null) {
  -            properties = isource.getSourceProperties();
  -            imeta.setSourceProperties(properties);
  -        }
  -        return properties;
  +        return imeta.getSourceProperties();
       }
   
       public void removeSourceProperty(String namespace, String name) throws SourceException
{
  @@ -121,7 +123,13 @@
       protected SourceMeta createMeta() {
           return new InspectableSourceMeta();
       }
  -    
  +
  +    protected void initMeta(SourceMeta meta, Source source) throws IOException {
  +        super.initMeta(meta, source);
  +        final InspectableSourceMeta imeta = ((InspectableSourceMeta) super.response.getExtra());
  +        imeta.setSourceProperties(isource.getSourceProperties());
  +    }
  +
       protected TraversableCachingSource newSource(String uri, Source wrapped) {
           return  new InspectableTraversableCachingSource(super.protocol,
                                                           uri,
  @@ -133,13 +141,10 @@
       
       protected static class InspectableSourceMeta extends TraversableSourceMeta {
           
  -        protected static final SourceProperty NULL_PROPERTY = new SourceProperty("cocoon","isnull");
  +        protected static final SourceProperty NULL_PROPERTY = new SourceProperty("cocoon",
"isnull");
           
           private Map properties;
           
  -        /* flag for determining whether we have all properties */
  -        private boolean all;
  -        
           protected SourceProperty getSourceProperty(String namespace, String name) {
               if (properties == null) return null;
               final String key = namespace + "#" + name;
  @@ -155,7 +160,7 @@
           }
   
           protected SourceProperty[] getSourceProperties() {
  -            if (this.properties == null || !all) return null;
  +            if (this.properties == null) return null;
               final Collection values = this.properties.values();
               return (SourceProperty[]) values.toArray(new SourceProperty[values.size()]);
           }
  @@ -167,7 +172,6 @@
               for (int i = 0; i < props.length; i++) {
                   setSourceProperty(props[i]);
               }
  -            all = true;
           }
           
           protected void removeSourceProperty(String namespace, String name) {
  
  
  

Mime
View raw message