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

java.lang.Object
  extended byorg.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper
All Implemented Interfaces:
Poolable, Recyclable, Source

public final class DelayedRefreshSourceWrapper
extends Object
implements Source, Recyclable

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

Version:
$Id: DelayedRefreshSourceWrapper.html 1304280 2012-03-23 11:18:01Z ilgrosso $

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()
           
 String getScheme()
           
 Source getSource()
          Get the real source
 String getURI()
           
 SourceValidity getValidity()
           
 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
See Also:
Source.getInputStream()

getURI

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

getValidity

public SourceValidity getValidity()
Specified by:
getValidity in interface Source
See Also:
Source.getValidity()

getScheme

public String getScheme()
Specified by:
getScheme in interface Source
See Also:
Source.getScheme()

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.
See Also:
Source.getLastModified()

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
See Also:
Source.refresh()

getContentLength

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

getMimeType

public String getMimeType()
Specified by:
getMimeType in interface Source
See Also:
Source.getMimeType()

recycle

public final void recycle()
Specified by:
recycle in interface Recyclable
See Also:
Recyclable.recycle()


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