|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.components.source.impl.CachingSourceFactory
public class CachingSourceFactory
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:
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 CachingSource
or TraversableCachingSource
depending on the whether the wrapped Source is an instance of TraversableSource.
cache-role (String) | Role of component used as cache. | opt | String |
|
---|---|---|---|---|
refresher-role (String) | Role of component used for refreshing sources. | opt | String |
|
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 |
Field Summary | |
---|---|
protected Cache |
cache
The cache |
protected ServiceManager |
manager
The ServiceManager |
protected SourceRefresher |
refresher
The refresher |
protected SourceResolver |
resolver
The SourceResolver |
Fields inherited from interface org.apache.excalibur.source.SourceFactory |
---|
ROLE |
Constructor Summary | |
---|---|
CachingSourceFactory()
|
Method Summary | |
---|---|
String |
absolutize(String baseURI,
String location)
|
void |
configure(Configuration configuration)
|
protected CachingSource |
createCachingSource(String uri,
String wrappedUri,
Source wrappedSource,
int expires,
String cacheName)
Actually creates a new CachingSource. |
void |
dispose()
|
protected String |
getScheme()
|
Source |
getSource(String location,
Map parameters)
Get a Source object. |
protected boolean |
isAsync()
|
void |
release(Source source)
Release a Source object. |
void |
service(ServiceManager manager)
|
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ServiceManager manager
ServiceManager
protected SourceResolver resolver
SourceResolver
protected SourceRefresher refresher
protected Cache cache
Constructor Detail |
---|
public CachingSourceFactory()
Method Detail |
---|
public void service(ServiceManager manager)
service
in interface Serviceable
public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
public void dispose()
dispose
in interface Disposable
protected String getScheme()
protected boolean isAsync()
public Source getSource(String location, Map parameters) throws MalformedURLException, IOException
Source
object.
getSource
in interface SourceFactory
parameters
- This is optional.
MalformedURLException
IOException
protected CachingSource createCachingSource(String uri, String wrappedUri, Source wrappedSource, int expires, String cacheName) throws SourceException
SourceException
public void release(Source source)
Source
object.
release
in interface SourceFactory
public String absolutize(String baseURI, String location)
absolutize
in interface URIAbsolutizer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |