You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2008/12/14 21:42:48 UTC
svn commit: r726527 - in /cocoon/cocoon3/trunk:
cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/
cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/
cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/
Author: stevendolg
Date: Sun Dec 14 12:42:48 2008
New Revision: 726527
URL: http://svn.apache.org/viewvc?rev=726527&view=rev
Log:
COCOON3-9 Generalization of the PipelineCache
Added:
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCache.java (with props)
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCacheValue.java (with props)
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/Cache.java (with props)
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ObjectCacheValue.java (with props)
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCache.java (with props)
Removed:
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/PipelineCache.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimplePipelineCache.java
Modified:
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheValue.java
cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompleteCacheValue.java
cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline.xml
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java?rev=726527&r1=726526&r2=726527&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java Sun Dec 14 12:42:48 2008
@@ -53,7 +53,7 @@
@Override
public void execute() throws Exception {
if (this.logger.isDebugEnabled()) {
- this.logger.debug("Used cache: " + this.pipelineCache);
+ this.logger.debug("Used cache: " + this.cache);
}
// construct the current cache key
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java?rev=726527&r1=726526&r2=726527&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java Sun Dec 14 12:42:48 2008
@@ -22,6 +22,7 @@
import java.io.Serializable;
import java.util.Map;
+import org.apache.cocoon.pipeline.caching.Cache;
import org.apache.cocoon.pipeline.caching.CacheKey;
import org.apache.cocoon.pipeline.caching.CacheValue;
import org.apache.cocoon.pipeline.caching.CachingOutputStream;
@@ -29,7 +30,6 @@
import org.apache.cocoon.pipeline.caching.CompoundCacheKey;
import org.apache.cocoon.pipeline.caching.ExpiresCacheKey;
import org.apache.cocoon.pipeline.caching.InvalidCacheKey;
-import org.apache.cocoon.pipeline.caching.PipelineCache;
import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
import org.apache.cocoon.pipeline.component.PipelineComponent;
import org.apache.commons.logging.Log;
@@ -37,8 +37,9 @@
/**
* <p>
- * A {@link Pipeline} implementation that returns a cached result if, and only if all its components support caching. A
- * {@link PipelineComponent} is cacheable if it implements the interface {@link CachingPipelineComponent}.
+ * A {@link Pipeline} implementation that returns a cached result if, and only if all its components
+ * support caching. A {@link PipelineComponent} is cacheable if it implements the interface
+ * {@link CachingPipelineComponent}.
* </p>
*/
public class CachingPipeline extends AbstractPipeline {
@@ -47,7 +48,7 @@
protected CachingOutputStream cachingOutputStream;
- protected PipelineCache pipelineCache;
+ protected Cache cache;
/** Expires time in seconds */
private String expires;
@@ -100,7 +101,7 @@
@Override
public void execute() throws Exception {
if (this.logger.isDebugEnabled()) {
- this.logger.debug("Used cache: " + this.pipelineCache);
+ this.logger.debug("Used cache: " + this.cache);
}
this.cacheKey = this.constructCacheKey();
@@ -157,8 +158,8 @@
this.expires = expires;
}
- public void setPipelineCache(PipelineCache pipelineCache) {
- this.pipelineCache = pipelineCache;
+ public void setCache(Cache cache) {
+ this.cache = cache;
}
@Override
@@ -179,7 +180,12 @@
return null;
}
- CacheValue cacheValue = this.pipelineCache.get(cacheKey);
+ if (this.cache == null) {
+ this.logger.warn("Caching pipeline has no cache configured. Falling back to non-caching behavior.");
+ return null;
+ }
+
+ CacheValue cacheValue = this.cache.get(cacheKey, true);
if (this.logger.isDebugEnabled()) {
if (cacheValue != null) {
this.logger.debug("Retrieved content from cache: " + cacheValue);
@@ -195,11 +201,18 @@
}
protected void setCachedValue(CacheKey cacheKey, CacheValue cacheValue) {
- if (cacheKey != null) {
- if (this.logger.isDebugEnabled()) {
- this.logger.debug("Putting result into pipeline cache: " + cacheValue + ")");
- }
- this.pipelineCache.put(cacheKey, cacheValue);
+ if (cacheKey == null) {
+ return;
+ }
+
+ if (this.cache == null) {
+ this.logger.warn("Caching pipeline has no cache configured. Falling back to non-caching behavior.");
+ return;
+ }
+
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Putting result into pipeline cache: " + cacheValue + ")");
}
+ this.cache.put(cacheKey, cacheValue);
}
}
Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCache.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCache.java?rev=726527&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCache.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCache.java Sun Dec 14 12:42:48 2008
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cocoon.pipeline.caching;
+
+/**
+ * An abstract implementation of the {@link Cache} interface.<br>
+ * <br>
+ * It handles the validity check for retrieving {@link CacheValue}s but relies on child classes for actually accessing the underlying
+ * stores.
+ */
+public abstract class AbstractCache implements Cache {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.pipeline.caching.Cache#get(org.apache.cocoon.pipeline.caching.CacheKey)
+ */
+ public final CacheValue get(CacheKey cacheKey) {
+ return this.get(cacheKey, false);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.pipeline.caching.Cache#get(org.apache.cocoon.pipeline.caching.CacheKey, boolean)
+ */
+ public final CacheValue get(CacheKey cacheKey, boolean includeInvalid) {
+ CacheValue cacheValue = this.retrieve(cacheKey);
+
+ if (includeInvalid || this.isValid(cacheKey, cacheValue)) {
+ return cacheValue;
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.pipeline.caching.Cache#put(org.apache.cocoon.pipeline.caching.CacheKey,
+ * org.apache.cocoon.pipeline.caching.CacheValue)
+ */
+ public final void put(CacheKey cacheKey, CacheValue cacheValue) {
+ this.store(cacheKey, cacheValue);
+ }
+
+ /**
+ * Determines if the given <code>cacheValue</code> is valid according to the given <code>cacheKey</code>.<br>
+ * <br>
+ * This method returns <code>true</code> if and only if the given <code>cacheValue</code> is not <code>null</code> and calling
+ * {@link CacheValue#isValid(CacheKey)} with the given <code>cacheKey</code> returns <code>true</code>.
+ *
+ * @param cacheKey The {@link CacheKey} to be used for checking the <code>cacheValue</code>'s validity.
+ * @param cacheValue The {@link CacheValue} to check for validity.
+ * @return <code>true</code> if the given <code>cacheValue</code> is not <code>null</code> and valid for the given
+ * <code>cacheKey</code>.
+ */
+ protected boolean isValid(CacheKey cacheKey, CacheValue cacheValue) {
+ if (cacheValue == null) {
+ return false;
+ }
+
+ return cacheValue.isValid(cacheKey);
+ }
+
+ /**
+ * Actually retrieves the {@link CacheValue} from the underlying storage.<br>
+ * This method must return the previously stored value - even if it is not valid anymore.
+ *
+ * @param cacheKey The {@link CacheKey} to be used for retrieval.
+ * @return The previously stored {@link CacheValue} or <code>null</code> if no {@link CacheValue} is stored at the given
+ * <code>cacheKey</code>.
+ */
+ protected abstract CacheValue retrieve(CacheKey cacheKey);
+
+ /**
+ * Actually stores the given <code>cacheValue</code> at the given <code>cacheKey</code> in the underlying storage.<br>
+ * <br>
+ * This method is to replace any previously stored {@link CacheValue} (if any).
+ *
+ * @param cacheKey The {@link CacheKey} to be used for storing.
+ * @param cacheValue The {@link CacheValue} to be stored.
+ */
+ protected abstract void store(CacheKey cacheKey, CacheValue cacheValue);
+}
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCache.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCache.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCacheValue.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCacheValue.java?rev=726527&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCacheValue.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCacheValue.java Sun Dec 14 12:42:48 2008
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cocoon.pipeline.caching;
+
+public abstract class AbstractCacheValue implements CacheValue {
+
+ private static final long serialVersionUID = 1L;
+
+ private final CacheKey cacheKey;
+
+ protected AbstractCacheValue(CacheKey cacheKey) {
+ super();
+
+ this.cacheKey = cacheKey;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.pipeline.caching.CacheValue#isValid(org.apache.cocoon.pipeline.caching.CacheKey)
+ */
+ public boolean isValid(CacheKey otherCacheKey) {
+ return this.cacheKey != null && this.cacheKey.isValid(otherCacheKey);
+ }
+
+ protected CacheKey getCacheKey() {
+ return this.cacheKey;
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCacheValue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCacheValue.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/AbstractCacheValue.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/Cache.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/Cache.java?rev=726527&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/Cache.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/Cache.java Sun Dec 14 12:42:48 2008
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cocoon.pipeline.caching;
+
+public interface Cache {
+
+ /**
+ * Stores the given <code>cacheValue</code> at the given <code>cacheKey</code>.<br>
+ * <br>
+ * If this cache already contains the given <code>cacheKey</code> it will be replaced.<br>
+ * If two {@link CacheKey}s represent the same data is ultimately depending on the implementation, but usually relies on the
+ * <code>equals</code> an/or <code>hashcode</code> methods.
+ *
+ * @param cacheKey The {@link CacheKey} to be used for storing.
+ * @param cacheValue The {@link CacheValue} to be stored.
+ */
+ void put(CacheKey cacheKey, CacheValue cacheValue);
+
+ /**
+ * Retrieves the {@link CacheValue} previously stored using the given <code>cacheKey</code>.<br>
+ * If the <code>cacheKey</code> is not stored in this {@link Cache} this method will return <code>null</code>.<br>
+ * <br>
+ * Furthermore the {@link Cache} will check if the stored {@link CacheValue} is still valid (using the
+ * {@link CacheValue#isValid(CacheKey)} method). If the {@link CacheValue} is considered to be invalid this method will return
+ * <code>null</code> as well (indicating that no valid {@link CacheValue} is available).<br>
+ * <br>
+ * To retrieve CacheValues even if they are invalid, use the {@link #get(CacheKey, boolean)} method.
+ *
+ * @param cacheKey The {@link CacheKey} defining which {@link CacheValue} to retrieve.
+ * @return The previously stored {@link CacheValue} or <code>null</code> if no or no valid {@link CacheValue} is stored at the
+ * given <code>cacheValue</code>.
+ */
+ CacheValue get(CacheKey cacheKey);
+
+ /**
+ * Retrieves the {@link CacheValue} previously stored using the given <code>cacheKey</code>.<br>
+ * If the <code>cacheKey</code> is not stored in this {@link Cache} this method will return <code>null</code>.<br>
+ * <br>
+ * This method will omit the check for validity if <code>includeInvalid</code> is <code>true</code> (i.e. the returned CacheValue
+ * <b>might</b> be invalid in this case).
+ *
+ * @param cacheKey The {@link CacheKey} defining which {@link CacheValue} to retrieve.
+ * @param includeInvalid Defines whether invalid {@link CacheValue} should be returned or not. Using <code>true</code> will also
+ * return invalid {@link CacheValue}. Using <code>false</code> will yield the same results as {@link #get(CacheKey)}.
+ * @return The previously stored {@link CacheValue} or <code>null</code> if and only if no {@link CacheValue} is stored at the
+ * given <code>cacheValue</code>.
+ */
+ CacheValue get(CacheKey cacheKey, boolean includeInvalid);
+}
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/Cache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/Cache.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/Cache.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheValue.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheValue.java?rev=726527&r1=726526&r2=726527&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheValue.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CacheValue.java Sun Dec 14 12:42:48 2008
@@ -27,4 +27,6 @@
boolean isValid(CacheKey cacheKey);
void writeTo(OutputStream outputStream) throws IOException;
+
+ Object getValue();
}
Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompleteCacheValue.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompleteCacheValue.java?rev=726527&r1=726526&r2=726527&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompleteCacheValue.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/CompleteCacheValue.java Sun Dec 14 12:42:48 2008
@@ -23,26 +23,29 @@
import org.apache.cocoon.pipeline.util.StringRepresentation;
-public class CompleteCacheValue implements CacheValue {
+public class CompleteCacheValue extends AbstractCacheValue {
private static final long serialVersionUID = 1L;
private final byte[] content;
- private final CacheKey cacheKey;
public CompleteCacheValue(byte[] content, CacheKey cacheKey) {
- super();
+ super(cacheKey);
this.content = content;
- this.cacheKey = cacheKey;
}
/**
* {@inheritDoc}
*
- * @see org.apache.cocoon.pipeline.caching.CacheValue#isValid(org.apache.cocoon.pipeline.caching.CacheKey)
+ * @see org.apache.cocoon.pipeline.caching.CacheValue#getValue()
*/
- public boolean isValid(CacheKey cacheKey) {
- return this.cacheKey != null && this.cacheKey.isValid(cacheKey);
+ public Object getValue() {
+ return this.content;
+ }
+
+ @Override
+ public String toString() {
+ return StringRepresentation.buildString(this, "content.length=" + this.content.length, "cacheKey=" + this.getCacheKey());
}
/**
@@ -53,10 +56,4 @@
public void writeTo(OutputStream outputStream) throws IOException {
outputStream.write(this.content);
}
-
- @Override
- public String toString() {
- return StringRepresentation.buildString(this, "content.length=" + this.content.length, "cacheKey="
- + this.cacheKey);
- }
}
Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ObjectCacheValue.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ObjectCacheValue.java?rev=726527&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ObjectCacheValue.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ObjectCacheValue.java Sun Dec 14 12:42:48 2008
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cocoon.pipeline.caching;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * An implementation of the {@link CacheValue} interface that can hold an arbitrary value.
+ */
+public class ObjectCacheValue extends AbstractCacheValue {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Object value;
+
+ public ObjectCacheValue(Object value, CacheKey cacheKey) {
+ super(cacheKey);
+
+ this.value = value;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.pipeline.caching.CacheValue#getValue()
+ */
+ public Object getValue() {
+ return this.value;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.pipeline.caching.CacheValue#writeTo(java.io.OutputStream)
+ */
+ public void writeTo(OutputStream outputStream) throws IOException {
+ throw new UnsupportedOperationException("Cannot write the content of ObjectCacheValue to OutputStream.");
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ObjectCacheValue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ObjectCacheValue.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/ObjectCacheValue.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCache.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCache.java?rev=726527&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCache.java (added)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCache.java Sun Dec 14 12:42:48 2008
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cocoon.pipeline.caching;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cocoon.pipeline.util.StringRepresentation;
+
+/**
+ * A very simple implementation of the {@link Cache} interface.<br>
+ * <br>
+ * It uses a {@link HashMap} as internal data store.
+ */
+public class SimpleCache extends AbstractCache {
+
+ private final Map<CacheKey, CacheValue> map = new HashMap<CacheKey, CacheValue>();
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public synchronized String toString() {
+ return StringRepresentation.buildString(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.pipeline.caching.AbstractCache#retrieve(org.apache.cocoon.pipeline.caching.CacheKey)
+ */
+ @Override
+ protected synchronized CacheValue retrieve(CacheKey cacheKey) {
+ return this.map.get(cacheKey);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.pipeline.caching.AbstractCache#store(org.apache.cocoon.pipeline.caching.CacheKey,
+ * org.apache.cocoon.pipeline.caching.CacheValue)
+ */
+ @Override
+ protected synchronized void store(CacheKey cacheKey, CacheValue cacheValue) {
+ this.map.put(cacheKey, cacheValue);
+ }
+}
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCache.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/SimpleCache.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline.xml?rev=726527&r1=726526&r2=726527&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline.xml Sun Dec 14 12:42:48 2008
@@ -24,7 +24,7 @@
<bean name="org.apache.cocoon.sitemap.spring.PipelineFactory" class="org.apache.cocoon.sitemap.spring.PrototypePipelineFactory" />
<bean name="pipeline:caching" class="org.apache.cocoon.pipeline.CachingPipeline" scope="prototype">
- <property name="pipelineCache" ref="org.apache.cocoon.pipeline.caching.PipelineCache" />
+ <property name="cache" ref="org.apache.cocoon.pipeline.caching.Cache" />
</bean>
<alias name="pipeline:caching" alias="pipeline:sync-caching" />
@@ -32,10 +32,10 @@
<bean name="pipeline:async-caching" class="org.apache.cocoon.pipeline.AsyncCachePipeline" scope="prototype">
<property name="cacheRefreshManager" ref="org.apache.cocoon.pipeline.caching.CacheRefreshManager" />
- <property name="pipelineCache" ref="org.apache.cocoon.pipeline.caching.PipelineCache" />
+ <property name="cache" ref="org.apache.cocoon.pipeline.caching.Cache" />
</bean>
- <bean name="org.apache.cocoon.pipeline.caching.PipelineCache" class="org.apache.cocoon.pipeline.caching.SimplePipelineCache" />
+ <bean name="org.apache.cocoon.pipeline.caching.Cache" class="org.apache.cocoon.pipeline.caching.SimpleCache" />
<bean name="org.apache.cocoon.pipeline.caching.CacheRefreshManager"
class="org.apache.cocoon.pipeline.caching.CacheRefreshManagerImpl">