cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject svn commit: r1438101 - in /cxf/branches/2.7.x-fixes: ./ api/src/main/java/org/apache/cxf/common/util/ tools/common/src/main/java/org/apache/cxf/tools/common/
Date Thu, 24 Jan 2013 17:45:07 GMT
Author: asoldano
Date: Thu Jan 24 17:45:06 2013
New Revision: 1438101

URL: http://svn.apache.org/viewvc?rev=1438101&view=rev
Log:
Merged revisions 1438059,1438084 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1438059 | asoldano | 2013-01-24 17:20:15 +0100 (Thu, 24 Jan 2013) | 2 lines
  
  [CXF-4777] Allow providing CXF compiler instance to be used in WSDLToJava
........
  r1438084 | asoldano | 2013-01-24 18:22:02 +0100 (Thu, 24 Jan 2013) | 2 lines
  
  [CXF-4777] Further externalize Compiler methods
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java
    cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
    cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1438059,1438084

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

Modified: cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java?rev=1438101&r1=1438100&r2=1438101&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java (original)
+++ cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/common/util/Compiler.java Thu
Jan 24 17:45:06 2013
@@ -32,6 +32,7 @@ import javax.tools.Diagnostic;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaCompiler.CompilationTask;
+import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
@@ -83,7 +84,7 @@ public class Compiler {
         classPath = StringUtils.isEmpty(s) ? null : s;
     }
     
-    private void addArgs(List<String> list) {
+    protected void addArgs(List<String> list) {
         if (verbose) {
             list.add("-verbose");
         }
@@ -184,16 +185,22 @@ public class Compiler {
         return internalCompile(list.toArray(new String[list.size()]), idx);
     }
 
-    private boolean useJava6Compiler(String[] files) {
+    protected boolean useJava6Compiler(String[] files) {
         JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
         StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null,
null);
-        Iterable<? extends JavaFileObject> fileList 
-            = fileManager.getJavaFileObjectsFromStrings(Arrays.asList(files));
-        
-        
-        List<String> args = new ArrayList<String>();
-        addArgs(args);
-        DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>()
{
+        Iterable<? extends JavaFileObject> fileList = fileManager.getJavaFileObjectsFromStrings(Arrays
+            .asList(files));
+
+        return internalJava6Compile(compiler, wrapJavaFileManager(fileManager), setupDiagnosticListener(),
+                                    fileList);
+    }
+    
+    protected JavaFileManager wrapJavaFileManager(StandardJavaFileManager standardJavaFileManger)
{
+        return standardJavaFileManger;
+    }
+    
+    protected DiagnosticListener<JavaFileObject> setupDiagnosticListener() {
+        return new DiagnosticListener<JavaFileObject>() {
             public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
                 switch (diagnostic.getKind()) {
                 case ERROR:
@@ -214,7 +221,14 @@ public class Compiler {
                 }   
             }
         };
-        CompilationTask task = compiler.getTask(null, fileManager, listener , args, null,
fileList);
+    }
+    
+    protected boolean internalJava6Compile(JavaCompiler compiler, JavaFileManager fileManager,
+                                           DiagnosticListener<JavaFileObject> listener,
+                                           Iterable<? extends JavaFileObject> fileList)
{
+        List<String> args = new ArrayList<String>();
+        addArgs(args);
+        CompilationTask task = compiler.getTask(null, fileManager, listener, args, null,
fileList);
         Boolean ret = task.call();
         try {
             fileManager.close();
@@ -222,7 +236,6 @@ public class Compiler {
             System.err.print("[ERROR] IOException during compiling.");
             e.printStackTrace();
         }
-        
         return ret;
     }
 

Modified: cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java?rev=1438101&r1=1438100&r2=1438101&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
(original)
+++ cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
Thu Jan 24 17:45:06 2013
@@ -41,8 +41,11 @@ public class ClassUtils {
     protected static final Logger LOG = LogUtils.getL7dLogger(ClassUtils.class);
     
     public void compile(ToolContext context) throws ToolException {
-        Compiler compiler = new Compiler();
-        
+        Compiler compiler = (Compiler)context.get(ToolConstants.COMPILER);
+        if (compiler == null) {
+            compiler = new Compiler();
+        }
+
         if (context.isVerbose()) {
             compiler.setVerbose(true);
         }

Modified: cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=1438101&r1=1438100&r2=1438101&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
(original)
+++ cxf/branches/2.7.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
Thu Jan 24 17:45:06 2013
@@ -222,6 +222,7 @@ public final class ToolConstants {
     public static final String FRONTEND_PLUGIN = "frontend";
     public static final String DATABINDING_PLUGIN = "databinding";
     public static final String RUNTIME_DATABINDING_CLASS = "databinding-class";
+    public static final String COMPILER = "compiler";
 
     public static final String CFG_WSDL_VERSION = "wsdlversion";
 



Mime
View raw message