org.apache.tapestry5.internal.services.assets
Class SRSCachingInterceptor

java.lang.Object
  extended by org.apache.tapestry5.internal.services.assets.SRSCachingInterceptor
All Implemented Interfaces:
StreamableResourceSource, InvalidationListener
Direct Known Subclasses:
SRSCompressedCachingInterceptor

public class SRSCachingInterceptor
extends Object
implements StreamableResourceSource, InvalidationListener

An interceptor for the StreamableResourceSource service that handles caching of content.


Constructor Summary
SRSCachingInterceptor(StreamableResourceSource delegate)
           
 
Method Summary
protected  boolean enableCache(StreamableResourceProcessing processing)
          Returns true unless the processing is StreamableResourceProcessing.FOR_AGGREGATION.
 StreamableResource getStreamableResource(Resource baseResource, StreamableResourceProcessing processing, ResourceDependencies dependencies)
          Converts a Resource (which must be non-null and exist) into a streamable resource, along with some additional optional behaviors.
protected  boolean isCacheable(StreamableResource resource)
          Always returns true; a subclass may extend this to only cache the resource in some circumstances.
 void objectWasInvalidated()
          Invoked to indicate that some object is invalid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SRSCachingInterceptor

public SRSCachingInterceptor(StreamableResourceSource delegate)
Method Detail

getStreamableResource

public StreamableResource getStreamableResource(Resource baseResource,
                                                StreamableResourceProcessing processing,
                                                ResourceDependencies dependencies)
                                         throws IOException
Description copied from interface: StreamableResourceSource
Converts a Resource (which must be non-null and exist) into a streamable resource, along with some additional optional behaviors.

Specified by:
getStreamableResource in interface StreamableResourceSource
Parameters:
baseResource - the resource to convert
processing - defines additional processing after the resource has been read and possibly transformed
dependencies - Passed to any ResourceTransformer to track additional dependencies of the base resource
Returns:
the contents of the Resource, possibly transformed, in a streamable format.
Throws:
IOException - if the resource does not exist or a URL for the content is not available

isCacheable

protected boolean isCacheable(StreamableResource resource)
Always returns true; a subclass may extend this to only cache the resource in some circumstances.

Parameters:
resource -
Returns:
true to cache the resource

objectWasInvalidated

public void objectWasInvalidated()
Description copied from interface: InvalidationListener
Invoked to indicate that some object is invalid. The receiver should clear its cache.

Specified by:
objectWasInvalidated in interface InvalidationListener

enableCache

protected boolean enableCache(StreamableResourceProcessing processing)
Returns true unless the processing is StreamableResourceProcessing.FOR_AGGREGATION. Subclasses may override. When the cache is not enabled, the request is passed on to the interceptor's delegate, and no attempt is made to read or update this interceptor's cache.

Since:
5.3.5


Copyright © 2003-2012 The Apache Software Foundation.