You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/06/28 17:47:23 UTC

svn commit: r551602 [4/4] - in /incubator/servicemix/trunk/tooling: ./ jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ jbi-maven-plugin/src/test/java/org/apache/servicemix/maven/plugin/jbi/ xfire-maven-plugin/src/main/java/org/ap...

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/test/java/org/apache/servicemix/maven/plugin/jbi/JbiServiceUnitDescriptorWriterTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/test/java/org/apache/servicemix/maven/plugin/jbi/JbiServiceUnitDescriptorWriterTest.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/test/java/org/apache/servicemix/maven/plugin/jbi/JbiServiceUnitDescriptorWriterTest.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/test/java/org/apache/servicemix/maven/plugin/jbi/JbiServiceUnitDescriptorWriterTest.java Thu Jun 28 08:47:21 2007
@@ -24,182 +24,180 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import junit.framework.TestCase;
-
-import org.apache.servicemix.common.packaging.Consumes;
-import org.apache.servicemix.common.packaging.Provides;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import junit.framework.TestCase;
+
+import org.apache.servicemix.common.packaging.Consumes;
+import org.apache.servicemix.common.packaging.Provides;
+
 public class JbiServiceUnitDescriptorWriterTest extends TestCase {
 
     private static final String ENCODING_UTF8 = "UTF-8";
+
     private static final String ENCODING_UTF16 = "UTF-16";
-	private static final String ENCODING_ISO88591 = "ISO-8859-1";
-    private static final String ENCODING_ISO88592 = "ISO-8859-2";
-	private static final String JBI_NAMESPACE = "http://java.sun.com/xml/ns/jbi";
-
-	//TODO: how to fetch the build directory ('./target') from Maven property?
-	private String generatedDescriptorLocation = "./target/test-outputs";
-
-	private File outputDir;
-
-	protected void setUp() throws Exception {
-		super.setUp();
-
-		this.outputDir = new File(generatedDescriptorLocation);
-		if (!this.outputDir.exists()) {
-			this.outputDir.mkdirs();
-		}
-	}
 
-    public void testUTF8EncodingWrite()
-            throws Exception {
+    //private static final String ENCODING_ISO88591 = "ISO-8859-1";
+
+    //private static final String ENCODING_ISO88592 = "ISO-8859-2";
+
+    private static final String JBI_NAMESPACE = "http://java.sun.com/xml/ns/jbi";
+
+    // TODO: how to fetch the build directory ('./target') from Maven property?
+    private String generatedDescriptorLocation = "./target/test-outputs";
+
+    private File outputDir;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        this.outputDir = new File(generatedDescriptorLocation);
+        if (!this.outputDir.exists()) {
+            this.outputDir.mkdirs();
+        }
+    }
+
+    public void testUTF8EncodingWrite() throws Exception {
         File descriptor = new File(outputDir, "jbi-su-UTF8.xml");
-        
+
         String xmlEncoding = ENCODING_UTF8;
         writeDescriptor(descriptor, xmlEncoding);
         verifyDescriptor(descriptor, xmlEncoding);
     }
 
-    public void testUTF16EncodingWrite()
-            throws Exception {
+    public void testUTF16EncodingWrite() throws Exception {
         File descriptor = new File(outputDir, "jbi-su-UTF16.xml");
-        
+
         String xmlEncoding = ENCODING_UTF16;
         writeDescriptor(descriptor, xmlEncoding);
         verifyDescriptor(descriptor, xmlEncoding);
     }
 
     /*
-    public void testISO88591EncodingWrite()
-            throws Exception {
-        File descriptor = new File(outputDir, "jbi-su-ISO88591.xml");
-        
-        String xmlEncoding = ENCODING_ISO88591;
-        writeDescriptor(descriptor, xmlEncoding);
-        verifyDescriptor(descriptor, xmlEncoding);
+     * public void testISO88591EncodingWrite() throws Exception { File
+     * descriptor = new File(outputDir, "jbi-su-ISO88591.xml");
+     * 
+     * String xmlEncoding = ENCODING_ISO88591; writeDescriptor(descriptor,
+     * xmlEncoding); verifyDescriptor(descriptor, xmlEncoding); }
+     * 
+     * public void testISO88592EncodingWrite() throws Exception { File
+     * descriptor = new File(outputDir, "jbi-su-ISO88592.xml");
+     * 
+     * String xmlEncoding = ENCODING_ISO88592; writeDescriptor(descriptor,
+     * xmlEncoding); verifyDescriptor(descriptor, xmlEncoding); }
+     */
+
+    private void writeDescriptor(File descriptor, 
+                                 String encoding) throws JbiPluginException {
+        List consumes = new ArrayList();
+        List provides = new ArrayList();
+
+        QName serviceName = new QName("http://test.com/encoding", "abcåäö");
+
+        Consumes newConsumes = new Consumes();
+        newConsumes.setServiceName(serviceName);
+        newConsumes.setEndpointName("consumeråäö");
+        consumes.add(newConsumes);
+
+        Provides newProvides = new Provides();
+        newProvides.setServiceName(serviceName);
+        newProvides.setEndpointName("provideråäö");
+        provides.add(newProvides);
+
+        JbiServiceUnitDescriptorWriter writer = new JbiServiceUnitDescriptorWriter(
+                encoding);
+        writer.write(descriptor, false, "name", "description", new ArrayList(),
+                consumes, provides);
     }
 
-    public void testISO88592EncodingWrite()
-            throws Exception {
-        File descriptor = new File(outputDir, "jbi-su-ISO88592.xml");
-        
-        String xmlEncoding = ENCODING_ISO88592;
-        writeDescriptor(descriptor, xmlEncoding);
-        verifyDescriptor(descriptor, xmlEncoding);
+    private void verifyDescriptor(File descriptor, 
+                                  String expectedXmlEncoding) throws Exception {
+        Document doc = getDocument(descriptor);
+        assertEquals(doc.getXmlEncoding(), expectedXmlEncoding);
+
+        Element serviceElement = getServicesElement(doc);
+
+        List consumes = getConsumes(serviceElement);
+        Consumes con = (Consumes) consumes.get(0);
+        assertEquals(con.getServiceName().getLocalPart(), "abcåäö");
+        assertEquals(con.getEndpointName(), "consumeråäö");
+
+        List provides = getProvides(serviceElement);
+        Provides prov = (Provides) provides.get(0);
+        assertEquals(prov.getServiceName().getLocalPart(), "abcåäö");
+        assertEquals(prov.getEndpointName(), "provideråäö");
     }
-    */
 
-	private void writeDescriptor(File descriptor, String encoding)
-			throws JbiPluginException {
-		List consumes = new ArrayList();
-		List provides = new ArrayList();
-
-		QName serviceName = new QName("http://test.com/encoding", "abcåäö");
-
-		Consumes newConsumes = new Consumes();
-		newConsumes.setServiceName(serviceName);
-		newConsumes.setEndpointName("consumeråäö");
-		consumes.add(newConsumes);
-
-		Provides newProvides = new Provides();
-		newProvides.setServiceName(serviceName);
-		newProvides.setEndpointName("provideråäö");
-		provides.add(newProvides);
-
-		JbiServiceUnitDescriptorWriter writer = new JbiServiceUnitDescriptorWriter(
-				encoding);
-		writer.write(descriptor, false, "name", "description", new ArrayList(), consumes,
-				provides);
-	}
-
-	private void verifyDescriptor(File descriptor, String expectedXmlEncoding) throws Exception {
-		Document doc = getDocument(descriptor);
-		assertEquals(doc.getXmlEncoding(), expectedXmlEncoding);
-
-		Element serviceElement = getServicesElement(doc);
-
-		List consumes = getConsumes(serviceElement);
-		Consumes con = (Consumes) consumes.get(0);
-		assertEquals(con.getServiceName().getLocalPart(), "abcåäö");
-		assertEquals(con.getEndpointName(), "consumeråäö");
-
-		List provides = getProvides(serviceElement);
-		Provides prov = (Provides) provides.get(0);
-		assertEquals(prov.getServiceName().getLocalPart(), "abcåäö");
-		assertEquals(prov.getEndpointName(), "provideråäö");
-	}
-
-	private Document getDocument(File jbiServicesFile) throws Exception {
-		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-		dbf.setNamespaceAware(true);
-		DocumentBuilder db = dbf.newDocumentBuilder();
-		Document doc = db.parse(jbiServicesFile);
-		
-		return doc;
-	}
-	
-	private Element getServicesElement(Document doc) throws Exception {
-		Node jbiNode = doc.getFirstChild();
-		assertTrue(XmlDescriptorHelper.isElement(jbiNode, JBI_NAMESPACE, "jbi"));
-		Node tmpNode = jbiNode.getFirstChild();
-		while (true) {
-			assertNotNull(tmpNode);
-			if (XmlDescriptorHelper.isElement(tmpNode, JBI_NAMESPACE,
-					"services")) {
-				return (Element) tmpNode;
-			} else {
-				tmpNode = tmpNode.getNextSibling();
-			}
-		}
-	}
-
-	private List getConsumes(Element servicesElement) throws Exception {
-		List consumes = new ArrayList();
-		NodeList children = servicesElement.getChildNodes();
-		for (int i = 0; i < children.getLength(); i++) {
-			if (children.item(i) instanceof Element) {
-				Element childElement = (Element) children.item(i);
-				if (XmlDescriptorHelper.isElement(childElement, JBI_NAMESPACE,
-						"consumes")) {
-					Consumes newConsumes = new Consumes();
-					newConsumes.setEndpointName(XmlDescriptorHelper
-							.getEndpointName(childElement));
-					newConsumes.setInterfaceName(XmlDescriptorHelper
-							.getInterfaceName(childElement));
-					newConsumes.setServiceName(XmlDescriptorHelper
-							.getServiceName(childElement));
-					consumes.add(newConsumes);
-				}
-			}
-		}
-		
-		return consumes;
-	}
-
-	private List getProvides(Element servicesElement) throws Exception {
-		List provides = new ArrayList();
-		NodeList children = servicesElement.getChildNodes();
-		for (int i = 0; i < children.getLength(); i++) {
-			if (children.item(i) instanceof Element) {
-				Element childElement = (Element) children.item(i);
-				if (XmlDescriptorHelper.isElement(childElement, JBI_NAMESPACE,
-						"provides")) {
-					Provides newProvides = new Provides();
-					newProvides.setEndpointName(XmlDescriptorHelper
-							.getEndpointName(childElement));
-					newProvides.setInterfaceName(XmlDescriptorHelper
-							.getInterfaceName(childElement));
-					newProvides.setServiceName(XmlDescriptorHelper
-							.getServiceName(childElement));
-					provides.add(newProvides);
-				}
-			}
-		}
-		
-		return provides;
-	}
+    private Document getDocument(File jbiServicesFile) throws Exception {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        Document doc = db.parse(jbiServicesFile);
+
+        return doc;
+    }
+
+    private Element getServicesElement(Document doc) throws Exception {
+        Node jbiNode = doc.getFirstChild();
+        assertTrue(XmlDescriptorHelper.isElement(jbiNode, JBI_NAMESPACE, "jbi"));
+        Node tmpNode = jbiNode.getFirstChild();
+        while (true) {
+            assertNotNull(tmpNode);
+            if (XmlDescriptorHelper.isElement(tmpNode, JBI_NAMESPACE,
+                    "services")) {
+                return (Element) tmpNode;
+            } else {
+                tmpNode = tmpNode.getNextSibling();
+            }
+        }
+    }
+
+    private List getConsumes(Element servicesElement) throws Exception {
+        List consumes = new ArrayList();
+        NodeList children = servicesElement.getChildNodes();
+        for (int i = 0; i < children.getLength(); i++) {
+            if (children.item(i) instanceof Element) {
+                Element childElement = (Element) children.item(i);
+                if (XmlDescriptorHelper.isElement(childElement, JBI_NAMESPACE,
+                        "consumes")) {
+                    Consumes newConsumes = new Consumes();
+                    newConsumes.setEndpointName(XmlDescriptorHelper
+                            .getEndpointName(childElement));
+                    newConsumes.setInterfaceName(XmlDescriptorHelper
+                            .getInterfaceName(childElement));
+                    newConsumes.setServiceName(XmlDescriptorHelper
+                            .getServiceName(childElement));
+                    consumes.add(newConsumes);
+                }
+            }
+        }
+
+        return consumes;
+    }
+
+    private List getProvides(Element servicesElement) throws Exception {
+        List provides = new ArrayList();
+        NodeList children = servicesElement.getChildNodes();
+        for (int i = 0; i < children.getLength(); i++) {
+            if (children.item(i) instanceof Element) {
+                Element childElement = (Element) children.item(i);
+                if (XmlDescriptorHelper.isElement(childElement, JBI_NAMESPACE,
+                        "provides")) {
+                    Provides newProvides = new Provides();
+                    newProvides.setEndpointName(XmlDescriptorHelper
+                            .getEndpointName(childElement));
+                    newProvides.setInterfaceName(XmlDescriptorHelper
+                            .getInterfaceName(childElement));
+                    newProvides.setServiceName(XmlDescriptorHelper
+                            .getServiceName(childElement));
+                    provides.add(newProvides);
+                }
+            }
+        }
+
+        return provides;
+    }
 }

Modified: incubator/servicemix/trunk/tooling/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/pom.xml?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/pom.xml (original)
+++ incubator/servicemix/trunk/tooling/pom.xml Thu Jun 28 08:47:21 2007
@@ -23,7 +23,7 @@
   
     <parent>
         <groupId>org.apache.servicemix</groupId>
-        <artifactId>servicemix</artifactId>
+        <artifactId>parent</artifactId>
         <version>3.2-incubating-SNAPSHOT</version>
     </parent>
     

Modified: incubator/servicemix/trunk/tooling/xfire-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/xfire/WsdlgenMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/xfire-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/xfire/WsdlgenMojo.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/xfire-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/xfire/WsdlgenMojo.java (original)
+++ incubator/servicemix/trunk/tooling/xfire-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/xfire/WsdlgenMojo.java Thu Jun 28 08:47:21 2007
@@ -1,7 +1,10 @@
 /*
- * Licensed 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
+ * 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
  *
@@ -13,29 +16,28 @@
  */
 package org.apache.servicemix.maven.plugin.xfire;
 
-import org.codehaus.xfire.gen.WsdlGenTask;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.model.Resource;
-import org.apache.maven.artifact.Artifact;
-import org.apache.tools.ant.Project;
 import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildEvent;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.Project;
+import org.codehaus.xfire.gen.WsdlGenTask;
 import org.codehaus.xfire.spring.XFireConfigLoader;
 
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.io.File;
-import java.net.URLClassLoader;
-import java.net.URL;
-import java.net.MalformedURLException;
-
 /**
  * WsdlGen mojo.
  * <p/>
@@ -47,9 +49,8 @@
  * @requiresProject
  * @requiresDependencyResolution
  */
-public class WsdlgenMojo
-    extends AbstractMojo
-{
+public class WsdlgenMojo extends AbstractMojo {
+    
     /**
      * Project.
      *
@@ -84,74 +85,78 @@
     private File basedir;
 
     /*
-    private PrintStream systemErr;
-    private PrintStream systemOut;
-    private final PrintStream mySystemErr = new PrintStream(new WsdlgenMojo.MyErrorStream());
-    private final PrintStream mySystemOut = new PrintStream(new WsdlgenMojo.MyOutputStream());
-
-    public void execute()
-        throws MojoExecutionException
-    {
-
-        systemErr = System.err;
-        systemOut = System.out;
-        System.setErr(mySystemErr);
-        // System.setOut(mySystemOut); // causes java.lang.OutOfMemoryError: Java heap space  on my box
-
-        try {
-            exec();
-        } finally {
-            System.setErr( systemErr );
-            // System.setOut( systemOut );
-        }
-    }
-
-    class MyErrorStream extends OutputStream {
-        private StringBuffer buffer = new StringBuffer();
-
-        public void write( final int b ) throws IOException {
-            final char c = (char) b;
-            // shouldn't we handle '\r' as well ??
-            if (c == '\n') {
-                getLog().error( buffer );
-                buffer = new StringBuffer();
-            } else {
-                buffer.append( c );
-            }
-        }
-    }
-
-    class MyOutputStream extends OutputStream {
-        private StringBuffer buffer = new StringBuffer();
-
-        public void write( final int b ) throws IOException {
-            final char c = (char) b;
-            // shouldn't we handle '\r' as well ??
-            if (c == '\n') {
-                getLog().info( buffer );
-                buffer = new StringBuffer();
-            } else {
-                buffer.append( c );
-            }
-        }
-    }
-*/
+     private PrintStream systemErr;
+     private PrintStream systemOut;
+     private final PrintStream mySystemErr = new PrintStream(new WsdlgenMojo.MyErrorStream());
+     private final PrintStream mySystemOut = new PrintStream(new WsdlgenMojo.MyOutputStream());
+
+     public void execute()
+     throws MojoExecutionException
+     {
+
+     systemErr = System.err;
+     systemOut = System.out;
+     System.setErr(mySystemErr);
+     // System.setOut(mySystemOut); // causes java.lang.OutOfMemoryError: Java heap space  on my box
+
+     try {
+     exec();
+     } finally {
+     System.setErr( systemErr );
+     // System.setOut( systemOut );
+     }
+     }
+
+     class MyErrorStream extends OutputStream {
+     private StringBuffer buffer = new StringBuffer();
+
+     public void write( final int b ) throws IOException {
+     final char c = (char) b;
+     // shouldn't we handle '\r' as well ??
+     if (c == '\n') {
+     getLog().error( buffer );
+     buffer = new StringBuffer();
+     } else {
+     buffer.append( c );
+     }
+     }
+     }
+
+     class MyOutputStream extends OutputStream {
+     private StringBuffer buffer = new StringBuffer();
+
+     public void write( final int b ) throws IOException {
+     final char c = (char) b;
+     // shouldn't we handle '\r' as well ??
+     if (c == '\n') {
+     getLog().info( buffer );
+     buffer = new StringBuffer();
+     } else {
+     buffer.append( c );
+     }
+     }
+     }
+     */
 
     public void execute() throws MojoExecutionException {
 
-        if ( configs == null )
-        {
+        if (configs == null) {
             configs = new ArrayList();
         }
 
-        if ( configs.size() == 0 )
-        {
-            configs.add( new File( basedir, "src/main/resources/META-INF/xfire/services.xml" ).getPath() );
+        if (configs.size() == 0) {
+            configs
+                    .add(new File(basedir,
+                            "src/main/resources/META-INF/xfire/services.xml")
+                            .getPath());
         }
 
-        if ( ! outputDirectory.exists() && ! outputDirectory.mkdirs() ) {
-           getLog().warn( "the output directory " + outputDirectory
-                   + " doesn't exist and couldn't be created. The goal with probably fail." );
+        if (!outputDirectory.exists() && !outputDirectory.mkdirs()) {
+            getLog()
+                    .warn(
+                            "the output directory "
+                                    + outputDirectory
+                                    + " doesn't exist and couldn't be created. The goal with probably fail.");
         }
 
         final Project antProject = new Project();
@@ -165,15 +170,15 @@
         try {
             Collection l = project.getArtifacts();
             List theurls = new ArrayList();
-            theurls.add(new File(project.getBuild().getOutputDirectory()).toURL());
-            int i = 0;
+            theurls.add(new File(project.getBuild().getOutputDirectory())
+                    .toURL());
             for (Iterator iterator = l.iterator(); iterator.hasNext();) {
                 Artifact dep = (Artifact) iterator.next();
                 theurls.add(dep.getFile().toURL());
             }
             urls = (URL[]) theurls.toArray(new URL[theurls.size()]);
 
-            getLog().debug( "classloader classpath: " + theurls );
+            getLog().debug("classloader classpath: " + theurls);
 
         } catch (MalformedURLException e) {
             throw new IllegalStateException(e);
@@ -189,77 +194,70 @@
 
         final WsdlGenTask task = new WsdlGenTask();
 
-        task.setProject( antProject );
+        task.setProject(antProject);
 
-        task.setOutputDirectory( outputDirectory.getAbsolutePath() );
+        task.setOutputDirectory(outputDirectory.getAbsolutePath());
 
         for (Iterator iterator = configs.iterator(); iterator.hasNext();) {
             String configUrl = (String) iterator.next();
 
             // required for multi-modules projects
-            if ( ! new File( configUrl ).exists() ) {
-                getLog().warn( "configUrl not found. Task will perhaps fail" ); 
+            if (!new File(configUrl).exists()) {
+                getLog().warn("configUrl not found. Task will perhaps fail");
             }
 
-            task.setConfigUrl( configUrl );
+            task.setConfigUrl(configUrl);
 
-            getLog().info( "Executing XFire WsdlGen task for configUrl: " + configUrl );
+            getLog().info(
+                    "Executing XFire WsdlGen task for configUrl: " + configUrl);
 
-            try
-            {
+            try {
                 task.execute();
-            }
-            catch ( BuildException e )
-            {
-                throw new MojoExecutionException( "command execution failed", e );
+            } catch (BuildException e) {
+                throw new MojoExecutionException("command execution failed", e);
             }
 
-            getLog().debug( "generated " + task.getGeneratedFile());
+            getLog().debug("generated " + task.getGeneratedFile());
         }
         Thread.currentThread().setContextClassLoader(oldCl);
 
-        getLog().debug( "Adding outputDirectory as Project's resource.");
+        getLog().debug("Adding outputDirectory as Project's resource.");
         Resource resource = new Resource();
         resource.setDirectory(outputDirectory.getAbsolutePath());
         project.addResource(resource);
     }
-/*
-    void displayClasspath(URLClassLoader cl, String message)
-    {
- 	URL[] urls = cl.getURLs();
- 	for (int i = 0; i < urls.length; i++) {
- 	    URL urL = urls[i];
- 	    getLog().info("URL " + i + ":" +  urL);
- 	}
-    }
-*/
-    private void displayClasspath(ClassLoader classLoader, String message)
-    {
-        getLog().info("------ " + message + ":" +  classLoader);
-        if (classLoader == null)
-        {
+
+    /*
+     void displayClasspath(URLClassLoader cl, String message)
+     {
+     URL[] urls = cl.getURLs();
+     for (int i = 0; i < urls.length; i++) {
+     URL urL = urls[i];
+     getLog().info("URL " + i + ":" +  urL);
+     }
+     }
+     */
+    private void displayClasspath(ClassLoader classLoader, String message) {
+        getLog().info("------ " + message + ":" + classLoader);
+        if (classLoader == null) {
             return;
         }
-        if ( classLoader instanceof URLClassLoader )
-        {
+        if (classLoader instanceof URLClassLoader) {
             URLClassLoader cl = (URLClassLoader) classLoader;
             URL[] urls = cl.getURLs();
             for (int i = 0; i < urls.length; i++) {
                 URL urL = urls[i];
-                getLog().info("URL " + i + ":" +  urL);
+                getLog().info("URL " + i + ":" + urL);
             }
-        }
-        else if ( classLoader instanceof AntClassLoader)
-        {
-            AntClassLoader cl = (AntClassLoader) XFireConfigLoader.class.getClassLoader();
+        } else if (classLoader instanceof AntClassLoader) {
+            AntClassLoader cl = (AntClassLoader) XFireConfigLoader.class
+                    .getClassLoader();
             String[] urls = cl.getClasspath().split(File.pathSeparator);
-            for (int i = 0; i < urls.length; i++)
-            {
+            for (int i = 0; i < urls.length; i++) {
                 String url = urls[i];
-                getLog().info("URL " + i + ":" +  url);
+                getLog().info("URL " + i + ":" + url);
             }
-        } else
-        {
+        } else {
             // not handled
         }
         displayClasspath(classLoader.getParent(), "parent->" + message);
@@ -267,40 +265,40 @@
 
     void load(String className, ClassLoader cl) {
         try {
-          Class c = Class.forName(className, true, cl);
-          getLog().debug(c.toString());
+            Class c = Class.forName(className, true, cl);
+            getLog().debug(c.toString());
         } catch (Exception e) {
-          displayClasspath(cl, "using classpath");
-          getLog().error(e);
+            displayClasspath(cl, "using classpath");
+            getLog().error(e);
         }
     }
 
     private class DebugAntBuildListener implements BuildListener {
-        public void buildStarted( final BuildEvent buildEvent ) {
+        public void buildStarted(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void buildFinished( final BuildEvent buildEvent ) {
+        public void buildFinished(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void targetStarted( final BuildEvent buildEvent ) {
+        public void targetStarted(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void targetFinished( final BuildEvent buildEvent ) {
+        public void targetFinished(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void taskStarted( final BuildEvent buildEvent ) {
+        public void taskStarted(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void taskFinished( final BuildEvent buildEvent ) {
+        public void taskFinished(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void messageLogged( final BuildEvent buildEvent ) {
+        public void messageLogged(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
     }

Modified: incubator/servicemix/trunk/tooling/xfire-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/xfire/WsgenMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/xfire-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/xfire/WsgenMojo.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/xfire-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/xfire/WsgenMojo.java (original)
+++ incubator/servicemix/trunk/tooling/xfire-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/xfire/WsgenMojo.java Thu Jun 28 08:47:21 2007
@@ -1,7 +1,10 @@
 /*
- * Licensed 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
+ * 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
  *
@@ -13,25 +16,25 @@
  */
 package org.apache.servicemix.maven.plugin.xfire;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
+import org.apache.tools.ant.BuildEvent;
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
 import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.BuildEvent;
-
+import org.apache.tools.ant.Project;
 import org.codehaus.xfire.gen.WsGenTask;
 
-import java.io.*;
-import java.util.Iterator;
-import java.util.List;
-
 /**
- * WsGen mojo.
- * <p/>
- * Implemented as a wrapper around the XFire WsGen Ant task.
- *
+ * WsGen mojo. <p/> Implemented as a wrapper around the XFire WsGen Ant task.
+ * 
  * @author <a href="jerome@coffeebreaks.org">Jerome Lacoste</a>
  * @version $Id$
  * @goal wsgen
@@ -39,12 +42,11 @@
  * @requiresProject
  * @requiresDependencyResolution
  */
-public class WsgenMojo
-    extends AbstractMojo
-{
+public class WsgenMojo extends AbstractMojo {
+
     /**
      * Project.
-     *
+     * 
      * @parameter expression="${project}"
      * @required
      * @readonly
@@ -53,7 +55,7 @@
 
     /**
      * URLs
-     *
+     * 
      * @parameter
      * @required
      */
@@ -62,7 +64,7 @@
     /**
      * @parameter expression="${package}" alias="package"
      */
-    private String _package; // reserved keyword...
+    private String thePackage; // reserved keyword...
 
     /**
      * @parameter expression="${profile}"
@@ -76,29 +78,33 @@
 
     /**
      * Will be added to the compileSourceRoot
-     * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources/xfire/wsgen"
+     * 
+     * @parameter expression="${outputDirectory}"
+     *            default-value="${project.build.directory}/generated-sources/xfire/wsgen"
      * @required
      */
     private File outputDirectory;
 
     private PrintStream systemErr;
-    private PrintStream systemOut;
+
+    //private PrintStream systemOut;
+
     private final PrintStream mySystemErr = new PrintStream(new MyErrorStream());
-    private final PrintStream mySystemOut = new PrintStream(new MyOutputStream());
 
-    public void execute()
-        throws MojoExecutionException
-    {
+    //private final PrintStream mySystemOut = new PrintStream(new MyOutputStream());
+
+    public void execute() throws MojoExecutionException {
 
         systemErr = System.err;
-        systemOut = System.out;
+        //systemOut = System.out;
         System.setErr(mySystemErr);
-        // System.setOut(mySystemOut); // causes java.lang.OutOfMemoryError: Java heap space  on my box
+        // System.setOut(mySystemOut); // causes java.lang.OutOfMemoryError:
+        // Java heap space on my box
 
         try {
             exec();
         } finally {
-            System.setErr( systemErr );
+            System.setErr(systemErr);
             // System.setOut( systemOut );
         }
     }
@@ -106,14 +112,14 @@
     class MyErrorStream extends OutputStream {
         private StringBuffer buffer = new StringBuffer();
 
-        public void write( final int b ) throws IOException {
+        public void write(final int b) throws IOException {
             final char c = (char) b;
             // shouldn't we handle '\r' as well ??
             if (c == '\n') {
-                getLog().error( buffer );
+                getLog().error(buffer);
                 buffer = new StringBuffer();
             } else {
-                buffer.append( c );
+                buffer.append(c);
             }
         }
     }
@@ -121,27 +127,30 @@
     class MyOutputStream extends OutputStream {
         private StringBuffer buffer = new StringBuffer();
 
-        public void write( final int b ) throws IOException {
+        public void write(final int b) throws IOException {
             final char c = (char) b;
             // shouldn't we handle '\r' as well ??
             if (c == '\n') {
-                getLog().info( buffer );
+                getLog().info(buffer);
                 buffer = new StringBuffer();
             } else {
-                buffer.append( c );
+                buffer.append(c);
             }
         }
     }
 
     private void exec() throws MojoExecutionException {
 
-        if ( wsdls.size() == 0 ) {
+        if (wsdls.size() == 0) {
             return;
         }
 
-        if ( ! outputDirectory.exists() && ! outputDirectory.mkdirs() ) {
-           getLog().warn( "the output directory " + outputDirectory
-                   + " doesn't exist and couldn't be created. The goal with probably fail." );
+        if (!outputDirectory.exists() && !outputDirectory.mkdirs()) {
+            getLog()
+                    .warn(
+                            "the output directory "
+                                    + outputDirectory
+                                    + " doesn't exist and couldn't be created. The goal with probably fail.");
         }
 
         final Project antProject = new Project();
@@ -150,74 +159,72 @@
 
         final WsGenTask task = new WsGenTask();
 
-        task.setProject( antProject );
+        task.setProject(antProject);
 
-        if ( binding != null) {
-            task.setBinding( binding );
+        if (binding != null) {
+            task.setBinding(binding);
         }
 
-        if ( profile != null) {
-            task.setProfile( profile );
+        if (profile != null) {
+            task.setProfile(profile);
         }
 
-        if ( _package != null) {
-            task.setPackage( _package );
+        if (thePackage != null) {
+            task.setPackage(thePackage);
         }
 
-        task.setOutputDirectory( outputDirectory.getAbsolutePath() );
+        task.setOutputDirectory(outputDirectory.getAbsolutePath());
 
         for (Iterator iterator = wsdls.iterator(); iterator.hasNext();) {
             String wsdlUrl = (String) iterator.next();
 
-            if ( ! wsdlUrl.contains("://") ) {
-                wsdlUrl = new File( wsdlUrl ).toURI().toString();
+            if (!wsdlUrl.contains("://")) {
+                wsdlUrl = new File(wsdlUrl).toURI().toString();
             }
 
-            task.setWsdl( wsdlUrl );
+            task.setWsdl(wsdlUrl);
 
-            getLog().info( "Executing XFire WsGen task with url: " + wsdlUrl );
+            getLog().info("Executing XFire WsGen task with url: " + wsdlUrl);
 
-            try
-            {
+            try {
                 task.execute();
-            }
-            catch ( BuildException e )
-            {
-                throw new MojoExecutionException( "command execution failed", e );
+            } catch (BuildException e) {
+                throw new MojoExecutionException("command execution failed", e);
             }
         }
 
-        getLog().debug( "Adding outputDirectory to source root: " + outputDirectory );
+        getLog().debug(
+                "Adding outputDirectory to source root: " + outputDirectory);
 
-        this.project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
+        this.project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
     }
 
     private class DebugAntBuildListener implements BuildListener {
-        public void buildStarted( final BuildEvent buildEvent ) {
+        public void buildStarted(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void buildFinished( final BuildEvent buildEvent ) {
+        public void buildFinished(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void targetStarted( final BuildEvent buildEvent ) {
+        public void targetStarted(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void targetFinished( final BuildEvent buildEvent ) {
+        public void targetFinished(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void taskStarted( final BuildEvent buildEvent ) {
+        public void taskStarted(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void taskFinished( final BuildEvent buildEvent ) {
+        public void taskFinished(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
 
-        public void messageLogged( final BuildEvent buildEvent ) {
+        public void messageLogged(final BuildEvent buildEvent) {
             getLog().debug(buildEvent.getMessage());
         }
     }