jstrachan 2002/10/02 06:56:23
Modified: jelly/src/java/org/apache/commons/jelly Jelly.java
Log:
Minor patch so that output flushing works better when using JellySwing by running
the Jelly main() class.
Revision Changes Path
1.16 +22 -28
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java
Index: Jelly.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Jelly.java 2 Oct 2002 11:03:38 -0000 1.15
+++ Jelly.java 2 Oct 2002 13:56:23 -0000 1.16
@@ -104,39 +104,38 @@
public Jelly() {
}
+
public static void main(String[] args) throws Exception {
- try
- {
+ try {
if (args.length <= 0) {
System.out.println("Usage: Jelly scriptFile [outputFile]");
return;
}
-
+
Jelly jelly = new Jelly();
jelly.setScript(args[0]);
-
+
// later we might wanna add some command line arguments
// checking stuff using commons-cli to specify the output file
// and input file via command line arguments
- final Writer writer = ( args.length > 1 )
- ? new FileWriter( args[1] )
- : new OutputStreamWriter( System.out );
-
+ final XMLOutput output =
+ (args.length > 1)
+ ? XMLOutput.createXMLOutput(new FileWriter(args[1]))
+ : XMLOutput.createXMLOutput(System.out);
+
Script script = jelly.compileScript();
- XMLOutput output = XMLOutput.createXMLOutput(writer);
-
+
// add the system properties and the command line arguments
JellyContext context = jelly.getJellyContext();
context.setVariable("args", args);
script.run(context, output);
-
+
// now lets wait for all threads to close
- Runtime.getRuntime().addShutdownHook(
- new Thread() {
+ Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
- writer.close();
+ output.close();
}
catch (Exception e) {
// ignore errors
@@ -145,22 +144,17 @@
}
);
}
- catch (JellyException e)
- {
+ catch (JellyException e) {
Throwable cause = e.getCause();
- if ( cause != null )
- {
+ if (cause != null) {
cause.printStackTrace();
}
- else
- {
+ else {
e.printStackTrace();
}
}
- }
-
-
+ }
/**
* Compiles the script
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>