|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.components.source.impl.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.
1) Synchronously. This means that the cached contents are checked for validity and thrown out on the current thread.
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 |
default-expires (int) | Default expiration value for if it is not specified on the Source itself. | opt | String | -1 |
Field Summary | |
static String |
ASYNC_PARAM
|
protected Cache |
cache
The cache |
static String |
CACHE_ROLE_PARAM
|
static String |
DEFAULT_EXPIRES_PARAM
|
static String |
FAILSAFE_PARAM
|
protected ServiceManager |
manager
The ServiceManager |
protected Refresher |
refresher
The refresher |
static String |
REFRESHER_ROLE_PARAM
|
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)
|
void |
dispose()
|
Source |
getSource(String location,
Map parameters)
Get a Source object. |
static CachingSource |
newCachingSource(Source wrappedSource,
String scheme,
String uri,
int expires,
String cacheName,
boolean async,
Cache cache,
Logger logger,
ServiceManager manager)
Factory method for creating a new CachingSource. |
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 |
public static final String ASYNC_PARAM
public static final String FAILSAFE_PARAM
public static final String CACHE_ROLE_PARAM
public static final String REFRESHER_ROLE_PARAM
public static final String DEFAULT_EXPIRES_PARAM
protected ServiceManager manager
ServiceManager
protected SourceResolver resolver
SourceResolver
protected Refresher 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
public Source getSource(String location, Map parameters) throws MalformedURLException, IOException
Source
object.
getSource
in interface SourceFactory
parameters
- This is optional.
MalformedURLException
IOException
public static CachingSource newCachingSource(Source wrappedSource, String scheme, String uri, int expires, String cacheName, boolean async, Cache cache, Logger logger, ServiceManager manager) 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 |