|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2005 the original author or authors. |
3 |
| - * |
| 2 | + * Copyright 2002-2010 the original author or authors. |
| 3 | + * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
6 | 6 | * You may obtain a copy of the License at
|
7 |
| - * |
| 7 | + * |
8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 |
| - * |
| 9 | + * |
10 | 10 | * Unless required by applicable law or agreed to in writing, software
|
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32 | 32 | * Used by FreeMarkerConfigurationFactory for any resource loader path that
|
33 | 33 | * cannot be resolved to a java.io.File.
|
34 | 34 | *
|
35 |
| - * <p>Note that this loader does not allow for modification detection: |
36 |
| - * Use FreeMarker's default TemplateLoader for java.io.File resources. |
37 |
| - * |
38 | 35 | * @author Juergen Hoeller
|
39 | 36 | * @since 14.03.2004
|
40 | 37 | * @see FreeMarkerConfigurationFactory#setTemplateLoaderPath
|
@@ -89,7 +86,17 @@ public Reader getReader(Object templateSource, String encoding) throws IOExcepti
|
89 | 86 |
|
90 | 87 |
|
91 | 88 | public long getLastModified(Object templateSource) {
|
92 |
| - return -1; |
| 89 | + Resource resource = (Resource) templateSource; |
| 90 | + try { |
| 91 | + return resource.lastModified(); |
| 92 | + } |
| 93 | + catch (IOException ex) { |
| 94 | + if (logger.isDebugEnabled()) { |
| 95 | + logger.debug("Could not obtain last-modified timestamp for FreeMarker template in " + |
| 96 | + resource + ": " + ex); |
| 97 | + } |
| 98 | + return -1; |
| 99 | + } |
93 | 100 | }
|
94 | 101 |
|
95 | 102 | public void closeTemplateSource(Object templateSource) throws IOException {
|
|
0 commit comments