com.openharbor.beck.map
Class PollableResource

java.lang.Object
  extended bycom.openharbor.beck.map.PollableResource
All Implemented Interfaces:
PollableInput

public class PollableResource
extends java.lang.Object
implements PollableInput

A resource with a relatively efficient method to check whether it has changed. This class is not thread-safe.


Field Summary
protected  java.lang.ClassLoader loader
           
protected  org.apache.commons.logging.Log log
           
protected  java.lang.String resourceName
           
 
Fields inherited from interface com.openharbor.beck.map.PollableInput
SECONDS
 
Constructor Summary
PollableResource(java.lang.ClassLoader loader, java.lang.String name)
           
 
Method Summary
protected  java.net.URL getResource()
           
 java.lang.String getSystemID()
          The SystemID that identifies the input source, or null if its SystemID is unknown.
 java.io.InputStream input()
          Begin reading the data (as a stream of bytes).
 java.io.InputStream inputIfModified()
          Begin reading the data (as a stream of bytes) if it has changed since the last call to input() or inputIfModified().
protected  PollableURL newPollableURL(java.net.URL url)
           
 void pollSoon()
          Check for a change in the data next time inputIfModified is called, regardless of the currently acceptable staleness.
 void setAcceptableStaleness(long msec)
          Set the maximum amount of time that may elapse from a change in the data until the change is detected by this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log

loader

protected java.lang.ClassLoader loader

resourceName

protected java.lang.String resourceName
Constructor Detail

PollableResource

public PollableResource(java.lang.ClassLoader loader,
                        java.lang.String name)
Method Detail

setAcceptableStaleness

public void setAcceptableStaleness(long msec)
Description copied from interface: PollableInput
Set the maximum amount of time that may elapse from a change in the data until the change is detected by this object.

Specified by:
setAcceptableStaleness in interface PollableInput
Parameters:
msec - the acceptable staleness, in units of milliseconds.

getSystemID

public java.lang.String getSystemID()
Description copied from interface: PollableInput
The SystemID that identifies the input source, or null if its SystemID is unknown.

Specified by:
getSystemID in interface PollableInput

input

public java.io.InputStream input()
                          throws java.io.IOException
Description copied from interface: PollableInput
Begin reading the data (as a stream of bytes).

Specified by:
input in interface PollableInput
Throws:
java.io.IOException

inputIfModified

public java.io.InputStream inputIfModified()
                                    throws java.io.IOException
Description copied from interface: PollableInput
Begin reading the data (as a stream of bytes) if it has changed since the last call to input() or inputIfModified().

Specified by:
inputIfModified in interface PollableInput
Returns:
a stream that will produce the data, or null to indicate that the data have not changed.
Throws:
java.io.IOException

pollSoon

public void pollSoon()
Description copied from interface: PollableInput
Check for a change in the data next time inputIfModified is called, regardless of the currently acceptable staleness.

Specified by:
pollSoon in interface PollableInput

getResource

protected java.net.URL getResource()
                            throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

newPollableURL

protected PollableURL newPollableURL(java.net.URL url)