You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by un...@apache.org on 2004/11/18 18:46:33 UTC
svn commit: r76260 - cocoon/trunk/src/blocks/scratchpad/java/org/apache/cocoon/components/source/impl
Author: unico
Date: Thu Nov 18 09:46:32 2004
New Revision: 76260
Modified:
cocoon/trunk/src/blocks/scratchpad/java/org/apache/cocoon/components/source/impl/CachingSource.java
Log:
create cached response in the same way irrespective of initialization method
Modified: cocoon/trunk/src/blocks/scratchpad/java/org/apache/cocoon/components/source/impl/CachingSource.java
==============================================================================
--- cocoon/trunk/src/blocks/scratchpad/java/org/apache/cocoon/components/source/impl/CachingSource.java (original)
+++ cocoon/trunk/src/blocks/scratchpad/java/org/apache/cocoon/components/source/impl/CachingSource.java Thu Nov 18 09:46:32 2004
@@ -209,14 +209,7 @@
boolean storeResponse = false;
CachedSourceResponse response = this.response;
if (response == null) {
- SourceValidity[] validities;
- if (this.cache instanceof EventAware) {
- validities = new SourceValidity[] { new EventValidity(new NamedEvent(this.source.getURI())) };
- }
- else {
- validities = new SourceValidity[] { new ExpiresValidity(getExpiration()), source.getValidity() };
- }
- response = new CachedSourceResponse(validities);
+ response = new CachedSourceResponse(getCacheValidities());
storeResponse = true;
}
if (response.getExtra() == null) {
@@ -244,7 +237,7 @@
/* delay caching the response until we have a valid new one */
CachedSourceResponse response = this.response;
if (response == null) {
- response = new CachedSourceResponse(new SourceValidity[] { new ExpiresValidity(getExpiration()), source.getValidity()});
+ response = new CachedSourceResponse(getCacheValidities());
storeResponse = true;
}
if (response.getBinaryResponse() == null) {
@@ -279,7 +272,7 @@
/* delay caching the response until we have a valid new one */
CachedSourceResponse response = this.response;
if (response == null) {
- response = new CachedSourceResponse(new SourceValidity[] { new ExpiresValidity(getExpiration()), source.getValidity() });
+ response = new CachedSourceResponse(getCacheValidities());
storeResponse = true;
}
if (response.getXMLResponse() == null || refresh) {
@@ -621,7 +614,19 @@
}
return valid;
}
-
+
+ private SourceValidity[] getCacheValidities() {
+ if (this.cache instanceof EventAware) {
+ // use event caching strategy, the associated event is the source uri
+ return new SourceValidity[] { new EventValidity(new NamedEvent(this.source.getURI())) };
+ }
+ else {
+ // we need to store both the cache expiration and the original source validity
+ // the former is to determine whether to recheck the latter (see checkValidity)
+ return new SourceValidity[] { new ExpiresValidity(getExpiration()), source.getValidity() };
+ }
+ }
+
private static boolean isValid(SourceValidity oldValidity, SourceValidity newValidity) {
return (oldValidity.isValid() == SourceValidity.VALID ||
(oldValidity.isValid() == SourceValidity.UNKNOWN &&