cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1356391 - in /cxf/branches/2.6.x-fixes: maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/common/src/main/java/org/apache/cxf/tools/util/ tools/w...
Date Mon, 02 Jul 2012 18:25:22 GMT
Author: dkulp
Date: Mon Jul  2 18:25:20 2012
New Revision: 1356391

URL: http://svn.apache.org/viewvc?rev=1356391&view=rev
Log:
Merged revisions 1356387 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1356387 | dkulp | 2012-07-02 14:21:22 -0400 (Mon, 02 Jul 2012) | 5 lines

  [CXF-4152, CXF-4403] Update codegen plugin for wsdl2java goal to pass
  warnings and errors back to Eclipse for display.
  Update customization parser to not discard location information so
  information passed back to eclipse is actually useful.

........

Added:
    cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolErrorListener.java
Modified:
    cxf/branches/2.6.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
    cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
    cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolException.java
    cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
    cxf/branches/2.6.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
    cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java
    cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
    cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java

Modified: cxf/branches/2.6.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java?rev=1356391&r1=1356390&r2=1356391&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
(original)
+++ cxf/branches/2.6.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
Mon Jul  2 18:25:20 2012
@@ -35,10 +35,12 @@ 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.common.ToolErrorListener;
 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;
+import org.sonatype.plexus.build.incremental.BuildContext;
 
 /**
  * @goal wsdl2java
@@ -201,6 +203,20 @@ public class WSDL2JavaMojo extends Abstr
         }
         doneFile.delete();
 
+        try {
+            File file = new File(wsdlURI);
+            if (file.exists()) {
+                buildContext.removeMessages(file);
+            }
+        } catch (Throwable t) {
+            //ignore
+        }
+        if (wsdlOption.getDependencies() != null) {
+            for (File f : wsdlOption.getDependencies()) {
+                buildContext.removeMessages(f);
+            }
+        }
+        
         List<String> list = wsdlOption.generateCommandLine(outputDirFile, basedir,
wsdlURI, 
                                                            getLog().isDebugEnabled());
         if (encoding != null) {
@@ -234,12 +250,33 @@ public class WSDL2JavaMojo extends Abstr
             try {
                 ToolContext ctx = new ToolContext();
                 final List<File> files = new ArrayList<File>();             
  
+                final List<File> errorfiles = new ArrayList<File>();        
       
                 ctx.put(OutputStreamCreator.class, new OutputStreamCreator() {
                     public OutputStream createOutputStream(File file) throws IOException
{
                         files.add(file);
                         return buildContext.newFileOutputStream(file);
                     }
                 });
+                ctx.setErrorListener(new ToolErrorListener() {
+                    public void addError(File file, int line, int column, String message,
Throwable t) {
+                        super.addError(file, line, column, message, t);
+                        if (!errorfiles.contains(file)) {
+                            buildContext.removeMessages(file);
+                            errorfiles.add(file);
+                        }
+                        buildContext.addMessage(file, line, column, message, BuildContext.SEVERITY_ERROR,
t);
+                    }
+
+                    public void addWarning(File file, int line, int column, String message,
Throwable t) {
+                        if (!errorfiles.contains(file)) {
+                            buildContext.removeMessages(file);
+                            errorfiles.add(file);
+                        }
+                        //don't send to super which just LOG.warns.   We'll let Maven do
that to
+                        //not duplicate the error message.
+                        buildContext.addMessage(file, line, column, message, BuildContext.SEVERITY_WARNING,
t);
+                    }
+                });
                 new WSDLToJava(args).run(ctx);
                 
                 List<File> oldFiles = CastUtils.cast((List<?>)buildContext
@@ -257,6 +294,9 @@ public class WSDL2JavaMojo extends Abstr
             } catch (Throwable e) {
                 buildContext.setValue("cxf.file.list." + doneFile.getName(), null);
                 getLog().debug(e);
+                if (e instanceof RuntimeException) {
+                    throw (RuntimeException)e;
+                }
                 throw new MojoExecutionException(e.getMessage(), e);
             }
         }

Modified: cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java?rev=1356391&r1=1356390&r2=1356391&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
Mon Jul  2 18:25:20 2012
@@ -40,6 +40,7 @@ public class ToolContext {
     private Map<String, Object> paramMap;
     private String packageName;
     private boolean packageNameChanged;
+    private ToolErrorListener errors;
     private Map<String, String> namespacePackageMap = new HashMap<String, String>();
     private Map<String, String> excludeNamespacePackageMap = new HashMap<String,
String>();
     private List<InputSource> jaxbBindingFiles = new ArrayList<InputSource>();
@@ -281,6 +282,15 @@ public class ToolContext {
         return null;
     }
     
+    public ToolErrorListener getErrorListener() {
+        if (errors == null) {
+            errors = new ToolErrorListener();
+        }
+        return errors;
+    }
+    public void setErrorListener(ToolErrorListener e) {
+        errors = e;
+    }
     
     public Map<String, String> getNamespacePackageMap() {
         return namespacePackageMap;
@@ -310,7 +320,7 @@ public class ToolContext {
         newCopy.jaxbBindingFiles = new ArrayList<InputSource>(jaxbBindingFiles);
         newCopy.excludePkgList = new ArrayList<String>(excludePkgList);
         newCopy.excludeFileList = new ArrayList<String>(excludeFileList);
-        
+        newCopy.errors = errors;
         return newCopy;
     }    
 }

Added: cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolErrorListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolErrorListener.java?rev=1356391&view=auto
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolErrorListener.java
(added)
+++ cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolErrorListener.java
Mon Jul  2 18:25:20 2012
@@ -0,0 +1,90 @@
+/**
+ * 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.common;
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+
+/**
+ * 
+ */
+public class ToolErrorListener {
+    private static final Logger LOG = LogUtils.getL7dLogger(ToolErrorListener.class);
+    
+    class ErrorInfo {
+        File file;
+        int line;
+        int col;
+        Throwable cause;
+        String message;
+        
+        ErrorInfo(File f, int l, int c, String m, Throwable t) {
+            file = f;
+            line = l;
+            col = c;
+            message = m;
+            cause = t;
+        }
+    }
+    List<ErrorInfo> errors = new LinkedList<ErrorInfo>();
+    
+    public void addError(File file, int line, int column, String message) {
+        addError(file, line, column, null);
+    }
+    public void addError(File file, int line, int column, String message, Throwable t) {
+        errors.add(new ErrorInfo(file, line, column, message, t));
+    }
+
+    public void addWarning(File file, int line, int column, String message) {
+        addWarning(file, line, column, null);
+    }
+    public void addWarning(File file, int line, int column, String message, Throwable t)
{
+        if (file != null) {
+            message = file.getAbsolutePath() + " [" + line + "," + column + "]: " + message;

+        }
+        LOG.warning(message);
+    }
+
+    public int getErrorCount() {
+        return errors.size();
+    }
+    private StringBuilder createMessage(StringBuilder b, ToolErrorListener.ErrorInfo e) {
+        if (e.file != null) {
+            b.append(e.file.getAbsolutePath())
+                .append(" [").append(e.line).append(',').append(e.col).append("]: ").append(e.message);
+        } else if (e.message == null && e.cause != null) {
+            b.append(e.cause.getLocalizedMessage());
+        } else {
+            b.append(e.message);
+        }
+        return b;
+    }
+    public void throwToolException() {
+        StringBuilder b = new StringBuilder();
+        for (ErrorInfo e : errors) {
+            createMessage(b, e).append("\n");
+        }
+        throw new ToolException(b.toString(), errors);
+    }
+}

Modified: cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolException.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolException.java?rev=1356391&r1=1356390&r2=1356391&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolException.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/ToolException.java
Mon Jul  2 18:25:20 2012
@@ -18,6 +18,9 @@
  */
 
 package org.apache.cxf.tools.common;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.i18n.Message;
@@ -26,12 +29,35 @@ import org.apache.cxf.common.i18n.Messag
  * Exception used for unrecoverable error in a CXF tool.
  */
 public class ToolException extends RuntimeException {
-
-    
     private static final long serialVersionUID = -4418907917249006910L;
+    List<Throwable> suppressed = new ArrayList<Throwable>(0);
+    boolean hasSuppressed;
+    
     public ToolException() {
         super();
     }
+    public ToolException(String message, List<ToolErrorListener.ErrorInfo> e) {
+        super(message);
+        
+        if (e.size() > 1) {
+            for (ToolErrorListener.ErrorInfo er : e) {
+                String ms = createMessage(er);
+                if (ms != null
+                    && er.cause != null
+                    && ms.equals(er.cause.getLocalizedMessage())) {
+                    addSuppressedThrowable(er.cause);
+                } else if (ms == null && er.cause != null) {
+                    addSuppressedThrowable(er.cause);
+                } else {
+                    addSuppressedThrowable(new ToolException(ms, er.cause));
+                }
+            }
+        } else if (e.size() == 1) {
+            initCause(e.get(0).cause);
+        }
+    }
+
+    
     public ToolException(Message msg) {
         super(msg.toString());
     }
@@ -61,5 +87,69 @@ public class ToolException extends Runti
     public ToolException(String messageId, Logger logger, Object ... args) {
         this(new Message(messageId, logger, args));
     }
+    private String createMessage(ToolErrorListener.ErrorInfo e) {
+        if (e.file != null) {
+            return e.file.getAbsolutePath() + " [" + e.line + "," + e.col + "]: " + e.message;

+        }
+        if (e.message == null && e.cause != null) {
+            return e.cause.getLocalizedMessage();
+        }
+        return e.message;
+    }
+    public void printStackTrace(PrintStream ps) {
+        if (!hasSuppressed) {
+            super.printStackTrace(ps);
+            return;
+        }
+        printStackTrace(ps, "", "");   
+    }
+    public void printStackTrace(PrintStream ps, String pfx, String cap) {
+        ps.println(pfx + cap + this);
+        StackTraceElement[] trace = super.getStackTrace();
+        for (StackTraceElement traceElement : trace) {
+            ps.println(pfx + "\tat " + traceElement);
+        }
+
+        // Print suppressed exceptions, if any
+        for (Throwable se : suppressed) {
+            printThrowable(se, ps, pfx + "/t", "Suppressed: ");
+        }
+
+        // Print cause, if any
+        Throwable ourCause = getCause();
+        if (ourCause != null &&  ourCause != suppressed.get(0)) {
+            printThrowable(ourCause, ps, pfx + "/t", "Caused by: ");
+        }
+    }    
+    private void printThrowable(Throwable t, PrintStream ps, String pfx, String cap) {
+        if (t instanceof ToolException) {
+            ((ToolException)t).printStackTrace(ps, pfx, cap);
+        } else {
+            ps.println(pfx + cap + t);
+            StackTraceElement[] trace = t.getStackTrace();
+            for (StackTraceElement ste : trace) {
+                ps.println(pfx + "\tat " + ste);
+            }
+            if (t.getCause() != null) {
+                printThrowable(t.getCause(), ps, pfx + "\t", "Caused by: ");
+            }
+        }
+        
+    }
+
+    
+    private void addSuppressedThrowable(Throwable t) {
+        try {
+            this.getClass().getMethod("addSuppressed", Throwable.class).invoke(this, t);
+        } catch (Throwable t2) {
+            //java < 1.7
+            suppressed.add(t2);
+            if (getCause() == null) {
+                initCause(t);
+            }
+            hasSuppressed = true;
+        }
+    }
+
 }
 

Modified: cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java?rev=1356391&r1=1356390&r2=1356391&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
Mon Jul  2 18:25:20 2012
@@ -23,6 +23,8 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.util.List;
 
+import javax.xml.XMLConstants;
+
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -94,7 +96,7 @@ public final class JAXBUtils {
         } else {
             packagename = doc.createElementNS(ToolConstants.NS_JAXB_BINDINGS, "package");
         }
-        packagename.setAttribute("name", packagevalue);
+        packagename.setAttributeNS(null, "name", packagevalue);
 
         schemaBindings.appendChild(packagename);
 
@@ -110,16 +112,16 @@ public final class JAXBUtils {
      */
     public static File getPackageMappingSchemaBindingFile(String namespace, String pkgName)
{
         Document doc = DOMUtils.createDocument();
-        Element rootElement = doc.createElement("schema");
-        rootElement.setAttribute("xmlns", ToolConstants.SCHEMA_URI);
-        rootElement.setAttribute("xmlns:jaxb", ToolConstants.NS_JAXB_BINDINGS);
-        rootElement.setAttribute("jaxb:version", "2.0");
-        rootElement.setAttribute("targetNamespace", namespace);
-        Element annoElement = doc.createElement("annotation");
-        Element appInfo = doc.createElement("appinfo");
-        Element schemaBindings = doc.createElement("jaxb:schemaBindings");
-        Element pkgElement = doc.createElement("jaxb:package");
-        pkgElement.setAttribute("name", pkgName);
+        Element rootElement = doc.createElementNS(ToolConstants.SCHEMA_URI, "schema");
+        rootElement.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns", ToolConstants.SCHEMA_URI);
+        rootElement.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:jaxb", ToolConstants.NS_JAXB_BINDINGS);
+        rootElement.setAttributeNS(ToolConstants.NS_JAXB_BINDINGS, "jaxb:version", "2.0");
+        rootElement.setAttributeNS(null, "targetNamespace", namespace);
+        Element annoElement = doc.createElementNS(ToolConstants.SCHEMA_URI, "annotation");
+        Element appInfo = doc.createElementNS(ToolConstants.SCHEMA_URI, "appinfo");
+        Element schemaBindings = doc.createElementNS(ToolConstants.NS_JAXB_BINDINGS, "jaxb:schemaBindings");
+        Element pkgElement = doc.createElementNS(ToolConstants.NS_JAXB_BINDINGS, "jaxb:package");
+        pkgElement.setAttributeNS(null, "name", pkgName);
         annoElement.appendChild(appInfo);
         appInfo.appendChild(schemaBindings);
         schemaBindings.appendChild(pkgElement);

Modified: cxf/branches/2.6.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=1356391&r1=1356390&r2=1356391&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Mon Jul  2 18:25:20 2012
@@ -124,6 +124,9 @@ public class WSDLToJavaContainer extends
                     
                     processWsdl();
                 }
+                if (context.getErrorListener().getErrorCount() > 0) {
+                    context.getErrorListener().throwToolException();
+                }
             } catch (IOException e) {
                 throw new ToolException(e);
             } finally {
@@ -137,6 +140,9 @@ public class WSDLToJavaContainer extends
             }
         } else {
             processWsdl();
+            if (context.getErrorListener().getErrorCount() > 0) {
+                context.getErrorListener().throwToolException();
+            }
         }
     }
 
@@ -240,6 +246,9 @@ public class WSDLToJavaContainer extends
         }
         
         generateTypes();
+        if (context.getErrorListener().getErrorCount() > 0) {
+            return;
+        }
 
         for (ServiceInfo service : serviceList) {
             context.put(ServiceInfo.class, service);
@@ -248,9 +257,14 @@ public class WSDLToJavaContainer extends
                 validate(service);
             }
 
-            // Build the JavaModel from the ServiceModel
-            processor.setEnvironment(context);
-            processor.process();
+            if (context.getErrorListener().getErrorCount() == 0) {
+                // Build the JavaModel from the ServiceModel
+                processor.setEnvironment(context);
+                processor.process();
+            }
+        }
+        if (context.getErrorListener().getErrorCount() > 0) {
+            return;
         }
         if (!isSuppressCodeGen()) {
             // Generate artifacts

Modified: cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java?rev=1356391&r1=1356390&r2=1356391&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBBindErrorListener.java
Mon Jul  2 18:25:20 2012
@@ -19,52 +19,50 @@
 
 package org.apache.cxf.tools.wsdlto.databinding.jaxb;
 
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+
 import com.sun.tools.xjc.api.ErrorListener;
 
-import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.common.ToolErrorListener;
 
 public class JAXBBindErrorListener implements ErrorListener {
     private boolean isVerbose;
-    private String prefix = "Thrown by JAXB: ";
-    private StringBuilder errors = new StringBuilder();
-    private Exception firstException;
+    private ToolErrorListener listener;
     
-    public JAXBBindErrorListener(boolean verbose) {
+    public JAXBBindErrorListener(boolean verbose, ToolErrorListener l) {
         isVerbose = verbose;
+        listener = l;
     }
 
     public boolean hasErrors() {
-        return errors.length() != 0;
-    }
-    public void throwError() {
-        throw new ToolException(prefix + "\n" + errors.toString(), firstException);
+        return listener.getErrorCount() > 0;
     }
-    
+
     public void error(org.xml.sax.SAXParseException exception) {
-        if (errors.length() == 0) {
-            errors.append(prefix);
-        }
-        errors.append("\n");
-        if (exception.getLineNumber() > 0) {
-            errors.append(exception.getLocalizedMessage() + "\n"
-                       + " at line " + exception.getLineNumber()
-                       + " column " + exception.getColumnNumber()
-                       + " of schema " + exception.getSystemId()
-                       + "\n");
-           
-        } else {
-            errors.append(prefix + mapMessage(exception.getLocalizedMessage())
-                          + "\n");
-        }
-        if (firstException == null) {
-            firstException = exception;
-            firstException.fillInStackTrace();
-        }
+        String s = exception.getSystemId();
+        File file = null;
+        if (s != null && s.startsWith("file:")) {
+            if (s.contains("#")) {
+                s = s.substring(0, s.indexOf('#'));
+            }
+            try {
+                URI uri = new URI(s);
+                file = new File(uri);
+            } catch (URISyntaxException e) {
+                //ignore
+            }
+        }
+        listener.addError(file,
+                          exception.getLineNumber(),
+                          exception.getColumnNumber(),
+                          mapMessage(exception.getLocalizedMessage()),
+                          exception);
     }
 
     public void fatalError(org.xml.sax.SAXParseException exception) {
-        throw new ToolException(prefix + exception.getLocalizedMessage()
-                                + " of schema " + exception.getSystemId(), exception);
+        error(exception);
     }
 
     public void info(org.xml.sax.SAXParseException exception) {
@@ -79,6 +77,25 @@ public class JAXBBindErrorListener imple
             System.out.println("JAXB parsing schema warning " + exception.toString()
                                + " in schema " + exception.getSystemId());
         }
+        String s = exception.getSystemId();
+        File file = null;
+        if (s != null && s.startsWith("file:")) {
+            if (s.contains("#")) {
+                s = s.substring(0, s.indexOf('#'));
+            }
+            try {
+                URI uri = new URI(s);
+                file = new File(uri);
+            } catch (URISyntaxException e) {
+                //ignore
+            }
+        }
+        listener.addWarning(file,
+                          exception.getLineNumber(),
+                          exception.getColumnNumber(),
+                          mapMessage(exception.getLocalizedMessage()),
+                          exception);
+        
     }
     
     private String mapMessage(String msg) {

Modified: cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=1356391&r1=1356390&r2=1356391&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Mon Jul  2 18:25:20 2012
@@ -313,7 +313,7 @@ public class JAXBDataBinding implements 
 
         schemaCompiler.setClassNameAllocator(allocator);
 
-        listener = new JAXBBindErrorListener(context.isVerbose());
+        listener = new JAXBBindErrorListener(context.isVerbose(), context.getErrorListener());
         schemaCompiler.setErrorListener(listener);
         // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
         List<InputSource> jaxbBindings = context.getJaxbBindingFile();
@@ -428,10 +428,7 @@ public class JAXBDataBinding implements 
                 }
             }
         }
-        
-        if (listener.hasErrors()) {
-            listener.throwError();
-        }
+
         initialized = true;
     }
 
@@ -534,7 +531,7 @@ public class JAXBDataBinding implements 
     }
     private InputSource convertToTmpInputSource(Element ele, String schemaLoc) throws Exception
{
         InputSource result = null;
-        ele.setAttribute("schemaLocation", schemaLoc);
+        ele.setAttributeNS(null, "schemaLocation", schemaLoc);
         File tmpFile = FileUtils.createTempFile("jaxbbinding", ".xml");
         XMLUtils.writeTo(ele, new FileOutputStream(tmpFile));
         result = new InputSource(URIParserUtil.getAbsoluteURI(tmpFile.getAbsolutePath()));
@@ -729,6 +726,10 @@ public class JAXBDataBinding implements 
         if (rawJaxbModelGenCode == null) {
             return;
         }
+        if (c.getErrorListener().getErrorCount() > 0) {
+            return;
+        }
+
 
         try {
             String dir = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
@@ -868,8 +869,14 @@ public class JAXBDataBinding implements 
             clone = document.createElement(node.getNodeName());
             NamedNodeMap attributes = node.getAttributes();
             for (int i = 0; i < attributes.getLength(); i++) {
-                ((Element)clone).setAttribute(attributes.item(i).getNodeName(), attributes.item(i)
-                    .getNodeValue());
+                ((Element)clone).setAttributeNS(attributes.item(i).getNamespaceURI(),
+                                                attributes.item(i).getNodeName(),
+                                                attributes.item(i).getNodeValue());
+            }
+            try {
+                clone.setUserData("location", node.getUserData("location"), null);
+            } catch (Throwable t) {
+                //non DOM level 3
             }
             break;
 

Modified: cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=1356391&r1=1356390&r2=1356391&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
Mon Jul  2 18:25:20 2012
@@ -30,6 +30,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.logging.Logger;
 
+import javax.xml.XMLConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
@@ -154,10 +155,17 @@ public final class CustomizationParser {
         }
         
         try {
-            doc = DOMUtils.readXml(ins);
+            XMLStreamReader reader = StaxUtils.createXMLStreamReader(uri, ins);
+            doc = StaxUtils.read(reader, true);
         } catch (Exception e) {
             Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {uri});
             throw new ToolException(msg, e);
+        } finally {
+            try {
+                ins.close();
+            } catch (IOException ex) {
+                //ignore
+            }
         }
         try {
             doc.setDocumentURI(uri);
@@ -236,8 +244,9 @@ public final class CustomizationParser {
     private void appendJaxbVersion(final Element schemaElement) {
         String jaxbPrefix = schemaElement.lookupPrefix(ToolConstants.NS_JAXB_BINDINGS);
         if (jaxbPrefix == null) {
-            schemaElement.setAttribute("xmlns:jaxb", ToolConstants.NS_JAXB_BINDINGS);
-            schemaElement.setAttribute("jaxb:version", "2.0");
+            schemaElement.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, 
+                                       "xmlns:jaxb", ToolConstants.NS_JAXB_BINDINGS);
+            schemaElement.setAttributeNS(ToolConstants.NS_JAXB_BINDINGS, "jaxb:version",
"2.0");
         }
     }
 
@@ -324,8 +333,9 @@ public final class CustomizationParser {
                                 pfxs = "";
                             }
                             String ns = el.lookupNamespaceURI(pfx);
-                            schemaNode.setAttribute("xmlns:" + pfx,
-                                                    ns);
+                            schemaNode.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,

+                                                      "xmlns:" + pfx,
+                                                      ns);
                         }
                     }
                 }
@@ -383,8 +393,9 @@ public final class CustomizationParser {
 
         for (Map.Entry<String, String> ent : ctx.getUsedNamespaces().entrySet()) {
             if (node.lookupNamespaceURI(ent.getKey()) == null) {
-                node.getOwnerDocument().getDocumentElement().setAttribute("xmlns:" + ent.getKey(),
-                                                                          ent.getValue());
+                node.getOwnerDocument().getDocumentElement().setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+                                                                            "xmlns:" + ent.getKey(),
+                                                                            ent.getValue());
             }
 
         }
@@ -398,16 +409,21 @@ public final class CustomizationParser {
         Node cloneNode = ProcessorUtil.cloneNode(node.getOwnerDocument(), bindings, true);
         Node firstChild = DOMUtils.getChild(node, "jaxws:bindings");
         if (firstChild == null && cloneNode.getNodeName().indexOf("bindings") ==
-1) {
-            wsdlNode.setAttribute("xmlns:jaxws", ToolConstants.JAXWS_BINDINGS.getNamespaceURI());
-            Element jaxwsBindingElement = node.getOwnerDocument().createElement("jaxws:bindings");
+            wsdlNode.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+                                  "xmlns:jaxws", 
+                                  ToolConstants.JAXWS_BINDINGS.getNamespaceURI());
+            Element jaxwsBindingElement = node.getOwnerDocument()
+                    .createElementNS(ToolConstants.JAXWS_BINDINGS.getNamespaceURI(),
+                                     "jaxws:bindings");
             node.appendChild(jaxwsBindingElement);
             firstChild = jaxwsBindingElement;
         }
 
         if (firstChild == null && cloneNode.getNodeName().indexOf("bindings") >
-1) {
             firstChild = node;
-            if (wsdlNode.getAttributeNode("xmls:jaxws") == null) {
-                wsdlNode.setAttribute("xmlns:jaxws", ToolConstants.JAXWS_BINDINGS.getNamespaceURI());
+            if (wsdlNode.getAttributeNodeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "jaxws")
== null) {
+                wsdlNode.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+                                        "xmlns:jaxws", ToolConstants.JAXWS_BINDINGS.getNamespaceURI());
             }
         }
 
@@ -464,7 +480,9 @@ public final class CustomizationParser {
         Element root = null;
         try {
             URIResolver resolver = new URIResolver(bindingFile);
-            root = DOMUtils.readXml(resolver.getInputStream()).getDocumentElement();
+            XMLStreamReader reader = StaxUtils.createXMLStreamReader(resolver.getURI().toString(),

+                                                                     resolver.getInputStream());
+            root = StaxUtils.read(reader, true).getDocumentElement();
         } catch (Exception e1) {
             Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {bindingFile});
             throw new ToolException(msg, e1);
@@ -489,11 +507,11 @@ public final class CustomizationParser {
                     throw new ToolException(msg);
                 }
 
-                root.setAttribute("wsdlLocation", wsdlURI);
+                root.setAttributeNS(null, "wsdlLocation", wsdlURI);
             } else {
                 targetNode = wsdlNode;
 
-                root.setAttribute("wsdlLocation", wsdlURL);
+                root.setAttributeNS(null, "wsdlLocation", wsdlURL);
             }
             jaxwsBindingsMap.put(root, targetNode);
 
@@ -562,7 +580,7 @@ public final class CustomizationParser {
 
     private InputSource convertToTmpInputSource(Element ele, String schemaLoc) throws Exception
{
         InputSource result = null;
-        ele.setAttribute("schemaLocation", schemaLoc);
+        ele.setAttributeNS(null, "schemaLocation", schemaLoc);
         File tmpFile = FileUtils.createTempFile("jaxbbinding", ".xml");
         XMLUtils.writeTo(ele, new FileOutputStream(tmpFile));
         result = new InputSource(URIParserUtil.getAbsoluteURI(tmpFile.getAbsolutePath()));

Modified: cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java?rev=1356391&r1=1356390&r2=1356391&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java
Mon Jul  2 18:25:20 2012
@@ -181,7 +181,12 @@ public class JAXWSDefinitionBuilder exte
         reader.setFeature("javax.wsdl.verbose", false);
         reader.setExtensionRegistry(mgr.getExtensionRegistry());       
 
-        return reader.readWSDL(wsdlLocator);
+        Element el = eleMap.get(wsdlLocator.getBaseURI());
+        if (el == null) {
+            el = (Element)cusParser.getWSDLNode();
+        }
+
+        return reader.readWSDL(wsdlLocator, el);
     }
 
     public Definition getWSDLModel() {



Mime
View raw message