this patch adds a "throws java.lang.Exception" to the
populateInitialContext and initControlContext methods in TexenTask.
these methods are likely candidates for overriding when subclassing
TexenTask. At the moment, no exceptions can be thrown by subclasses
(which is unsatisfactory). Throwing java.lang.Exception seems the right
thing to do since these methods are called from execute (which must
catch and process all exceptions) and also throwing java.lang.Exception
seems to be common in texen.
this patch also contains additional documentation and adds a catch for
BuildException for execute()
- robert
Index: src/java/org/apache/velocity/texen/ant/TexenTask.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/texen/ant/TexenTask.java,v
retrieving revision 1.23
diff -u -r1.23 TexenTask.java
--- src/java/org/apache/velocity/texen/ant/TexenTask.java 2001/05/01 12:54:59
1.23
+++ src/java/org/apache/velocity/texen/ant/TexenTask.java 2001/05/06 21:40:41
@@ -269,8 +269,13 @@
{
return contextProperties;
}
-
- public Context initControlContext()
+
+ /**
+ * Creates a VelocityContext.
+ *
+ * @throws Exception the execute method will catch and rethrow as a
+<code>BuildException</code>
+ */
+ public Context initControlContext() throws Exception
{
return new VelocityContext();
}
@@ -447,6 +452,10 @@
writer.close();
generator.shutdown();
}
+ catch( BuildException e)
+ {
+ throw e;
+ }
catch( MethodInvocationException e )
{
throw new BuildException(
@@ -468,11 +477,19 @@
}
/**
- * Place some useful object in the initial context.
- *
+ * <p>
+ * Place useful objects into the initial context.
+ * </p><p>
+ * TexenTask places <code>Date().toString()</code> into the context as
+<code>$now</code>.
+ * Subclasses who want to vary the objects in the context should override this
+method.
+ * </p><p>
+ * <code>$generator</code> is not put into the context in this method.
+ * </p>
* @param Context initial context
+ *
+ * @throws Exception the execute method will catch and rethrow as a
+<code>BuildException</code>
*/
- protected void populateInitialContext(Context context)
+ protected void populateInitialContext(Context context) throws Exception
{
/*
* Place the current date in the context. Hmm,