jvanzyl 01/03/03 16:51:29
Modified: src/java/org/apache/velocity/runtime/resource/loader
FileResourceLoader.java
Log:
- keep track of the path that a template was found on so that
we can use it check the modification time of a file based
template.
Revision Changes Path
1.6 +17 -4
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
Index: FileResourceLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FileResourceLoader.java 2001/03/04 00:37:43 1.5
+++ FileResourceLoader.java 2001/03/04 00:51:29 1.6
@@ -77,7 +77,7 @@
* That'll change once we decide how we want to do configuration
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*/
public class FileResourceLoader extends ResourceLoader
{
@@ -85,7 +85,14 @@
* The paths to search for templates.
*/
private Vector paths = null;
-
+
+ /**
+ * Used to map the path that a template was found on
+ * so that we can properly check the modification
+ * times of the files.
+ */
+ private Hashtable templatePaths = new Hashtable();
+
public void init(Configuration configuration)
{
paths = configuration.getVector("resource.path");
@@ -149,6 +156,12 @@
if (inputStream != null)
{
+ /*
+ * Store the path that this template came
+ * from so that we can check its modification
+ * time.
+ */
+ templatePaths.put(templateName, path);
return inputStream;
}
}
@@ -204,7 +217,7 @@
*/
public boolean isSourceModified(Resource resource)
{
- String path = "";
+ String path = (String) templatePaths.get(resource.getName());
File file = new File( path, resource.getName() );
if ( file.canRead() )
@@ -232,7 +245,7 @@
public long getLastModified(Resource resource)
{
- String path = "";
+ String path = (String) templatePaths.get(resource.getName());
File file = new File(path, resource.getName());
if (file.canRead())