| org.apache.cocoon.components.source.impl.CachingSourceFactory
CachingSourceFactory | public class CachingSourceFactory extends AbstractLogEnabled implements Serviceable,Configurable,Disposable,ThreadSafe,URIAbsolutizer,SourceFactory(Code) | | This class implements a proxy like source caches the contents of the source
it wraps. This implementation can cache the content either for a given period
of time or until an external event invalidates the cached response.
When using the timeout approach you have a choice between two separate
revalidation strategies:
- Synchronously. This means that the cached contents are checked for validity
and thrown out on the current thread.
- Asynchronously. A runnable task is created to invalidate and update the
cached response in the backgound.
Protocol syntax
The URL needs to contain the URL of the cached source, an expiration
period in seconds, and optionally a cache key:
cached:http://www.apache.org/[?cocoon:cache-expires=60][&cocoon:cache-name=main] .
The above examples shows how the real source http://www.apache.org/
is wrapped and the cached contents is used for 60 seconds.
The second querystring parameter instructs that the cache key be extended with the string
main . This allows the use of multiple cache entries for the same source.
This factory creates either instances of
org.apache.cocoon.components.source.impl.CachingSource or
org.apache.cocoon.components.source.impl.TraversableCachingSource depending on the whether the wrapped Source is an instance of TraversableSource.
Parameters
cache-role (String) |
Role of component used as cache. |
opt |
String |
Cache.ROLE |
refresher-role (String) |
Role of component used for refreshing sources. |
opt |
String |
org.apache.cocoon.components.source.helpers.SourceRefresher.ROLE |
async (boolean) |
Indicated if the cached source should be refreshed asynchronously. |
opt |
String |
false |
event-aware (boolean) |
Whether to use event-based cache invalidation. |
opt |
String |
false |
default-expires (int) |
Default expiration value for if it is not specified on the Source itself. |
opt |
String |
-1 |
version: $Id: CachingSourceFactory.java 485495 2006-12-11 04:44:23Z crossley $ since: 2.1.1 |
manager | protected ServiceManager manager(Code) | | The ServiceManager
|
resolver | protected SourceResolver resolver(Code) | | The
SourceResolver
|
CachingSourceFactory | public CachingSourceFactory()(Code) | | |
configure | public void configure(Configuration configuration) throws ConfigurationException(Code) | | |
createCachingSource | protected CachingSource createCachingSource(String uri, String wrappedUri, Source wrappedSource, int expires, String cacheName) throws SourceException(Code) | | Actually creates a new CachingSource. Can be overriden in subclasses
|
dispose | public void dispose()(Code) | | |
isAsync | protected boolean isAsync()(Code) | | |
release | public void release(Source source)(Code) | | Release a
Source object.
|
service | public void service(ServiceManager manager)(Code) | | |
|
|