geirm 01/08/07 14:57:56
Modified: src/java/org/apache/velocity/runtime/directive
Directive.java Foreach.java Include.java
Literal.java Macro.java Parse.java VMProxyArg.java
VelocimacroProxy.java
Log:
Support for separable instances of the runtime engine.
Revision Changes Path
1.15 +11 -5
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Directive.java
Index: Directive.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Directive.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Directive.java 2001/03/20 01:11:21 1.14
+++ Directive.java 2001/08/07 21:57:56 1.15
@@ -57,6 +57,8 @@
import java.io.Writer;
import java.io.IOException;
+import org.apache.velocity.runtime.RuntimeServices;
+
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.runtime.parser.node.Node;
@@ -67,13 +69,15 @@
* Base class for all directives used in Velocity.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Directive.java,v 1.14 2001/03/20 01:11:21 jon Exp $
+ * @version $Id: Directive.java,v 1.15 2001/08/07 21:57:56 geirm Exp $
*/
public abstract class Directive implements DirectiveConstants,Cloneable
{
private int line = 0;
private int column = 0;
+ protected RuntimeServices rsvc = null;
+
/** Return the name of this directive */
public abstract String getName();
@@ -102,13 +106,15 @@
/**
* How this directive is to be initialized.
*/
- public void init( InternalContextAdapter context, Node node)
+ public void init( RuntimeServices rs, InternalContextAdapter context, Node node)
throws Exception
{
- int i, k = node.jjtGetNumChildren();
+ rsvc = rs;
+
+ // int i, k = node.jjtGetNumChildren();
- for (i = 0; i < k; i++)
- node.jjtGetChild(i).init(context, null);
+ //for (i = 0; i < k; i++)
+ // node.jjtGetChild(i).init(context, rs);
}
/**
1.37 +21 -17
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java
Index: Foreach.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- Foreach.java 2001/04/08 21:14:21 1.36
+++ Foreach.java 2001/08/07 21:57:56 1.37
@@ -65,8 +65,10 @@
import java.util.Map;
import java.util.Vector;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeConstants;
+
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.runtime.Runtime;
import org.apache.velocity.util.ArrayIterator;
import org.apache.velocity.util.EnumerationIterator;
@@ -85,7 +87,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Foreach.java,v 1.36 2001/04/08 21:14:21 geirm Exp $
+ * @version $Id: Foreach.java,v 1.37 2001/08/07 21:57:56 geirm Exp $
*/
public class Foreach extends Directive
{
@@ -142,14 +144,12 @@
* the counter value into the context. Right
* now the default is $velocityCount.
*/
- private final static String COUNTER_NAME =
- Runtime.getString(Runtime.COUNTER_NAME);
-
+ private String counterName;
+
/**
* What value to start the loop counter at.
*/
- private final static int COUNTER_INITIAL_VALUE =
- Runtime.getInt(Runtime.COUNTER_INITIAL_VALUE);
+ private int counterInitialValue;
/**
* The reference name used to access each
@@ -163,15 +163,19 @@
*/
private String elementKey;
+
/**
* simple init - init the tree and get the elementKey from
* the AST
*/
- public void init( InternalContextAdapter context, Node node)
+ public void init( RuntimeServices rs, InternalContextAdapter context, Node
node)
throws Exception
{
- super.init( context, node );
+ super.init( rs, context, node );
+ counterName = rsvc.getString(RuntimeConstants.COUNTER_NAME);
+ counterInitialValue = rsvc.getInt(RuntimeConstants.COUNTER_INITIAL_VALUE);
+
/*
* this is really the only thing we can do here as everything
* else is context sensitive
@@ -263,7 +267,7 @@
return ( (Collection) listObject).iterator();
case INFO_ITERATOR :
- Runtime.warn ("Warning! The reference "
+ rsvc.warn ("Warning! The reference "
+ node.jjtGetChild(2).getFirstToken().image
+ " is an Iterator in the #foreach() loop at ["
+ getLine() + "," + getColumn() + "]"
@@ -275,7 +279,7 @@
return ( (Iterator) listObject);
case INFO_ENUMERATION :
- Runtime.warn ("Warning! The reference "
+ rsvc.warn ("Warning! The reference "
+ node.jjtGetChild(2).getFirstToken().image
+ " is an Enumeration in the #foreach() loop at ["
+ getLine() + "," + getColumn() + "]"
@@ -294,7 +298,7 @@
default:
/* we have no clue what this is */
- Runtime.warn ("Could not determine type of iterator in "
+ rsvc.warn ("Could not determine type of iterator in "
+ "#foreach loop for "
+ node.jjtGetChild(2).getFirstToken().image
+ " at [" + getLine() + "," + getColumn() + "]"
@@ -320,7 +324,7 @@
if ( i == null )
return false;
- int counter = COUNTER_INITIAL_VALUE;
+ int counter = counterInitialValue;
/*
* save the element key if there is one,
@@ -328,11 +332,11 @@
*/
Object o = context.get( elementKey );
- Object ctr = context.get( COUNTER_NAME );
+ Object ctr = context.get( counterName);
while (i.hasNext())
{
- context.put(COUNTER_NAME, new Integer(counter));
+ context.put( counterName , new Integer(counter));
context.put(elementKey,i.next());
node.jjtGetChild(3).render(context, writer);
counter++;
@@ -345,11 +349,11 @@
if( ctr != null)
{
- context.put( COUNTER_NAME, ctr );
+ context.put( counterName, ctr );
}
else
{
- context.remove(COUNTER_NAME);
+ context.remove( counterName );
}
1.21 +25 -11
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java
Index: Include.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Include.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Include.java 2001/04/28 18:58:40 1.20
+++ Include.java 2001/08/07 21:57:56 1.21
@@ -58,7 +58,8 @@
import java.io.IOException;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.resource.Resource;
@@ -99,7 +100,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Kasper Nielsen</a>
- * @version $Id: Include.java,v 1.20 2001/04/28 18:58:40 geirm Exp $
+ * @version $Id: Include.java,v 1.21 2001/08/07 21:57:56 geirm Exp $
*/
public class Include extends Directive
{
@@ -126,19 +127,19 @@
* simple init - init the tree and get the elementKey from
* the AST
*/
- public void init( InternalContextAdapter context, Node node)
+ public void init( RuntimeServices rs, InternalContextAdapter context, Node
node)
throws Exception
{
- super.init( context, node );
+ super.init( rs, context, node );
/*
* get the msg, and add the space so we don't have to
* do it each time
*/
- outputMsgStart = Runtime.getString(Runtime.ERRORMSG_START);
+ outputMsgStart = rsvc.getString(RuntimeConstants.ERRORMSG_START);
outputMsgStart = outputMsgStart + " ";
- outputMsgEnd = Runtime.getString(Runtime.ERRORMSG_END );
+ outputMsgEnd = rsvc.getString(RuntimeConstants.ERRORMSG_END );
outputMsgEnd = " " + outputMsgEnd;
}
@@ -174,7 +175,7 @@
}
else
{
- Runtime.error("#include() error : invalid argument type : "
+ rsvc.error("#include() error : invalid argument type : "
+ n.toString());
outputErrorToStream( writer, "error with arg " + i
+ " please see log.");
@@ -200,7 +201,7 @@
if ( node == null )
{
- Runtime.error("#include() error : null argument");
+ rsvc.error("#include() error : null argument");
return false;
}
@@ -210,7 +211,7 @@
Object value = node.value( context );
if ( value == null)
{
- Runtime.error("#include() error : null argument");
+ rsvc.error("#include() error : null argument");
return false;
}
@@ -227,12 +228,25 @@
{
/*
* get the resource, and assume that we use the encoding of the
current template
+ * the 'current resource' can be null if we are processing a stream....
*/
- resource = Runtime.getContent(arg, current.getEncoding());
+
+ String encoding = null;
+
+ if ( current != null)
+ {
+ encoding = current.getEncoding();
+ }
+ else
+ {
+ encoding = (String) rsvc.getProperty(
RuntimeConstants.INPUT_ENCODING);
+ }
+
+ resource = rsvc.getContent(arg, encoding);
}
catch (Exception e)
{
- Runtime.error("#include : cannot find " + arg + " template!");
+ rsvc.error("#include : cannot find " + arg + " template");
}
if ( resource == null )
1.5 +6 -3
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Literal.java
Index: Literal.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Literal.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Literal.java 2001/03/20 01:11:24 1.4
+++ Literal.java 2001/08/07 21:57:56 1.5
@@ -57,9 +57,10 @@
import java.io.*;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.runtime.Runtime;
import org.apache.velocity.runtime.parser.node.Node;
+import org.apache.velocity.runtime.RuntimeServices;
+
/**
* A very simple directive that leverages the Node.literal()
* to grab the literal rendition of a node. We basically
@@ -67,7 +68,7 @@
* that during render().
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: Literal.java,v 1.4 2001/03/20 01:11:24 jon Exp $
+ * @version $Id: Literal.java,v 1.5 2001/08/07 21:57:56 geirm Exp $
*/
public class Literal extends Directive
{
@@ -93,9 +94,11 @@
* Store the literal rendition of a node using
* the Node.literal().
*/
- public void init( InternalContextAdapter context, Node node)
+ public void init( RuntimeServices rs, InternalContextAdapter context, Node node)
throws Exception
{
+ super.init( rs, context, node );
+
literalText = node.jjtGetChild(0).literal();
}
1.13 +10 -9
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Macro.java
Index: Macro.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Macro.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Macro.java 2001/03/20 01:11:24 1.12
+++ Macro.java 2001/08/07 21:57:56 1.13
@@ -62,8 +62,7 @@
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.SimpleNode;
import org.apache.velocity.runtime.parser.Token;
-import org.apache.velocity.runtime.Runtime;
-import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.RuntimeServices;
/**
* Macro.java
@@ -82,7 +81,7 @@
* macro. It is used inline in the parser when processing a directive.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Macro.java,v 1.12 2001/03/20 01:11:24 jon Exp $
+ * @version $Id: Macro.java,v 1.13 2001/08/07 21:57:56 geirm Exp $
*/
public class Macro extends Directive
{
@@ -119,9 +118,11 @@
return true;
}
- public void init( InternalContextAdapter context, Node node)
+ public void init( RuntimeServices rs, InternalContextAdapter context, Node
node)
throws Exception
{
+ super.init( rs, context, node );
+
/*
* again, don't do squat. We want the AST of the macro
* block to hang off of this but we don't want to
@@ -139,7 +140,7 @@
* VelocimacroProxy objects, and if not currently used, adds it
* to the macro Factory
*/
- public void processAndRegister( Node node, String sourceTemplate )
+ public static void processAndRegister( RuntimeServices rs, Node node, String
sourceTemplate )
throws IOException
{
/*
@@ -163,7 +164,7 @@
* define a block
*/
- Runtime.error("#macro error : Velocimacro must have name as 1st " +
+ rs.error("#macro error : Velocimacro must have name as 1st " +
"argument to #macro()");
return;
@@ -198,7 +199,7 @@
* so just give it a whack...
*/
- boolean bRet = Runtime.addVelocimacro( argArray[0], macroBody,
+ boolean bRet = rs.addVelocimacro( argArray[0], macroBody,
argArray, sourceTemplate );
return;
@@ -209,7 +210,7 @@
* creates an array containing the literal
* strings in the macro arguement
*/
- private String[] getArgArray( Node node )
+ private static String[] getArgArray( Node node )
{
/*
* remember : this includes the block tree
@@ -263,7 +264,7 @@
/**
* Returns an array of the literal rep of the AST
*/
- private String [] getASTAsStringArray( Node rootNode )
+ private static String [] getASTAsStringArray( Node rootNode )
{
/*
* this assumes that we are passed in the root
1.21 +12 -11
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Parse.java
Index: Parse.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Parse.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Parse.java 2001/07/23 02:31:09 1.20
+++ Parse.java 2001/08/07 21:57:56 1.21
@@ -60,7 +60,7 @@
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.Template;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.SimpleNode;
@@ -87,7 +87,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Christoph Reck</a>
- * @version $Id: Parse.java,v 1.20 2001/07/23 02:31:09 geirm Exp $
+ * @version $Id: Parse.java,v 1.21 2001/08/07 21:57:56 geirm Exp $
*/
public class Parse extends Directive
{
@@ -123,7 +123,7 @@
*/
if ( node.jjtGetChild(0) == null)
{
- Runtime.error( "#parse() error : null argument" );
+ rsvc.error( "#parse() error : null argument" );
return false;
}
@@ -134,7 +134,7 @@
if ( value == null)
{
- Runtime.error( "#parse() error : null argument" );
+ rsvc.error( "#parse() error : null argument" );
return false;
}
@@ -151,7 +151,7 @@
Object[] templateStack = context.getTemplateNameStack();
if ( templateStack.length >=
- Runtime.getInt(Runtime.PARSE_DIRECTIVE_MAXDEPTH, 20) )
+ rsvc.getInt(RuntimeConstants.PARSE_DIRECTIVE_MAXDEPTH, 20) )
{
StringBuffer path = new StringBuffer();
@@ -160,12 +160,12 @@
path.append( " > " + templateStack[i] );
}
- Runtime.error( "Max recursion depth reached (" +
+ rsvc.error( "Max recursion depth reached (" +
templateStack.length + ")" + " File stack:" + path );
return false;
}
- Resource current = context.getCurrentResource();
+ Resource current = context.getCurrentResource();
/*
* get the resource, and assume that we use the encoding of the current
template
@@ -180,21 +180,22 @@
}
else
{
- encoding = (String) Runtime.getProperty( Runtime.INPUT_ENCODING);
+ encoding = (String) rsvc.getProperty( RuntimeConstants.INPUT_ENCODING);
}
/*
* now use the Runtime resource loader to get the template
*/
+
Template t = null;
try
{
- t = Runtime.getTemplate( arg, encoding );
+ t = rsvc.getTemplate( arg, encoding );
}
catch ( Exception e)
{
- Runtime.error("#parse : cannot find " + arg + " template!");
+ rsvc.error("#parse : cannot find " + arg + " template!");
return false;
}
@@ -217,7 +218,7 @@
throw (MethodInvocationException) e;
}
- Runtime.error( "Exception rendering #parse( " + arg + " ) : " + e );
+ rsvc.error( "Exception rendering #parse( " + arg + " ) : " + e );
return false;
}
finally
1.9 +18 -14
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VMProxyArg.java
Index: VMProxyArg.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VMProxyArg.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- VMProxyArg.java 2001/06/19 03:33:30 1.8
+++ VMProxyArg.java 2001/08/07 21:57:56 1.9
@@ -61,7 +61,7 @@
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.ASTReference;
import org.apache.velocity.runtime.parser.Token;
@@ -113,7 +113,7 @@
* into a local context.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: VMProxyArg.java,v 1.8 2001/06/19 03:33:30 geirm Exp $
+ * @version $Id: VMProxyArg.java,v 1.9 2001/08/07 21:57:56 geirm Exp $
*/
public class VMProxyArg
{
@@ -147,6 +147,8 @@
/** in the event our type is switched - we don't care really what it is */
private final int GENERALSTATIC = -1;
+ private RuntimeServices rsvc = null;
+
/**
* ctor for current impl
*
@@ -157,8 +159,10 @@
* @param callerRef reference used by the caller as an arg to the VM
* @param t type of arg : JJTREFERENCE, JJTTRUE, etc
*/
- public VMProxyArg( String contextRef, String callerRef, int t )
+ public VMProxyArg( RuntimeServices rs, String contextRef, String callerRef, int
t )
{
+ rsvc = rs;
+
contextReference = contextRef;
callerReference = callerRef;
type = t;
@@ -226,7 +230,7 @@
}
catch( MethodInvocationException mie )
{
- Runtime.error("VMProxyArg.getObject() : method invocation error
setting value : " + mie );
+ rsvc.error("VMProxyArg.getObject() : method invocation error
setting value : " + mie );
}
}
else
@@ -253,7 +257,7 @@
type = GENERALSTATIC;
staticObject = o;
- Runtime.error("VMProxyArg.setObject() : Programmer error : I am a
constant! No setting! : "
+ rsvc.error("VMProxyArg.setObject() : Programmer error : I am a
constant! No setting! : "
+ contextReference + " / " + callerReference);
}
@@ -343,7 +347,7 @@
}
catch (Exception e )
{
- Runtime.error("VMProxyArg.getObject() : error rendering
reference : " + e );
+ rsvc.error("VMProxyArg.getObject() : error rendering reference
: " + e );
}
}
else if( type == GENERALSTATIC )
@@ -352,7 +356,7 @@
}
else
{
- Runtime.error("Unsupported VM arg type : VM arg = " +
callerReference +" type = " + type + "( VMProxyArg.getObject() )");
+ rsvc.error("Unsupported VM arg type : VM arg = " + callerReference
+" type = " + type + "( VMProxyArg.getObject() )");
}
return retObject;
@@ -366,7 +370,7 @@
* I can think of
*/
- Runtime.error("VMProxyArg.getObject() : method invocation error getting
value : " + mie );
+ rsvc.error("VMProxyArg.getObject() : method invocation error getting
value : " + mie );
return null;
}
@@ -408,7 +412,7 @@
BufferedReader br = new BufferedReader( new StringReader( buff
) );
- nodeTree = Runtime.parse( br, "VMProxyArg:" + callerReference );
+ nodeTree = rsvc.parse( br, "VMProxyArg:" + callerReference );
/*
* now, our tree really is the first DirectiveArg(), and only
one
@@ -422,18 +426,18 @@
if ( nodeTree != null && nodeTree.getType() != type )
{
- Runtime.error( "VMProxyArg.setup() : programmer error :
type doesn't match node type.");
+ rsvc.error( "VMProxyArg.setup() : programmer error : type
doesn't match node type.");
}
/*
* init. We can do this as they are only references
*/
- nodeTree.init(null, null);
+ nodeTree.init(null, rsvc);
}
catch ( Exception e )
{
- Runtime.error("VMProxyArg.setup() : exception " +
callerReference +
+ rsvc.error("VMProxyArg.setup() : exception " + callerReference
+
" : " + StringUtils.stackTrace(e));
}
@@ -467,7 +471,7 @@
* this is technically an error...
*/
- Runtime.error("Unsupported arg type : " + callerReference
+ rsvc.error("Unsupported arg type : " + callerReference
+ " You most likely intended to call a VM with a
string literal, so enclose with ' or \" characters. (VMProxyArg.setup())");
constant = true;
staticObject = new String( callerReference );
@@ -477,7 +481,7 @@
default :
{
- Runtime.error(" VMProxyArg.setup() : unsupported type : "
+ rsvc.error(" VMProxyArg.setup() : unsupported type : "
+ callerReference );
}
}
1.25 +13 -11
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
Index: VelocimacroProxy.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- VelocimacroProxy.java 2001/07/03 19:29:09 1.24
+++ VelocimacroProxy.java 2001/08/07 21:57:56 1.25
@@ -70,7 +70,7 @@
import org.apache.velocity.context.Context;
import org.apache.velocity.runtime.visitor.VMReferenceMungeVisitor;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
@@ -85,7 +85,7 @@
* a proxy Directive-derived object to fit with the current directive system
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: VelocimacroProxy.java,v 1.24 2001/07/03 19:29:09 geirm Exp $
+ * @version $Id: VelocimacroProxy.java,v 1.25 2001/08/07 21:57:56 geirm Exp $
*/
public class VelocimacroProxy extends Directive
{
@@ -187,7 +187,7 @@
{
if ( !init )
{
- nodeTree.init(context,null);
+ nodeTree.init( context, rsvc);
init = true;
}
@@ -195,7 +195,7 @@
* wrap the current context and add the VMProxyArg objects
*/
- VMContext vmc = new VMContext( context );
+ VMContext vmc = new VMContext( context, rsvc );
for( int i = 1; i < argArray.length; i++)
{
@@ -216,7 +216,7 @@
}
else
{
- Runtime.error( "VM error : " + macroName + ". Null AST");
+ rsvc.error( "VM error : " + macroName + ". Null AST");
}
}
catch ( Exception e )
@@ -230,7 +230,7 @@
throw (MethodInvocationException) e;
}
- Runtime.error("VelocimacroProxy.render() : exception VM = #" +
macroName +
+ rsvc.error("VelocimacroProxy.render() : exception VM = #" + macroName +
"() : " + StringUtils.stackTrace(e));
}
@@ -242,9 +242,11 @@
* macro body, renders the macro into an AST, and then inits the AST, so it
is ready
* for quick rendering. Note that this is only AST dependant stuff. Not
context.
*/
- public void init( InternalContextAdapter context, Node node)
+ public void init( RuntimeServices rs, InternalContextAdapter context, Node
node)
throws Exception
{
+ super.init( rs, context, node );
+
/*
* how many args did we get?
*/
@@ -257,7 +259,7 @@
if ( getNumArgs() != i )
{
- Runtime.error("VM #" + macroName + ": error : too few arguments to
macro. Wanted "
+ rsvc.error("VM #" + macroName + ": error : too few arguments to macro.
Wanted "
+ getNumArgs() + " got " + i + " -->");
return;
}
@@ -302,7 +304,7 @@
* now parse the macro - and don't dump the namespace
*/
- nodeTree = Runtime.parse( br, namespace, false );
+ nodeTree = rsvc.parse( br, namespace, false );
/*
* now, to make null references render as proper schmoo
@@ -341,7 +343,7 @@
}
catch ( Exception e )
{
- Runtime.error("VelocimacroManager.parseTree() : exception " + macroName
+
+ rsvc.error("VelocimacroManager.parseTree() : exception " + macroName +
" : " + StringUtils.stackTrace(e));
}
}
@@ -354,7 +356,7 @@
for( int i = 1; i < argArray.length; i++)
{
- VMProxyArg arg = new VMProxyArg( argArray[i], callArgs[i-1],
callArgTypes[i-1] );
+ VMProxyArg arg = new VMProxyArg( rsvc, argArray[i], callArgs[i-1],
callArgTypes[i-1] );
proxyArgHash.put( argArray[i], arg );
}
}