geirm 01/10/22 04:47:06
Modified: src/java/org/apache/velocity/runtime VelocimacroManager.java
Log:
This should fix the problem where useing local-scope VMs interferes with
VM library reloading. It's here rather than Factory as i think it dodges
neatly any concurrency questions. Any information about what is a library is
set at init() time, and we just preserve that for later adds.
Revision Changes Path
1.15 +33 -4
jakarta-velocity/src/java/org/apache/velocity/runtime/VelocimacroManager.java
Index: VelocimacroManager.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/VelocimacroManager.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- VelocimacroManager.java 2001/10/11 17:38:21 1.14
+++ VelocimacroManager.java 2001/10/22 11:47:06 1.15
@@ -82,7 +82,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jose Alberto Fernandez</a>
- * @version $Id: VelocimacroManager.java,v 1.14 2001/10/11 17:38:21 dlr Exp $
+ * @version $Id: VelocimacroManager.java,v 1.15 2001/10/22 11:47:06 geirm Exp $
*/
public class VelocimacroManager
{
@@ -93,7 +93,10 @@
/** Hash of namespace hashes. */
private Hashtable namespaceHash = new Hashtable();
-
+
+ /** map of names of library tempates/namespaces */
+ private Hashtable libraryMap = new Hashtable();
+
/*
* big switch for namespaces. If true, then properties control
* usage. If false, no.
@@ -127,9 +130,35 @@
me.setFromLibrary(registerFromLib);
- if ( usingNamespaces( namespace ) )
+ /*
+ * the client (VMFactory) will signal to us via
+ * registerFromLib that we are in startup mode registering
+ * new VMs from libraries. Therefore, we want to
+ * addto the library map for subsequent auto reloads
+ */
+
+ boolean isLib = true;
+
+ if ( registerFromLib)
{
+ libraryMap.put( namespace, namespace );
+ }
+ else
+ {
/*
+ * now, we first want to check to see if this namespace (template)
+ * is actually a library - if so, we need to use the global namespace
+ * we don't have to do this when registering, as namespaces should
+ * be shut off. If not, the default value is true, so we still go
+ * global
+ */
+
+ isLib = libraryMap.containsKey( namespace);
+ }
+
+ if ( !isLib && usingNamespaces( namespace ) )
+ {
+ /*
* first, do we have a namespace hash already for this namespace?
* if not, add it to the namespaces, and add the VM
*/
@@ -140,7 +169,7 @@
return true;
}
else
- {
+ {
/*
* otherwise, add to global template. First, check if we
* already have it to preserve some of the autoload information