cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r447283 - in /incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor: WSDLToJavaProcessor.java compiler/Compiler.java
Date Mon, 18 Sep 2006 06:37:34 GMT
Author: ema
Date: Sun Sep 17 23:37:33 2006
New Revision: 447283

URL: http://svn.apache.org/viewvc?view=rev&rev=447283
Log:
Fixed tools compile a large number of files issue.  

Modified:
    incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java
    incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/compiler/Compiler.java

Modified: incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java?view=diff&rev=447283&r1=447282&r2=447283
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java
(original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/WSDLToJavaProcessor.java
Sun Sep 17 23:37:33 2006
@@ -291,13 +291,17 @@
 
         String[] arguments = new String[argList.size() + fileList.size() + 1];
         arguments[0] = "javac";
+        
         int i = 1;
+        
         for (Object obj : argList.toArray()) {
             String arg = (String)obj;
             arguments[i] = arg;
             i++;
         }
-
+        
+        int srcFileIndex = i; 
+        
         for (Object o : fileList.toArray()) {
             String file = (String)o;
             arguments[i] = file;
@@ -306,7 +310,7 @@
 
         Compiler compiler = new Compiler();
 
-        if (!compiler.internalCompile(arguments)) {
+        if (!compiler.internalCompile(arguments, srcFileIndex)) {
             Message msg = new Message("FAIL_TO_COMPILE_GENERATE_CODES", LOG);
             throw new ToolException(msg);
         }

Modified: incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/compiler/Compiler.java?view=diff&rev=447283&r1=447282&r2=447283
==============================================================================
--- incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/compiler/Compiler.java
(original)
+++ incubator/cxf/trunk/tools/wsdl2java/src/main/java/org/apache/cxf/tools/wsdl2java/processor/compiler/Compiler.java
Sun Sep 17 23:37:33 2006
@@ -20,35 +20,59 @@
 package org.apache.cxf.tools.wsdl2java.processor.compiler;
 
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
+import java.io.PrintWriter;
 
 public class Compiler {
-    public boolean internalCompile(String[] args) {
-
+    public boolean internalCompile(String[] args, int sourceFileIndex) {
         Process p = null;
+        String cmdArray[] = null;
+      
         try {
-
-            for (int i = 0; i < args.length; i++) {
-                if (!"/".equals(File.separator) && args[i].indexOf("package-info")
== -1) {
-                    args[i] = args[i].replace(File.separatorChar, '/');
-                }              
+            if (isLongCommandLines(args) && sourceFileIndex >= 0) {
+                PrintWriter out = null;
+                File tmpFile = File.createTempFile("cxf-compiler", null);
+                tmpFile.deleteOnExit();
+                out = new PrintWriter(new FileWriter(tmpFile));
+                for (int i = sourceFileIndex; i < args.length; i++) {
+                    if (args[i].indexOf(" ") > -1) {
+                        args[i] = args[i].replace(File.separatorChar, '/');
+                        out.println("\"" + args[i] + "\"");
+                    } else {
+                        out.println(args[i]);
+                    }
+                }
+                out.flush();
+                cmdArray = new String[sourceFileIndex + 1];
+                System.arraycopy(args, 0, cmdArray, 0, sourceFileIndex);
+                cmdArray[sourceFileIndex] = "@" + tmpFile;
+            } else {
+                /*//Sun's jdk bug on windows xp and windows 2000. It will be fixed in mustung

+                //get windows
+                if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1)
{
+                    for (int i = 0; i < args.length; i++) {
+                        if (!"/".equals(File.separator) && args[i].indexOf("package-info")
== -1) {
+                            args[i] = args[i].replace(File.separatorChar, '/');
+                        }
+                    }
+                }
+               */
+                cmdArray = new String[args.length];
+                System.arraycopy(args, 0, cmdArray, 0, args.length);
             }
+            
+            p = Runtime.getRuntime().exec(cmdArray);
 
-            p = Runtime.getRuntime().exec(args);
-                  
             if (p.getErrorStream() != null) {
-                StreamPrinter errorStreamPrinter = 
-                    new StreamPrinter(p.getErrorStream(), "", System.out);
+                StreamPrinter errorStreamPrinter = new StreamPrinter(p.getErrorStream(),
"", System.out);
                 errorStreamPrinter.run();
             }
-            
-            
+
             if (p.getInputStream() != null) {
                 StreamPrinter infoStreamPrinter = new StreamPrinter(p.getInputStream(), "[INFO]",
System.out);
                 infoStreamPrinter.run();
             }
-            
-            
 
             if (p != null) {
                 return p.waitFor() == 0 ? true : false;
@@ -64,5 +88,13 @@
         }
 
         return false;
+    }
+
+    private boolean isLongCommandLines(String args[]) {
+        StringBuffer strBuffer = new StringBuffer();
+        for (int i = 0; i < args.length; i++) {
+            strBuffer.append(args[i]);
+        }
+        return strBuffer.toString().length() > 4096 ? true : false;
     }
 }



Mime
View raw message