geirm 01/05/15 06:26:33
Modified: src/java/org/apache/velocity/runtime/resource
ResourceManager.java
Log:
Didn't seem to go the first time :)
ResourceManager : prevented a NPE and added log msg when the 'class' is
not set for a resource loader
Revision Changes Path
1.28 +23 -1
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.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- ResourceManager.java 2001/05/11 04:00:29 1.27
+++ ResourceManager.java 2001/05/15 13:26:26 1.28
@@ -81,7 +81,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Paulo Gaspar</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: ResourceManager.java,v 1.27 2001/05/11 04:00:29 geirm Exp $
+ * @version $Id: ResourceManager.java,v 1.28 2001/05/15 13:26:26 geirm Exp $
*/
public class ResourceManager
{
@@ -96,6 +96,11 @@
public static final int RESOURCE_CONTENT = 2;
/**
+ * token used to identify the loader internally
+ */
+ private static final String RESOURCE_LOADER_IDENTIFIER =
"_RESOURCE_LOADER_IDENTIFIER_";
+
+ /**
* Hashtable used to store templates that have been
* processed. Our simple caching mechanism.
*/
@@ -153,6 +158,15 @@
ExtendedProperties configuration = (ExtendedProperties)
sourceInitializerList.get(i);
String loaderClass = configuration.getString("class");
+ if ( loaderClass == null)
+ {
+ Runtime.error( "Unable to find '"
+ +
configuration.getString(RESOURCE_LOADER_IDENTIFIER)
+ + ".resource.loader.class' specification in
configuation."
+ + " This is a critical value. Please adjust
configuration.");
+ continue;
+ }
+
resourceLoader = ResourceLoaderFactory.getLoader(loaderClass);
resourceLoader.commonInit(configuration);
resourceLoader.init(configuration);
@@ -193,6 +207,14 @@
ExtendedProperties loaderConfiguration =
Runtime.getConfiguration().subset(loaderID);
+
+ /*
+ * add the loader name token to the initializer if we need it
+ * for reference later. We can't count on the user to fill
+ * in the 'name' field
+ */
+
+ loaderConfiguration.setProperty( RESOURCE_LOADER_IDENTIFIER,
resourceLoaderNames.get(i));
/*
* Add resources to the list of resource loader