diff options
Diffstat (limited to 'velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java')
-rw-r--r-- | velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java index 58fe19b8..1e1abd7b 100644 --- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java +++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java @@ -240,14 +240,14 @@ public class Include extends InputBase try { if (!blockinput) - resource = rsvc.getContent(arg, getInputEncoding(context)); + resource = getResource(arg, getInputEncoding(context)); } catch ( ResourceNotFoundException rnfe ) { /* * the arg wasn't found. Note it and throw */ - log.error("#include(): cannot find resource '{}', called at {}", + log.error("#" + getName() + "(): cannot find resource '{}', called at {}", arg, StringUtils.formatFileString(this)); throw rnfe; } @@ -257,13 +257,13 @@ public class Include extends InputBase */ catch( RuntimeException e ) { - log.error("#include(): arg = '{}', called at {}", + log.error("#" + getName() + "(): arg = '{}', called at {}", arg, StringUtils.formatFileString(this)); throw e; } catch (Exception e) { - String msg = "#include(): arg = '" + arg + + String msg = "#" + getName() + "(): arg = '" + arg + "', called at " + StringUtils.formatFileString(this); log.error(msg, e); throw new VelocityException(msg, e, rsvc.getLogContext().getStackTrace()); @@ -304,4 +304,16 @@ public class Include extends InputBase writer.write(outputMsgEnd); } } + + /** + * Find the resource to include + * @param path resource path + * @param encoding resource encoding + * @return found resource + * @throws ResourceNotFoundException if resource was not found + */ + protected Resource getResource(String path, String encoding) throws ResourceNotFoundException + { + return rsvc.getContent(path, encoding); + } } |