org.apache.cocoon.components.source.impl
Class DelayedRefreshSourceWrapper

java.lang.Object
  extended by org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper
All Implemented Interfaces:
Source

public final class DelayedRefreshSourceWrapper
extends Object
implements Source

A wrapper around a Source that reduces the number of calls to Source.getLastModified() which can be a costly operation.

Version:
CVS $Id: DelayedRefreshSourceWrapper.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Sylvain Wallez

Constructor Summary
DelayedRefreshSourceWrapper(Source source, long delay)
          Creates a wrapper for a Source which ensures that Source.getLastModified() won't be called more than once per delay milliseconds period.
 
Method Summary
 boolean exists()
           
 long getContentLength()
           
 InputStream getInputStream()
           
 long getLastModified()
          Get the last modification time for the wrapped Source.
 String getMimeType()
          The mime-type of the content described by this object.
 String getParameter(String name)
          Get the value of a parameter.
 long getParameterAsLong(String name)
          Get the value of a parameter.
 Iterator getParameterNames()
          Get parameter names Using this it is possible to get custom information provided by the source implementation, like an expires date, HTTP headers etc.
 String getScheme()
          Return the protocol identifier.
 Source getSource()
          Get the real source
 String getURI()
           
 SourceValidity getValidity()
          Get the Validity object.
 void recycle()
           
 void refresh()
          Force the refresh of the wrapped Source, even if the refresh period isn't over, and starts a new period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelayedRefreshSourceWrapper

public DelayedRefreshSourceWrapper(Source source,
                                   long delay)
Creates a wrapper for a Source which ensures that Source.getLastModified() won't be called more than once per delay milliseconds period.

Parameters:
source - the wrapped Source
delay - the last-modified refresh delay, in milliseconds
Method Detail

getSource

public Source getSource()
Get the real source


getInputStream

public final InputStream getInputStream()
                                 throws SourceException,
                                        IOException
Specified by:
getInputStream in interface Source
Throws:
SourceException
IOException

getURI

public final String getURI()
Specified by:
getURI in interface Source

getValidity

public SourceValidity getValidity()
Get the Validity object. This can either wrap the last modification date or the expires information or... If it is currently not possible to calculate such an information null is returned.

Specified by:
getValidity in interface Source

getScheme

public String getScheme()
Return the protocol identifier.

Specified by:
getScheme in interface Source

exists

public boolean exists()
Specified by:
exists in interface Source
See Also:
Source.exists()

getLastModified

public final long getLastModified()
Get the last modification time for the wrapped Source. The age of the returned information is guaranteed to be lower than or equal to the delay specified in the constructor.

This method is also thread-safe, even if the underlying Source is not.

Specified by:
getLastModified in interface Source
Returns:
the last modification time.

refresh

public final void refresh()
Force the refresh of the wrapped Source, even if the refresh period isn't over, and starts a new period.

This method is thread-safe, even if the underlying Source is not.

Specified by:
refresh in interface Source

getContentLength

public final long getContentLength()
Specified by:
getContentLength in interface Source

getMimeType

public String getMimeType()
The mime-type of the content described by this object. If the source is not able to determine the mime-type by itself this can be null.

Specified by:
getMimeType in interface Source

recycle

public final void recycle()

getParameter

public String getParameter(String name)
Get the value of a parameter. Using this it is possible to get custom information provided by the source implementation, like an expires date, HTTP headers etc.


getParameterAsLong

public long getParameterAsLong(String name)
Get the value of a parameter. Using this it is possible to get custom information provided by the source implementation, like an expires date, HTTP headers etc.


getParameterNames

public Iterator getParameterNames()
Get parameter names Using this it is possible to get custom information provided by the source implementation, like an expires date, HTTP headers etc.



Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.