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/repository/java/org/apache/cocoon/components/source/impl MultiSourceValidity.java
Date Tue, 28 Oct 2003 13:39:36 GMT
unico       2003/10/28 05:39:36

  Modified:    src/blocks/eventcache/java/org/apache/cocoon/caching/impl
                        EventAwareCacheImpl.java
               src/blocks/repository/java/org/apache/cocoon/components/source/impl
                        MultiSourceValidity.java
  Log:
  Make EventAwareCacheImpl work with MultiSourceValidity. 
  Since EventAwareCacheImpl was only aware of AggregatedValidity 
  components working with MultiSourceValidity such as *TraversableGenerator
  could not be used to take advantage of the event cache mechanism. By 
  having MultiSourceValidity extend AbstractAggregatedValidity and making event cache
  aware of the more general AbstractAggregatedValidity this issue has now been solved
  
  Revision  Changes    Path
  1.7       +5 -5      cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/EventAwareCacheImpl.java
  
  Index: EventAwareCacheImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/EventAwareCacheImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EventAwareCacheImpl.java	2 Oct 2003 04:21:17 -0000	1.6
  +++ EventAwareCacheImpl.java	28 Oct 2003 13:39:36 -0000	1.7
  @@ -59,7 +59,7 @@
   import org.apache.cocoon.caching.validity.Event;
   import org.apache.cocoon.caching.validity.EventValidity;
   import org.apache.excalibur.source.SourceValidity;
  -import org.apache.excalibur.source.impl.validity.AggregatedValidity;
  +import org.apache.excalibur.source.impl.validity.AbstractAggregatedValidity;
   
   /**
    * This implementation holds all mappings between Events and PipelineCacheKeys 
  @@ -202,15 +202,15 @@
   	}
   
       private void examineValidity(SourceValidity val, Serializable key) {
  -        if (val instanceof AggregatedValidity) {
  -            handleAggregatedValidity((AggregatedValidity)val, key);
  +        if (val instanceof AbstractAggregatedValidity) {
  +            handleAggregatedValidity((AbstractAggregatedValidity)val, key);
           } else if (val instanceof EventValidity) {
               handleEventValidity((EventValidity)val, key);
           }
       }
   
       private void handleAggregatedValidity(
  -                                    AggregatedValidity val,
  +                                    AbstractAggregatedValidity val,
                                       Serializable key) {
           // AggregatedValidity must be investigated further.
            Iterator it = val.getValidities().iterator();
  
  
  
  1.2       +14 -12    cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java
  
  Index: MultiSourceValidity.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultiSourceValidity.java	23 Oct 2003 08:52:50 -0000	1.1
  +++ MultiSourceValidity.java	28 Oct 2003 13:39:36 -0000	1.2
  @@ -57,6 +57,7 @@
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceResolver;
   import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.AbstractAggregatedValidity;
   
   /**
    * An aggregated validity for multiple sources.
  @@ -64,11 +65,11 @@
    * @author <a href="http://www.apache.org/~sylvain">Sylvain Wallez</a>
    * @version CVS $Id$
    */
  -public class MultiSourceValidity implements SourceValidity{
  +public class MultiSourceValidity extends AbstractAggregatedValidity implements SourceValidity
{
   
       private long expiry;
       private long delay;
  -    private List data = new ArrayList();
  +    private List uris = new ArrayList();
       private boolean isClosed = false;
       
       /** SourceResolver. Transient in order not to be serialized */
  @@ -81,15 +82,15 @@
       }
       
       public void addSource(Source src) {
  -        if (this.data != null) {
  +        if (this.uris != null) {
               SourceValidity validity = src.getValidity();
               if (validity == null) {
                   // one of the sources has no validity : this object will always be invalid
  -                this.data = null;
  +                this.uris = null;
               } else {
                   // Add the validity and URI to the list
  -                this.data.add(validity);
  -                this.data.add(src.getURI());
  +                super.add(validity);
  +                this.uris.add(src.getURI());
               }
           }
       }
  @@ -105,7 +106,7 @@
           }
           expiry = System.currentTimeMillis() + delay;
           
  -        if (data == null || !isClosed) {
  +        if (uris == null || !isClosed) {
               return -1;
           } else {
               return computeStatus(null);
  @@ -113,7 +114,7 @@
       }
   
       public int isValid(SourceValidity newValidity) {
  -        if (data == null || !isClosed) {
  +        if (uris == null || !isClosed) {
               return -1;
           }
           
  @@ -126,8 +127,9 @@
       }
       
       private int computeStatus(SourceResolver resolver) {
  -        for (int i = 0; i < data.size(); i+=2) {
  -            SourceValidity validity = (SourceValidity)data.get(i);
  +        List validities = super.getValidities();
  +        for (int i = 0; i < validities.size(); i++) {
  +            SourceValidity validity = (SourceValidity) validities.get(i);
               switch(validity.isValid()) {
                   case -1:
                       // invalid : stop examining
  @@ -142,7 +144,7 @@
                           return 0;
                       }
                       try {
  -                        Source newSrc = resolver.resolveURI((String)data.get(i+1));
  +                        Source newSrc = resolver.resolveURI((String) uris.get(i));
                           int value = validity.isValid(newSrc.getValidity());
                           resolver.release(newSrc);
                           if (value != 1) {
  
  
  

Mime
View raw message