cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1355501 - in /cxf/trunk: maven-plugins/archetypes/cxf-jaxrs-service/ maven-plugins/codegen-plugin/ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plug...
Date Fri, 29 Jun 2012 18:42:37 GMT
Author: dkulp
Date: Fri Jun 29 18:42:33 2012
New Revision: 1355501

URL: http://svn.apache.org/viewvc?rev=1355501&view=rev
Log:
[CXF-4152] Updates to get the cxf-codegen-plugin be automatically m2e
compatible

Added:
    cxf/trunk/maven-plugins/codegen-plugin/src/main/resources/
    cxf/trunk/maven-plugins/codegen-plugin/src/main/resources/META-INF/
    cxf/trunk/maven-plugins/codegen-plugin/src/main/resources/META-INF/m2e/
    cxf/trunk/maven-plugins/codegen-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java
Modified:
    cxf/trunk/maven-plugins/archetypes/cxf-jaxrs-service/pom.xml
    cxf/trunk/maven-plugins/codegen-plugin/pom.xml
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/FileWriterUtil.java
    cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/FileWriterUtilTest.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLUtils.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGenerator.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
    cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java
    cxf/trunk/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java
    cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/TypesCodeWriter.java
    cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java
    cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java

Modified: cxf/trunk/maven-plugins/archetypes/cxf-jaxrs-service/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/archetypes/cxf-jaxrs-service/pom.xml?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/archetypes/cxf-jaxrs-service/pom.xml (original)
+++ cxf/trunk/maven-plugins/archetypes/cxf-jaxrs-service/pom.xml Fri Jun 29 18:42:33 2012
@@ -22,9 +22,9 @@
 
     <parent>
         <groupId>org.apache.cxf</groupId>
-        <artifactId>cxf-parent</artifactId>
+        <artifactId>cxf</artifactId>
         <version>2.7.0-SNAPSHOT</version>
-        <relativePath>../../../parent/pom.xml</relativePath>
+        <relativePath>../../../pom.xml</relativePath>
     </parent>
 
     <groupId>org.apache.cxf.archetype</groupId>

Modified: cxf/trunk/maven-plugins/codegen-plugin/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/pom.xml?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/pom.xml (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/pom.xml Fri Jun 29 18:42:33 2012
@@ -134,7 +134,6 @@
             <artifactId>spring-context</artifactId>
             <optional>true</optional>
         </dependency>
-
         <dependency>
             <groupId>org.apache.ant</groupId>
             <artifactId>ant</artifactId>
@@ -143,8 +142,13 @@
             <groupId>org.apache.ant</groupId>
             <artifactId>ant-nodeps</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.sonatype.plexus</groupId>
+            <artifactId>plexus-build-api</artifactId>
+            <version>0.0.7</version>
+            <optional>true</optional>
+        </dependency>
     </dependencies>
-    
 
     <profiles>
         <profile>

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
Fri Jun 29 18:42:33 2012
@@ -59,6 +59,7 @@ import org.codehaus.plexus.util.cli.Comm
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
 import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.sonatype.plexus.build.incremental.BuildContext;
 
 public abstract class AbstractCodegenMoho extends AbstractMojo {
 
@@ -140,6 +141,11 @@ public abstract class AbstractCodegenMoh
      * @parameter expression="${cxf.wsdlRoot}" default-value="${basedir}/src/main/resources/wsdl"
      */
     protected File wsdlRoot;
+    
+    /** @component */
+    protected BuildContext buildContext;
+    
+    
     /**
      * Sets the JVM arguments (i.e. <code>-Xms128m -Xmx128m</code>) if fork is
set to <code>true</code>.
      * 
@@ -207,6 +213,7 @@ public abstract class AbstractCodegenMoh
       * @required
       */
     private ArtifactResolver artifactResolver;
+    
 
     public AbstractCodegenMoho() {
         super();
@@ -268,11 +275,12 @@ public abstract class AbstractCodegenMoh
         // add the generated source into compile source
         if (project != null && getGeneratedSourceRoot() != null && getGeneratedSourceRoot().exists())
{
             project.addCompileSourceRoot(getGeneratedSourceRoot().getAbsolutePath());
+            buildContext.refresh(getGeneratedSourceRoot().getAbsoluteFile());
         }
         if (project != null && getGeneratedTestRoot() != null && getGeneratedTestRoot().exists())
{
             project.addTestCompileSourceRoot(getGeneratedTestRoot().getAbsolutePath());
+            buildContext.refresh(getGeneratedTestRoot().getAbsoluteFile());
         }
-
         System.gc();
     }
 
@@ -346,6 +354,7 @@ public abstract class AbstractCodegenMoh
         if (f.exists()) {
             return f.delete();
         }
+        buildContext.refresh(f.getParentFile());
 
         return true;
     }

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
Fri Jun 29 18:42:33 2012
@@ -20,6 +20,8 @@
 package org.apache.cxf.maven_plugin.wsdl2java;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -29,9 +31,11 @@ import java.util.Set;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.maven_plugin.AbstractCodegenMoho;
 import org.apache.cxf.maven_plugin.GenericWsdlOption;
 import org.apache.cxf.tools.common.ToolContext;
+import org.apache.cxf.tools.util.OutputStreamCreator;
 import org.apache.cxf.tools.wsdlto.WSDLToJava;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -228,8 +232,30 @@ public class WSDL2JavaMojo extends Abstr
                 BusFactory.setThreadDefaultBus(bus);
             }
             try {
-                new WSDLToJava(args).run(new ToolContext());
+                ToolContext ctx = new ToolContext();
+                final List<File> files = new ArrayList<File>();             
  
+                ctx.put(OutputStreamCreator.class, new OutputStreamCreator() {
+                    public OutputStream createOutputStream(File file) throws IOException
{
+                        files.add(file);
+                        return buildContext.newFileOutputStream(file);
+                    }
+                });
+                new WSDLToJava(args).run(ctx);
+                
+                List<File> oldFiles = CastUtils.cast((List<?>)buildContext
+                                                     .getValue("cxf.file.list." + doneFile.getName()));
+                if (oldFiles != null) {
+                    for (File f : oldFiles) {
+                        if (!files.contains(f)) {
+                            f.delete();
+                            buildContext.refresh(f);
+                        }
+                    }
+                }
+
+                buildContext.setValue("cxf.file.list." + doneFile.getName(), files);
             } catch (Throwable e) {
+                buildContext.setValue("cxf.file.list." + doneFile.getName(), null);
                 getLog().debug(e);
                 throw new MojoExecutionException(e.getMessage(), e);
             }
@@ -238,6 +264,7 @@ public class WSDL2JavaMojo extends Abstr
 
         try {
             doneFile.createNewFile();
+            buildContext.refresh(doneFile);
         } catch (Throwable e) {
             getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
             getLog().debug(e);
@@ -245,9 +272,11 @@ public class WSDL2JavaMojo extends Abstr
         }
         if (project != null && getGeneratedSourceRoot() != null && getGeneratedSourceRoot().exists())
{
             project.addCompileSourceRoot(getGeneratedSourceRoot().getAbsolutePath());
+            buildContext.refresh(getGeneratedSourceRoot().getAbsoluteFile());
         }
         if (project != null && getGeneratedTestRoot() != null && getGeneratedTestRoot().exists())
{
             project.addTestCompileSourceRoot(getGeneratedTestRoot().getAbsolutePath());
+            buildContext.refresh(getGeneratedTestRoot().getAbsoluteFile());
         }
         return bus;
     }

Added: cxf/trunk/maven-plugins/codegen-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml?rev=1355501&view=auto
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
(added)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
Fri Jun 29 18:42:33 2012
@@ -0,0 +1,31 @@
+<lifecycleMappingMetadata>
+  <pluginExecutions>
+    <pluginExecution>
+      <pluginExecutionFilter>
+        <goals>
+          <goal>wsdl2java</goal>
+        </goals>
+      </pluginExecutionFilter>
+      <action>
+        <execute>
+          <runOnIncremental>true</runOnIncremental>
+          <runOnConfiguration>true</runOnConfiguration>
+        </execute>
+      </action>
+    </pluginExecution>
+    <pluginExecution>
+      <pluginExecutionFilter>
+        <goals>
+          <goal>wsdl2js</goal>
+        </goals>
+      </pluginExecutionFilter>
+      <action>
+        <execute>
+          <runOnIncremental>true</runOnIncremental>
+          <runOnConfiguration>true</runOnConfiguration>
+        </execute>
+      </action>
+    </pluginExecution>
+  </pluginExecutions>
+</lifecycleMappingMetadata>
+

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java
(original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java
Fri Jun 29 18:42:33 2012
@@ -122,7 +122,7 @@ public final class VelocityGenerator {
 
     public File parseOutputName(String packageName, String filename, String ext) throws ToolException
{
         FileUtils.mkDir(new File(this.baseDir));
-        FileWriterUtil fw = new FileWriterUtil(this.baseDir);
+        FileWriterUtil fw = new FileWriterUtil(this.baseDir, null);
         try {
             return fw.getFileToWrite(packageName, filename + ext);
         } catch (IOException ioe) {

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/FileWriterUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/FileWriterUtil.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/FileWriterUtil.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/FileWriterUtil.java Fri
Jun 29 18:42:33 2012
@@ -21,7 +21,6 @@ package org.apache.cxf.tools.util;
 
 import java.io.BufferedOutputStream;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
@@ -34,9 +33,15 @@ import org.apache.cxf.tools.common.ToolE
 public class FileWriterUtil {
     private static final Logger LOG = LogUtils.getL7dLogger(FileWriterUtil.class);
     private final File target;
+    private final OutputStreamCreator osc;
 
-    public FileWriterUtil(String targetDir) throws ToolException {
+    public FileWriterUtil() throws ToolException {
+        target = null;
+        osc = new OutputStreamCreator();
+    }
+    public FileWriterUtil(String targetDir, OutputStreamCreator osc) throws ToolException
{
         target = new File(targetDir);
+        this.osc = osc == null ? new OutputStreamCreator() : osc;
         if (!(target.exists()) || !(target.isDirectory())) {
             Message msg = new Message("DIRECTORY_NOT_EXIST", LOG, target);
             throw new ToolException(msg);
@@ -52,15 +57,15 @@ public class FileWriterUtil {
         return fn;
     }
 
-    public static Writer getWriter(File fn) throws IOException {
+    private Writer getWriter(File fn) throws IOException {
         return getWriter(fn, "UTF-8");
     }
 
-    public static Writer getWriter(File fn, String encoding) throws IOException {
+    public Writer getWriter(File fn, String encoding) throws IOException {
         if (encoding == null) {
             encoding = "UTF-8";
         }
-        return new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(fn)),
encoding);
+        return new OutputStreamWriter(new BufferedOutputStream(osc.createOutputStream(fn)),
encoding);
     }
     
     public Writer getWriter(String packageName, String fileName) throws IOException {

Added: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java?rev=1355501&view=auto
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java
(added)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java
Fri Jun 29 18:42:33 2012
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.tools.util;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * 
+ */
+public class OutputStreamCreator {
+    
+    public OutputStream createOutputStream(File file) throws IOException {
+        return new FileOutputStream(file);
+    }
+}

Modified: cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/FileWriterUtilTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/FileWriterUtilTest.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/FileWriterUtilTest.java
(original)
+++ cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/FileWriterUtilTest.java
Fri Jun 29 18:42:33 2012
@@ -48,7 +48,7 @@ public class FileWriterUtilTest extends 
         File targetDir = new File(tmpDir + File.separator + "target");
         try {
             targetDir.mkdirs();
-            fileWriter = new FileWriterUtil(targetDir.getAbsolutePath());
+            fileWriter = new FileWriterUtil(targetDir.getAbsolutePath(), null);
             fileWriter.getWriter("com.iona.test" , "A.java");
             String packPath = "/com/iona/test/A.java".replace('/' , File.separatorChar);
             String path = targetDir.getAbsolutePath() + packPath;
@@ -70,7 +70,7 @@ public class FileWriterUtilTest extends 
 
         try {
             targetDir.mkdirs();
-            fileWriter = new FileWriterUtil(targetDir.getAbsolutePath()); 
+            fileWriter = new FileWriterUtil(targetDir.getAbsolutePath(), null); 
             assertNotNull(fileWriter.getWriter("com.iona.test.SAMPLE" , "A.java"));  
         } catch (IOException e) {
             // TODO Auto-generated catch block

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLUtils.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLUtils.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLUtils.java Fri
Jun 29 18:42:33 2012
@@ -66,7 +66,7 @@ public final class WSDLUtils {
 
     public static void writeWSDL(Definition def, String outputdir, String wsdlOutput)
         throws WSDLException, IOException {
-        FileWriterUtil fw = new FileWriterUtil(outputdir);
+        FileWriterUtil fw = new FileWriterUtil(outputdir, null);
         Writer outputWriter = fw.getWriter("", wsdlOutput);
 
         writeWSDL(def, outputWriter);

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
(original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
Fri Jun 29 18:42:33 2012
@@ -400,9 +400,10 @@ public class IDLToWSDLProcessor extends 
         
         if (env.optionSet(ToolCorbaConstants.CFG_WSDL_ENCODING)) { 
             String encoding = env.get(ToolCorbaConstants.CFG_WSDL_ENCODING).toString(); 
          
-            return FileWriterUtil.getWriter(new File(outputDirectory, filename), encoding);

+            return new FileWriterUtil()
+                .getWriter(new File(outputDirectory, filename), encoding); 
         } else {
-            FileWriterUtil fw = new FileWriterUtil(outputDirectory);        
+            FileWriterUtil fw = new FileWriterUtil(outputDirectory, null);        
             return fw.getWriter("", filename); 
         }       
     }
@@ -410,9 +411,9 @@ public class IDLToWSDLProcessor extends 
     public Writer getOutputWriter(File file) throws Exception {        
         if (env.optionSet(ToolCorbaConstants.CFG_WSDL_ENCODING)) { 
             String encoding = env.get(ToolCorbaConstants.CFG_WSDL_ENCODING).toString(); 
          
-            return FileWriterUtil.getWriter(file, encoding); 
+            return new FileWriterUtil().getWriter(file, encoding); 
         } else {
-            return FileWriterUtil.getWriter(file);
+            return new FileWriterUtil().getWriter(file, "UTF-8");
         }       
     }    
 

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
Fri Jun 29 18:42:33 2012
@@ -24,6 +24,7 @@ import java.io.File;
 import org.apache.cxf.Bus;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.ToolContext;
+import org.apache.cxf.tools.util.OutputStreamCreator;
 
 public abstract class AbstractGenerator<T> {
     private ServiceInfo service;
@@ -82,4 +83,13 @@ public abstract class AbstractGenerator<
         }
         return parentDir;
     }
+    
+    protected OutputStreamCreator getOutputStreamCreator() {
+        OutputStreamCreator osc = context.get(OutputStreamCreator.class);
+        if (osc == null) {
+            osc = new OutputStreamCreator();
+            context.put(OutputStreamCreator.class, osc);
+        }
+        return osc;
+    }
 }

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/BeanGenerator.java
Fri Jun 29 18:42:33 2012
@@ -26,6 +26,7 @@ import java.util.List;
 
 import org.apache.cxf.common.util.Compiler;
 import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.VelocityGenerator;
 import org.apache.cxf.tools.common.model.JavaClass;
 import org.apache.cxf.tools.java2wsdl.generator.AbstractGenerator;
@@ -74,7 +75,8 @@ public class BeanGenerator extends Abstr
                                                       wrapperClass.getName());
                 generatedFiles.add(file);
             
-                generator.doWrite(TEMPLATE, FileWriterUtil.getWriter(file));
+                generator.doWrite(TEMPLATE, new FileWriterUtil(file.getParent(), getOutputStreamCreator())
+                    .getWriter(file, (String)getToolContext().get(ToolConstants.CFG_ENCODING)));
             
                 generator.clearAttributes();
             }

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGenerator.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGenerator.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/DateTypeCustomGenerator.java
Fri Jun 29 18:42:33 2012
@@ -94,7 +94,8 @@ public final class DateTypeCustomGenerat
             }
 
             try {
-                generator.doWrite(getTemplate(), FileWriterUtil.getWriter(xjb));
+                generator.doWrite(getTemplate(), new FileWriterUtil(xjb.getParent(), getOutputStreamCreator())
+                    .getWriter(xjb, "UTF-8"));
             } catch (Exception e) {
                 e.printStackTrace();
             }

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
Fri Jun 29 18:42:33 2012
@@ -46,6 +46,7 @@ import org.apache.cxf.service.model.Sche
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.java2wsdl.generator.AbstractGenerator;
 import org.apache.cxf.tools.util.FileWriterUtil;
+import org.apache.cxf.tools.util.OutputStreamCreator;
 import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
 import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
 
@@ -66,7 +67,8 @@ public class WSDL11Generator extends Abs
         File outputdir = createOutputDir(file);
         Definition def = null;
         try {
-            Writer os = FileWriterUtil.getWriter(file);
+            Writer os = new FileWriterUtil(file.getParent(),
+                                           getOutputStreamCreator()).getWriter(file, "UTF-8");
             WSDLWriter wsdlWriter = WSDLFactory.newInstance().newWSDLWriter();
 
             ServiceWSDLBuilder builder = new ServiceWSDLBuilder(getBus(), getServiceModel());
@@ -101,7 +103,8 @@ public class WSDL11Generator extends Abs
                 File impfile = new File(file.getParentFile(), imp.getKey());
                 Element el = imp.getValue().getElement();
                 updateImports(el, imports);
-                os = FileWriterUtil.getWriter(impfile);
+                os = new FileWriterUtil(impfile.getParent(),
+                                        getToolContext().get(OutputStreamCreator.class)).getWriter(impfile,
"UTF-8");
                 XMLUtils.writeTo(el, os, 2);
                 os.close();
             }

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
Fri Jun 29 18:42:33 2012
@@ -142,6 +142,7 @@ public class JavaToWSDLProcessor impleme
         factory.setWSDLVersion(getWSDLVersion());
 
         AbstractGenerator<?> generator = factory.newGenerator();
+        generator.setToolContext(context);
         generator.setAllowImports(context.containsKey(ToolConstants.CFG_CREATE_XSD_IMPORTS));
         generator.setOutputBase(wsdlFile);
         return generator;

Modified: cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java
(original)
+++ cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractGenerator.java
Fri Jun 29 18:42:33 2012
@@ -36,6 +36,7 @@ import org.apache.cxf.tools.common.ToolE
 import org.apache.cxf.tools.common.VelocityGenerator;
 import org.apache.cxf.tools.util.ClassCollector;
 import org.apache.cxf.tools.util.FileWriterUtil;
+import org.apache.cxf.tools.util.OutputStreamCreator;
 import org.apache.cxf.version.Version;
 
 public abstract class AbstractGenerator implements FrontEndGenerator {
@@ -62,7 +63,7 @@ public abstract class AbstractGenerator 
         if (env.optionSet(ToolConstants.CFG_GEN_OVERWRITE)) {
             return false;
         }
-        FileWriterUtil fw = new FileWriterUtil((String)env.get(ToolConstants.CFG_OUTPUTDIR));
+        FileWriterUtil fw = new FileWriterUtil((String)env.get(ToolConstants.CFG_OUTPUTDIR),
null);
         return fw.isCollision(packageName, filename + ext);
     }
 
@@ -80,7 +81,8 @@ public abstract class AbstractGenerator 
             return null;
         }
 
-        fw = new FileWriterUtil(getOutputDir());
+        fw = new FileWriterUtil(getOutputDir(), 
+                                (OutputStreamCreator)env.get(OutputStreamCreator.class));
         try {
             if (".java".equals(ext)) {
                 writer = fw.getWriter(packageName, filename + ext, 

Modified: cxf/trunk/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java
(original)
+++ cxf/trunk/tools/wsdlto/core/src/test/java/org/apache/cxf/tools/wsdlto/core/AbstractGeneratorTest.java
Fri Jun 29 18:42:33 2012
@@ -39,7 +39,7 @@ public class AbstractGeneratorTest exten
     @Test
     public void testKeep() throws Exception {
         gen = new DummyGenerator();
-        util = new FileWriterUtil(output.toString());
+        util = new FileWriterUtil(output.toString(), null);
 
         context = new ToolContext();
         context.put(ToolConstants.CFG_OUTPUTDIR, output.toString());
@@ -57,7 +57,7 @@ public class AbstractGeneratorTest exten
     @Test
     public void testOverwrite() throws Exception {
         gen = new DummyGenerator();
-        util = new FileWriterUtil(output.toString());
+        util = new FileWriterUtil(output.toString(), null);
 
         context = new ToolContext();
         context.put(ToolConstants.CFG_OUTPUTDIR, output.toString());

Modified: cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Fri Jun 29 18:42:33 2012
@@ -113,6 +113,7 @@ import org.apache.cxf.tools.common.ToolE
 import org.apache.cxf.tools.common.model.DefaultValueWriter;
 import org.apache.cxf.tools.util.ClassCollector;
 import org.apache.cxf.tools.util.JAXBUtils;
+import org.apache.cxf.tools.util.OutputStreamCreator;
 import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
 import org.apache.cxf.tools.wsdlto.core.DefaultValueProvider;
 import org.apache.cxf.tools.wsdlto.core.RandomValueProvider;
@@ -734,7 +735,8 @@ public class JAXBDataBinding implements 
 
             TypesCodeWriter fileCodeWriter = new TypesCodeWriter(new File(dir),
                                                                  context.getExcludePkgList(),
-                                                                 (String)context.get(ToolConstants.CFG_ENCODING));
+                                                                 (String)context.get(ToolConstants.CFG_ENCODING),
+                                                                 context.get(OutputStreamCreator.class));
 
             if (rawJaxbModelGenCode instanceof S2JJAXBModel) {
                 S2JJAXBModel schem2JavaJaxbModel = rawJaxbModelGenCode;

Modified: cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/TypesCodeWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/TypesCodeWriter.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/TypesCodeWriter.java
(original)
+++ cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/TypesCodeWriter.java
Fri Jun 29 18:42:33 2012
@@ -20,7 +20,6 @@
 package org.apache.cxf.tools.wsdlto.databinding.jaxb;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.lang.reflect.Field;
@@ -31,24 +30,30 @@ import com.sun.codemodel.CodeWriter;
 import com.sun.codemodel.JPackage;
 
 import org.apache.cxf.common.util.ReflectionUtil;
+import org.apache.cxf.tools.util.OutputStreamCreator;
 
 public class TypesCodeWriter extends CodeWriter {
 
     /** The target directory to put source code. */
     private File target;
+    private OutputStreamCreator osc;
     
     private List<String> excludeFileList = new ArrayList<String>();
     private List<String> excludePkgList;
     
     private List<File> generatedFiles = new ArrayList<File>();
 
-    public TypesCodeWriter(File ftarget, List<String> excludePkgs, String e)
+    public TypesCodeWriter(File ftarget, List<String> excludePkgs, String e,
+                           OutputStreamCreator outputStreamCreator)
         throws IOException {
         target = ftarget;
         excludePkgList = excludePkgs;
         setEncoding(e);
+        osc = outputStreamCreator == null ? new OutputStreamCreator() : outputStreamCreator;
     }
     
+
+
     private void setEncoding(String s) {
         if (s != null) {
             try {
@@ -64,7 +69,7 @@ public class TypesCodeWriter extends Cod
     public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
         File f = getFile(pkg, fileName);
         generatedFiles.add(f);
-        return new FileOutputStream(getFile(pkg, fileName));
+        return osc.createOutputStream(getFile(pkg, fileName));
     }
 
     public List<File> getGeneratedFiles() {

Modified: cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java
(original)
+++ cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java
Fri Jun 29 18:42:33 2012
@@ -40,6 +40,7 @@ import org.apache.cxf.tools.common.ToolC
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.util.ClassCollector;
 import org.apache.cxf.tools.util.FileWriterUtil;
+import org.apache.cxf.tools.util.OutputStreamCreator;
 import org.apache.cxf.tools.validator.internal.WSDL11Validator;
 import org.apache.cxf.wsdl.WSDLExtensibilityPlugin;
 import org.apache.cxf.wsdl.WSDLManager;
@@ -92,7 +93,7 @@ public class AbstractWSDLToProcessor imp
         } else {
             outputDir = "./";
         }
-        FileWriterUtil fw = new FileWriterUtil(outputDir);
+        FileWriterUtil fw = new FileWriterUtil(outputDir, env.get(OutputStreamCreator.class));
         try {
             writer = fw.getWriter("", newName);
         } catch (IOException ioe) {

Modified: cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java?rev=1355501&r1=1355500&r2=1355501&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java
(original)
+++ cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java
Fri Jun 29 18:42:33 2012
@@ -48,6 +48,7 @@ import org.apache.cxf.tools.common.ToolC
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.dom.ExtendedDocumentBuilder;
 import org.apache.cxf.tools.util.FileWriterUtil;
+import org.apache.cxf.tools.util.OutputStreamCreator;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingDeserializer;
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingSerializer;
@@ -200,7 +201,7 @@ public class XSDToWSDLProcessor implemen
         } else {
             outputDir = "./";
         }
-        FileWriterUtil fw = new FileWriterUtil(outputDir);
+        FileWriterUtil fw = new FileWriterUtil(outputDir, env.get(OutputStreamCreator.class));
         try {
             writer = fw.getWriter("", newName);
         } catch (IOException ioe) {



Mime
View raw message