jvanzyl 00/12/19 08:16:44
Modified: src/java/org/apache/velocity/runtime/resource
ResourceManager.java
Log:
- Have to keep track of whether the resource loader initializers
are active. Typically the initializers are not set up until
just before the resource loaders are initialized, but they
have to be set up for calls to setSourceProperty(k,v) so
I added a check to make sure the loader initializers are
active before trying to set loader initializer property :-)
Revision Changes Path
1.3 +12 -4
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java
Index: ResourceManager.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ResourceManager.java 2000/12/19 15:37:17 1.2
+++ ResourceManager.java 2000/12/19 16:16:43 1.3
@@ -71,7 +71,7 @@
* Runtime.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: ResourceManager.java,v 1.2 2000/12/19 15:37:17 jvanzyl Exp $
+ * @version $Id: ResourceManager.java,v 1.3 2000/12/19 16:16:43 jvanzyl Exp $
*/
public class ResourceManager
{
@@ -108,6 +108,8 @@
*/
private static Hashtable sourceInitializerMap = new Hashtable();
+ private static boolean resourceLoaderInitializersActive = false;
+
/**
* Initialize the ResourceManager. It is assumed
* that assembleSourceInitializers() has been
@@ -117,7 +119,7 @@
{
ResourceLoader resourceLoader;
- assembleSourceInitializers();
+ assembleResourceLoaderInitializers();
for (int i = 0; i < sourceInitializerList.size(); i++)
{
@@ -132,12 +134,15 @@
/**
* This will produce a List of Hashtables, each
* hashtable contains the intialization info for
- * a particular template loader. This Hastable
+ * a particular resource loader. This Hastable
* will be passed in when initializing the
* the template loader.
*/
- private static void assembleSourceInitializers()
+ private static void assembleResourceLoaderInitializers()
{
+ if (resourceLoaderInitializersActive)
+ return;
+
for (int i = 0; i < 10; i++)
{
String loaderID = "resource.loader." + new Integer(i).toString();
@@ -282,6 +287,9 @@
*/
public static void setSourceProperty(String key, String value)
{
+ if (resourceLoaderInitializersActive == false)
+ assembleResourceLoaderInitializers();
+
String publicName = key.substring(0, key.indexOf("."));
String property = key.substring(key.indexOf(".") + 1);
((Map)sourceInitializerMap.get(publicName.toLowerCase())).put(property,
value);