1 16 package org.apache.cocoon.components.source.impl.validity; 17 18 import org.apache.excalibur.source.SourceValidity; 19 20 31 public class DelayedValidity implements SourceValidity { 32 33 private long delay; 34 private long expires; 35 36 private SourceValidity delegate; 37 38 39 public DelayedValidity(long delay, SourceValidity validity) { 40 this.delay = delay; 41 this.expires = System.currentTimeMillis() + delay; 42 this.delegate = validity; 43 } 44 45 public int isValid() { 46 final long currentTime = System.currentTimeMillis(); 47 if (currentTime <= this.expires) { 48 return SourceValidity.VALID; 50 } 51 52 this.expires = currentTime + this.delay; 54 55 return this.delegate.isValid(); 56 } 57 58 public int isValid(SourceValidity newValidity) { 59 return this.delegate.isValid(newValidity); 61 } 62 } 63 | Popular Tags |