aboutsummaryrefslogtreecommitdiff
path: root/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java
diff options
context:
space:
mode:
authorClaude Brisson <claude@renegat.net>2022-07-25 08:59:12 +0200
committerClaude Brisson <claude@renegat.net>2022-07-25 08:59:12 +0200
commit28c97b43c731ea42f87bcbdbd08d08fd08533a58 (patch)
treec6e7a8284bd3f51ca5c3f5dec92ab6969a8caa02 /velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java
parent051f20a8b7b76ecd9f773ac83aac138867aa0976 (diff)
downloadapache-velocity-engine-28c97b43c731ea42f87bcbdbd08d08fd08533a58.tar.gz
Easier #include and #parse directives subclassing - fixes VELOCITY-959
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.java20
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);
+ }
}