aboutsummaryrefslogtreecommitdiff
path: root/velocity-engine-core/src
diff options
context:
space:
mode:
authorClaude Brisson <cbrisson@apache.org>2016-09-12 12:31:32 +0000
committerClaude Brisson <cbrisson@apache.org>2016-09-12 12:31:32 +0000
commit855ea3008e00ec5fe75033f3b9a555af0de6d36a (patch)
tree140004ed69aa921c34a8cd530ad07d58d17d7fcc /velocity-engine-core/src
parent62aba90e8f18c9f9683c37b8195cae030f9d0bfd (diff)
downloadapache-velocity-engine-855ea3008e00ec5fe75033f3b9a555af0de6d36a.tar.gz
add a resource.manager.instance property
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1760348 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'velocity-engine-core/src')
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java11
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java21
2 files changed, 28 insertions, 4 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
index 3c2b1c46..050cb258 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
@@ -115,7 +115,16 @@ public interface RuntimeConstants
* ----------------------------------------------------------------------
*/
- /** */
+ /**
+ * The <code>resource.manager.instance</code> property specifies an existing instance of a
+ * {@link org.apache.velocity.runtime.resource.ResourceManager} implementation to use
+ */
+ String RESOURCE_MANAGER_INSTANCE = "resource.manager.instance";
+
+ /**
+ * The <code>resource.manager.class</code> property specifies the name of the
+ * {@link org.apache.velocity.runtime.resource.ResourceManager} implementation to use.
+ */
String RESOURCE_MANAGER_CLASS = "resource.manager.class";
/**
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
index 09a986f7..f2c3fb29 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
@@ -752,9 +752,24 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
/*
* Which resource manager?
*/
+ Object inst = getProperty(RuntimeConstants.RESOURCE_MANAGER_INSTANCE);
String rm = getString(RuntimeConstants.RESOURCE_MANAGER_CLASS);
- if (rm != null && rm.length() > 0)
+ if (inst != null)
+ {
+ if (ResourceManager.class.isAssignableFrom(inst.getClass()))
+ {
+ resourceManager = (ResourceManager)inst;
+ resourceManager.initialize(this);
+ }
+ else
+ {
+ String msg = inst.getClass().getName() + " object set as resource.manager.instance is not a valid org.apache.velocity.runtime.resource.ResourceManager.";
+ log.error(msg);
+ throw new VelocityException(msg);
+ }
+ }
+ else if (rm != null && rm.length() > 0)
{
/*
* if something was specified, then make one.
@@ -795,8 +810,8 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
}
resourceManager = (ResourceManager) o;
-
resourceManager.initialize(this);
+ setProperty(RESOURCE_MANAGER_INSTANCE, resourceManager);
}
else
{
@@ -804,7 +819,7 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
* someone screwed up. Lets not fool around...
*/
- String err = "It appears that no class was specified as the"
+ String err = "It appears that no class or instance was specified as the"
+ " ResourceManager. Please ensure that all configuration"
+ " information is correct.";