The Spring Framework

org.springframework.scripting.support
Class ResourceScriptSource

java.lang.Object
  extended by org.springframework.scripting.support.ResourceScriptSource
All Implemented Interfaces:
ScriptSource

public class ResourceScriptSource
extends Object
implements ScriptSource

ScriptSource implementation based on Spring's Resource abstraction. Loads the script text from the underlying Resource's InputStream and tracks the file timestamp of the Resource (if possible).

Since:
2.0
Author:
Rob Harrop, Juergen Hoeller
See Also:
InputStreamSource.getInputStream(), Resource.getFile(), ResourceLoader

Field Summary
protected  Log logger
          Logger available to subclasses
 
Constructor Summary
ResourceScriptSource(Resource resource)
          Create a new ResourceScriptSource for the given resource.
 
Method Summary
 Resource getResource()
          Return the Resource to load the script from.
 String getScriptAsString()
          Retrieve the current script source text as String.
 boolean isModified()
          Indicate whether the underlying script data was modified since the last time getScriptAsString() was called.
protected  long retrieveLastModifiedTime()
          Retrieve the current last-modified timestamp of the underlying timestamp.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses

Constructor Detail

ResourceScriptSource

public ResourceScriptSource(Resource resource)
Create a new ResourceScriptSource for the given resource.

Parameters:
resource - the Resource to load the script from
Throws:
IllegalArgumentException - if the supplied Resource is null
Method Detail

getResource

public final Resource getResource()
Return the Resource to load the script from.


getScriptAsString

public String getScriptAsString()
                         throws IOException
Description copied from interface: ScriptSource
Retrieve the current script source text as String.

Specified by:
getScriptAsString in interface ScriptSource
Throws:
IOException - if script retrieval failed

isModified

public boolean isModified()
Description copied from interface: ScriptSource
Indicate whether the underlying script data was modified since the last time getScriptAsString() was called. Returns true if the script has not been read yet.

Specified by:
isModified in interface ScriptSource
See Also:
ScriptSource.getScriptAsString()

retrieveLastModifiedTime

protected long retrieveLastModifiedTime()
Retrieve the current last-modified timestamp of the underlying timestamp.

Returns:
the current timestamp, or 0 if not determinable

toString

public String toString()
Overrides:
toString in class Object

The Spring Framework

Copyright © 2002-2006 The Spring Framework.