cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject svn commit: r797035 - in /cxf/branches/2.2.x-fixes: ./ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/ tool...
Date Thu, 23 Jul 2009 12:14:31 GMT
Author: asoldano
Date: Thu Jul 23 12:14:30 2009
New Revision: 797035

URL: http://svn.apache.org/viewvc?rev=797035&view=rev
Log:
Merged revisions 796994-796995,796997 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r796994 | asoldano | 2009-07-23 11:56:16 +0200 (gio, 23 lug 2009) | 2 lines

  [CXF-2351] Make tool containers use provided err/out streams instead of directly writing
to System.out/System.err; also making quietMode do not touch the whole VM System.out/err streams.
........
  r796995 | asoldano | 2009-07-23 11:57:25 +0200 (gio, 23 lug 2009) | 2 lines

  [CXF-2351] Allow jaxws tools output to be redirected to a given stream
........
  r796997 | asoldano | 2009-07-23 11:59:52 +0200 (gio, 23 lug 2009) | 2 lines

  [CXF-2351]
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
    cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/AbstractToolContainer.java
    cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolContainer.java
    cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolRunner.java
    cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
    cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
    cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/WSDLToIDL.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
    cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToService.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToSoap.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToXML.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/XSDToWSDL.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 23 12:14:30 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796994-796997

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java
Thu Jul 23 12:14:30 2009
@@ -88,18 +88,18 @@
 
         if (commandDocument.hasParameter("help")) {
             try {
-                System.out.println(name + " " + getUsage());
-                System.out.println();
-                System.out.println("Options: ");
-                System.out.println();
-                System.out.println(parser.getFormattedDetailedUsage());
+                out.println(name + " " + getUsage());
+                out.println();
+                out.println("Options: ");
+                out.println();
+                out.println(parser.getFormattedDetailedUsage());
                 String toolUsage = parser.getToolUsage();
                 if (toolUsage != null) {
-                    System.out.println(toolUsage);
+                    out.println(toolUsage);
                 }
             } catch (Exception ex) {
-                System.err.println("Error: Could not output detailed usage");
-                System.err.println();
+                err.println("Error: Could not output detailed usage");
+                err.println();
             }
         }
         if (commandDocument.hasParameter("version")) {
@@ -149,16 +149,16 @@
     }
 
     public void outputVersion() {
-        System.out.println(name + " - " + Version.getCompleteVersionString());
-        System.out.println();
+        out.println(name + " - " + Version.getCompleteVersionString());
+        out.println();
     }
 
     public void outputFullCommandLine() {
-        System.out.print(name);
+        out.print(name);
         for (int i = 0; i < getArgument().length; i++) {
-            System.out.print(" " + getArgument()[i]);
+            out.print(" " + getArgument()[i]);
         }
-        System.out.println();
+        out.println();
     }
     
     public String getFileBase(String wsdlUrl) {
@@ -178,12 +178,12 @@
         if (verbose) {
             outputFullCommandLine();
         }
-        System.err.println(ex.getMessage());
-        System.err.println("Usage : " + toolName + " " + ex.getUsage());
+        err.println(ex.getMessage());
+        err.println("Usage : " + toolName + " " + ex.getUsage());
         if (verbose) {
             outputVersion();
         }
-        System.err.println();
+        err.println();
     }
 
     public String getFileName(String loc) {

Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/AbstractToolContainer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/AbstractToolContainer.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/AbstractToolContainer.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/AbstractToolContainer.java
Thu Jul 23 12:14:30 2009
@@ -46,6 +46,8 @@
 
     protected ToolSpec toolspec;
     protected ToolContext context;
+    protected PrintStream out = System.out;
+    protected PrintStream err = System.err;
     
     private String arguments[];
     private boolean isVerbose;
@@ -54,9 +56,6 @@
     private CommandLineParser parser;
     private OutputStream outOutputStream;
     private OutputStream errOutputStream;
-
-    private PrintStream stdOutputStream;
-    private PrintStream stdErrorStream;
  
     public class GenericOutputStream extends OutputStream {
         public void write(int b) throws IOException {
@@ -126,15 +125,10 @@
     }
 
     public void redirectOutput() {
-        stdOutputStream = System.out;
-        stdErrorStream = System.err;
-
         outOutputStream = new GenericOutputStream();
         errOutputStream = new GenericOutputStream();
-        System.setErr(new PrintStream(errOutputStream));
-        System.setOut(new PrintStream(outOutputStream));
     }
-
+    
     public boolean isQuietMode() {
         return isQuiet;
     }
@@ -150,11 +144,23 @@
     public OutputStream getOutOutputStream() {
         return outOutputStream;
     }
+    
+    public void setOutOutputStream(OutputStream outOutputStream) {
+        this.outOutputStream = outOutputStream;
+        this.out = (outOutputStream instanceof PrintStream)
+            ? (PrintStream)outOutputStream : new PrintStream(outOutputStream);
+    }
 
     public OutputStream getErrOutputStream() {
         return errOutputStream;
     }
     
+    public void setErrOutputStream(OutputStream errOutputStream) {
+        this.errOutputStream = errOutputStream;
+        this.err = (errOutputStream instanceof PrintStream)
+            ? (PrintStream)errOutputStream : new PrintStream(errOutputStream);
+    }
+    
     public void setContext(ToolContext c) {
         context = c;
     }
@@ -176,10 +182,7 @@
     }
 
     public void tearDown() {
-        if (isQuietMode()) {
-            System.setOut(stdOutputStream);
-            System.setErr(stdErrorStream);
-        }
+        //nothing to do
     }
     
     public Bus getBus() {
@@ -192,7 +195,7 @@
             try {
                 catalogManager.loadCatalog(new URI(catalogLocation).toURL());
             } catch (Exception e) {
-                e.printStackTrace();
+                e.printStackTrace(err);
                 throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG, catalogLocation));
             }
         }

Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolContainer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolContainer.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolContainer.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolContainer.java
Thu Jul 23 12:14:30 2009
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.tools.common.toolspec;
 
+import java.io.OutputStream;
+
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
 
@@ -26,4 +28,6 @@
     void execute(boolean exitOnFinish) throws ToolException;
     void setContext(ToolContext context);    
     void setArguments(String[] args);
+    void setOutOutputStream(OutputStream outOutputStream);
+    void setErrOutputStream(OutputStream errOutputStream);
 }

Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolRunner.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolRunner.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolRunner.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/ToolRunner.java
Thu Jul 23 12:14:30 2009
@@ -20,6 +20,7 @@
 package org.apache.cxf.tools.common.toolspec;
 
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.lang.reflect.Constructor;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -38,10 +39,15 @@
                                boolean validate, String[] args) throws Exception {
         runTool(clz, toolspecStream, validate, args, true);
     }
+    
+    public static void runTool(Class<? extends ToolContainer> clz, InputStream toolspecStream,
+                               boolean validate, String[] args, OutputStream os) throws Exception
{
+        runTool(clz, toolspecStream, validate, args, true, null, os);
+    }
 
     public static void runTool(Class<? extends ToolContainer> clz, InputStream toolspecStream,
                                boolean validate, String[] args, ToolContext context) throws
Exception {
-        runTool(clz, toolspecStream, validate, args, true, context);
+        runTool(clz, toolspecStream, validate, args, true, context, null);
     }
 
     public static void runTool(Class<? extends ToolContainer> clz,
@@ -49,7 +55,7 @@
                                boolean validate,
                                String[] args,
                                boolean exitOnFinish) throws Exception {
-        runTool(clz, toolspecStream, validate, args, true, null);
+        runTool(clz, toolspecStream, validate, args, true, null, null);
     }
     
     public static void runTool(Class<? extends ToolContainer> clz,
@@ -58,6 +64,16 @@
                                String[] args,
                                boolean exitOnFinish,
                                ToolContext context) throws Exception {
+        runTool(clz, toolspecStream, validate, args, exitOnFinish, context, null);
+    }
+    
+    public static void runTool(Class<? extends ToolContainer> clz,
+                               InputStream toolspecStream,
+                               boolean validate,
+                               String[] args,
+                               boolean exitOnFinish,
+                               ToolContext context,
+                               OutputStream os) throws Exception {
 
         ToolContainer container = null;
 
@@ -79,6 +95,10 @@
 
         try {
             container.setArguments(args);
+            if (os != null) {
+                container.setErrOutputStream(os);
+                container.setOutOutputStream(os);
+            }
             container.setContext(context);
             container.execute(exitOnFinish);
         } catch (Exception ex) {

Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
Thu Jul 23 12:14:30 2009
@@ -21,12 +21,13 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
@@ -182,7 +183,9 @@
                                     new StreamSource(Tool.class
                                         .getResourceAsStream("indent-no-xml-declaration.xsl")));
 
-                serializer.transform(new DOMSource(resultDoc), new StreamResult(new PrintStream(System.out)));
+                OutputStream os = new ByteArrayOutputStream();
+                serializer.transform(new DOMSource(resultDoc), new StreamResult(os));
+                LOG.fine(os.toString());
             } catch (Exception ex) {
                 LOG.log(Level.SEVERE, "ERROR_SERIALIZE_COMMAND_MSG", ex);
             }

Modified: cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
Thu Jul 23 12:14:30 2009
@@ -73,20 +73,20 @@
                 idlProcessor.process();
             }
         } catch (ToolException ex) {
-            System.err.println("Error : " + ex.getMessage());
+            err.println("Error : " + ex.getMessage());
             if (ex.getCause() instanceof BadUsageException) {
                 printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
             }
-            System.err.println();
+            err.println();
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
             throw ex;
         } catch (Exception ex) {
-            System.err.println("Error : " + ex.getMessage());
-            System.err.println();
+            err.println("Error : " + ex.getMessage());
+            err.println();
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
             throw new ToolException(ex.getMessage(), ex.getCause());
         }

Modified: cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/WSDLToIDL.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/WSDLToIDL.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/WSDLToIDL.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/WSDLToIDL.java
Thu Jul 23 12:14:30 2009
@@ -84,20 +84,20 @@
                 corbaProcessor.process();
             }
         } catch (ToolException ex) {
-            System.err.println("Error : " + ex.getMessage());
+            err.println("Error : " + ex.getMessage());
             if (ex.getCause() instanceof BadUsageException) {
                 printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
             }
-            System.err.println();
+            err.println();
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
             throw ex;
         } catch (Exception ex) {
-            System.err.println("Error : " + ex.getMessage());
-            System.err.println();
+            err.println("Error : " + ex.getMessage());
+            err.println();
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
             throw new ToolException(ex.getMessage(), ex.getCause());
         }

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java
Thu Jul 23 12:14:30 2009
@@ -67,16 +67,16 @@
             if (ex.getCause() instanceof BadUsageException) {
                 printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
             }
-            System.err.println();
-            System.err.println("JavaToJS Error : " + ex.getMessage());
+            err.println();
+            err.println("JavaToJS Error : " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         } catch (Exception ex) {
-            System.err.println();
-            System.err.println("JavaToJS Error : " + ex.getMessage());
+            err.println();
+            err.println("JavaToJS Error : " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         } finally {
             tearDown();

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
Thu Jul 23 12:14:30 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.tools.java2ws;
 
+import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.List;
 
@@ -76,6 +77,12 @@
         ToolRunner.runTool(JavaToWSContainer.class, JavaToWSContainer.class
                            .getResourceAsStream("java2ws.xml"), false, args);      
     }
+    
+    public void run(OutputStream os) throws Exception {
+        ToolRunner.runTool(JavaToWSContainer.class, JavaToWSContainer.class
+                           .getResourceAsStream("java2ws.xml"), false, args, os);      
+    }
+    
 
     private boolean isExitOnFinish() {
         String exit = System.getProperty("exitOnFinish");

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
Thu Jul 23 12:14:30 2009
@@ -78,15 +78,15 @@
             if (ex.getCause() instanceof BadUsageException) {
                 printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
                 if (isVerboseOn()) {
-                    ex.printStackTrace();
+                    ex.printStackTrace(err);
                 }
             }
             throw ex;
         } catch (Exception ex) {
-            System.err.println("Error: " + ex.getMessage());
-            System.err.println();
+            err.println("Error: " + ex.getMessage());
+            err.println();
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
 
             throw new ToolException(ex.getMessage(), ex.getCause());

Modified: cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
Thu Jul 23 12:14:30 2009
@@ -83,23 +83,23 @@
                 }
             }
         } catch (ToolException ex) {
-            System.err.println("WSDLValidator Error : " + ex.getMessage());
+            err.println("WSDLValidator Error : " + ex.getMessage());
             if (ex.getCause() instanceof BadUsageException) {
                 printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
             }
-            System.err.println();
+            err.println();
             if (isVerboseOn()) {
-                System.err.println("[+] Verbose turned on");
-                System.err.println();                
-                ex.printStackTrace();
+                err.println("[+] Verbose turned on");
+                err.println();                
+                ex.printStackTrace(err);
             }
         } catch (Exception ex) {
-            System.err.println("WSDLValidator Error : " + ex.getMessage());
-            System.err.println();
+            err.println("WSDLValidator Error : " + ex.getMessage());
+            err.println();
             if (isVerboseOn()) {
-                System.err.println("[+] Verbose turned on");
-                System.err.println();
-                ex.printStackTrace();
+                err.println("[+] Verbose turned on");
+                err.println();
+                ex.printStackTrace(err);
             }
         }
     }

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJava.java
Thu Jul 23 12:14:30 2009
@@ -20,6 +20,8 @@
 package org.apache.cxf.tools.wsdlto;
 
 import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.List;
 
@@ -41,6 +43,7 @@
     public static final String DEFAULT_DATABINDING_NAME = "jaxb";
 
     private String[] args;
+    private PrintStream out = System.out;
 
     private PluginLoader pluginLoader = PluginLoader.getInstance();
 
@@ -56,7 +59,7 @@
             name = DEFAULT_FRONTEND_NAME;
         }
         if (isVerbose()) {
-            System.out.println("Loading FrontEnd " + name + " ...");
+            out.println("Loading FrontEnd " + name + " ...");
         }
         return pluginLoader.getFrontEndProfile(name);
     }
@@ -66,7 +69,7 @@
             name = DEFAULT_DATABINDING_NAME;
         }
         if (isVerbose()) {
-            System.out.println("Loading DataBinding " + name + " ...");
+            out.println("Loading DataBinding " + name + " ...");
         }
         return pluginLoader.getDataBindingProfile(name);
     }
@@ -78,8 +81,15 @@
         }
         return "YES".equalsIgnoreCase(exit) || "TRUE".equalsIgnoreCase(exit);
     }
-
+    
     public void run(ToolContext context) throws Exception {
+        run(context, null);
+    }
+
+    public void run(ToolContext context, OutputStream os) throws Exception {
+        if (os != null) {
+            this.out = (os instanceof PrintStream) ? (PrintStream)os : new PrintStream(os);
+        }
         FrontEndProfile frontend = null;
         if (args != null) {
             context.put(ToolConstants.CFG_CMD_ARG, args);
@@ -105,7 +115,8 @@
                            false,
                            args,
                            isExitOnFinish(),
-                           context);
+                           context,
+                           os);
     }
 
     protected boolean isVerbose() {

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToService.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToService.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToService.java
Thu Jul 23 12:14:30 2009
@@ -71,16 +71,16 @@
             if (ex.getCause() instanceof BadUsageException) {
                 printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
             }
-            System.err.println();
-            System.err.println("WSDLToService Error : " + ex.getMessage());
+            err.println();
+            err.println("WSDLToService Error : " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         } catch (Exception ex) {
-            System.err.println();
-            System.err.println("WSDLToService Error : " + ex.getMessage());
+            err.println();
+            err.println("WSDLToService Error : " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         } finally {
             tearDown();

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToSoap.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToSoap.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToSoap.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToSoap.java
Thu Jul 23 12:14:30 2009
@@ -73,16 +73,16 @@
             if (ex.getCause() instanceof BadUsageException) {
                 printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
             }
-            System.err.println();
-            System.err.println("WSDLToSoap Error : " + ex.getMessage());
+            err.println();
+            err.println("WSDLToSoap Error : " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         } catch (Exception ex) {
-            System.err.println();
-            System.err.println("WSDLToSoap Error : " + ex.getMessage());
+            err.println();
+            err.println("WSDLToSoap Error : " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         } finally {
             tearDown();

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToXML.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToXML.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToXML.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/WSDLToXML.java
Thu Jul 23 12:14:30 2009
@@ -73,16 +73,16 @@
             if (ex.getCause() instanceof BadUsageException) {
                 printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
             }
-            System.err.println();
-            System.err.println("WSDLToXML Error: " + ex.getMessage());
+            err.println();
+            err.println("WSDLToXML Error: " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         } catch (Exception ex) {
-            System.err.println();
-            System.err.println("WSDLToXML Error: " + ex.getMessage());
+            err.println();
+            err.println("WSDLToXML Error: " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         } finally {
             tearDown();

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/XSDToWSDL.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/XSDToWSDL.java?rev=797035&r1=797034&r2=797035&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/XSDToWSDL.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/XSDToWSDL.java
Thu Jul 23 12:14:30 2009
@@ -68,16 +68,16 @@
             if (ex.getCause() instanceof BadUsageException) {
                 printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
             }
-            System.err.println();
-            System.err.println("XSDToWSDL Error: " + ex.getMessage());
+            err.println();
+            err.println("XSDToWSDL Error: " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         } catch (Exception ex) {
-            System.err.println();
-            System.err.println("XSDToWSDL Error: " + ex.getMessage());
+            err.println();
+            err.println("XSDToWSDL Error: " + ex.getMessage());
             if (isVerboseOn()) {
-                ex.printStackTrace();
+                ex.printStackTrace(err);
             }
         }
     }



Mime
View raw message