[jbossws-commits] JBossWS SVN: r14136 - common-tools and 25 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Apr 18 07:04:21 EDT 2011


Author: richard.opalka at jboss.com
Date: 2011-04-18 07:04:20 -0400 (Mon, 18 Apr 2011)
New Revision: 14136

Added:
   common-tools/
   common-tools/pom.xml
   common-tools/src/
   common-tools/src/main/
   common-tools/src/main/java/
   common-tools/src/main/java/org/
   common-tools/src/main/java/org/jboss/
   common-tools/src/main/java/org/jboss/ws/
   common-tools/src/main/java/org/jboss/ws/tools/
   common-tools/src/main/java/org/jboss/ws/tools/ant/
   common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseClasspathTask.java
   common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseJUnitTestsTask.java
   common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseProjectTask.java
   common-tools/src/main/java/org/jboss/ws/tools/ant/FixPathTask.java
   common-tools/src/main/java/org/jboss/ws/tools/ant/InstallModulesTask.java
   common-tools/src/main/java/org/jboss/ws/tools/ant/PathWriterTask.java
   common-tools/src/main/java/org/jboss/wsf/
   common-tools/src/main/java/org/jboss/wsf/spi/
   common-tools/src/main/java/org/jboss/wsf/spi/tools/
   common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/
   common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/AntTaskHelper.java
   common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java
   common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java
   common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java
   common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/
   common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java
   common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java
   common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java
   common-tools/src/main/java/org/jboss/wsf/spi/util/
   common-tools/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java
   common-tools/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java
   common-tools/src/test/
   common-tools/src/test/java/
   common-tools/src/test/java/org/
   common-tools/src/test/java/org/jboss/
   common-tools/src/test/java/org/jboss/test/
   common-tools/src/test/java/org/jboss/test/wsf/
   common-tools/src/test/java/org/jboss/test/wsf/spi/
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java
   common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java
   common-tools/src/test/resources/
   common-tools/src/test/resources/smoke/
   common-tools/src/test/resources/smoke/tools/
   common-tools/src/test/resources/smoke/tools/consume-test.xml
   common-tools/src/test/resources/smoke/tools/provide-test.xml
Log:
[JBWS-3273] introducing new SVN module for JBossWS ANT & CMD line tools - jbossws-tools

Added: common-tools/pom.xml
===================================================================
--- common-tools/pom.xml	                        (rev 0)
+++ common-tools/pom.xml	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <name>JBoss Web Services - Tools Integration</name>
+  <groupId>org.jboss.ws</groupId>
+  <artifactId>jbossws-common-tools</artifactId>
+  <packaging>jar</packaging>
+  <description>JBossWS Common Tools</description>
+
+  <version>1.0.0-SNAPSHOT</version>
+
+  <parent>
+    <groupId>org.jboss.ws</groupId>
+    <artifactId>jbossws-parent</artifactId>
+    <version>1.0.10-SNAPSHOT</version>
+  </parent>
+
+  <scm>
+    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossws/tools/trunk</connection>
+    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossws/tools/trunk</developerConnection>
+    <url>http://fisheye.jboss.com/viewrep/JBossWS/tools/trunk</url>
+  </scm>
+
+  <properties>
+    <jbossws.spi.version>2.0.0-SNAPSHOT</jbossws.spi.version>
+    <ant.version>1.7.1</ant.version>
+    <getopt.version>1.0.13</getopt.version>
+    <junit.version>3.8.2</junit.version>
+    <log4j.version>1.2.14</log4j.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.ant</groupId>
+      <artifactId>ant</artifactId>
+      <version>${ant.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.ws</groupId>
+      <artifactId>jbossws-spi</artifactId>
+      <version>${jbossws.spi.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>gnu-getopt</groupId>
+      <artifactId>getopt</artifactId>
+      <version>${getopt.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>${log4j.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit.version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Added: common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseClasspathTask.java
===================================================================
--- common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseClasspathTask.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseClasspathTask.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.ant;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * An Ant task creating a simple Eclipse .classpath file using the provided
+ * Ant's path id.
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 15-Feb-2008
+ */
+public class EclipseClasspathTask extends Task
+{
+   private String pathId;
+   private String excludesFile;
+   private String outputFile;
+   private String srcPath; 
+   private String srcOutput;
+
+   @Override
+   public void execute() throws BuildException
+   {
+      Project project = getProject();
+      Path path = (Path)project.getReference(pathId);
+      String[] pathElements = path.list();
+      try
+      {
+         List<String> excludes = getExcludes();
+         StringBuffer sb = new StringBuffer();
+         generateContent(sb, excludes, pathElements);
+         File file = outputFile != null ? new File(outputFile) : new File(getProject().getBaseDir(), ".classpath");
+         BufferedWriter out = new BufferedWriter(new FileWriter(file));
+         out.write(sb.toString());
+         out.close();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         throw new BuildException(e);
+      }
+   }
+
+   private void generateContent(StringBuffer sb, List<String> excludes, String[] libs)
+   {
+      sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+      sb.append("<classpath>\n");
+      sb.append("<classpathentry ");
+      if (excludes != null && !excludes.isEmpty())
+      {
+         sb.append("excluding=\"");
+         for (Iterator<String> it = excludes.iterator(); it.hasNext();)
+         {
+            sb.append(it.next());
+            if (it.hasNext())
+               sb.append("|");
+         }
+         sb.append("\" ");
+      }
+      sb.append("kind=\"src\" ");
+      if (srcOutput != null)
+      {
+         sb.append("output=\"");
+         sb.append(srcOutput);
+         sb.append("\" ");
+      }
+      if (srcPath != null)
+      {
+         sb.append("path=\"");
+         sb.append(srcPath);
+         sb.append("\" ");
+      }
+      sb.append("/>\n");
+      sb.append("<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n");
+      for (int i = 0; i < libs.length; i++)
+      {
+         if (new File(libs[i]).exists() && libs[i].endsWith(".jar")) //jar files only can be used as lib entry
+         {
+            sb.append("<classpathentry kind=\"lib\" path=\"");
+            sb.append(absoluteToRelativePath(libs[i]));
+            sb.append("\"/>\n");
+         }
+      }
+      sb.append("<classpathentry kind=\"output\" path=\"bin\"/>\n");
+      sb.append("</classpath>");
+   }
+
+   private List<String> getExcludes() throws IOException
+   {
+      List<String> excludes = new LinkedList<String>();
+      if (excludesFile != null)
+      {
+         BufferedReader in = null;
+         try
+         {
+            in = new BufferedReader(new FileReader(excludesFile));
+            String str;
+            while ((str = in.readLine()) != null)
+            {
+               if (str.length() > 0 && !str.startsWith("#"))
+                  excludes.add(str);
+            }
+         }
+         finally
+         {
+            if (in != null)
+               in.close();
+         }
+      }
+      return excludes;
+   }
+
+   private String absoluteToRelativePath(String absolutePath)
+   {
+      String baseDir = getProject().getBaseDir().toString();
+      String result = absolutePath;
+      if (absolutePath.startsWith(baseDir))
+      {
+         result = absolutePath.substring(baseDir.length());
+         if (result.startsWith("\\") || result.startsWith("/"))
+            result = result.substring(1);
+      }
+      return result;
+   }
+
+   public void setPathId(String pathId)
+   {
+      this.pathId = pathId;
+   }
+
+   public void setExcludesFile(String excludesFile)
+   {
+      this.excludesFile = excludesFile;
+   }
+
+   public void setOutputFile(String outputFile)
+   {
+      this.outputFile = outputFile;
+   }
+
+   public void setSrcPath(String srcPath)
+   {
+      this.srcPath = srcPath;
+   }
+
+   public void setSrcOutput(String srcOutput)
+   {
+      this.srcOutput = srcOutput;
+   }
+
+}

Added: common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseJUnitTestsTask.java
===================================================================
--- common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseJUnitTestsTask.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseJUnitTestsTask.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,266 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.ant;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+
+/**
+ * An Ant task creating Eclipse's launch configuration files for the JUnit tests
+ * of the test-suite.
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 18-Feb-2008
+ */
+public class EclipseJUnitTestsTask extends Task
+{
+   private String projectName;
+   private String projectWorkingDir; // the Eclipse project working dir, i.e. the output dir
+   private String testResourcesDir; //the dir containing the resources files
+   private String testLibsDir; //the dir containing the libs files
+   private String srcDir; // the tests src dir
+   private String integrationTarget;
+   private String jbossHome;
+   private String endorsedDir;
+   private String namingProviderUrl;
+   private String securityPolicy;
+   private FileSet fileset;
+
+   @Override
+   public void execute() throws BuildException
+   {
+      try
+      {
+         DirectoryScanner dsc = fileset.getDirectoryScanner(getProject());
+         String[] classes = dsc.getIncludedFiles();
+         for (int i = 0; i < classes.length; i++)
+         {
+            String clazz = classes[i];
+            File file = new File(getProject().getBaseDir(), pathToClassName(clazz) + ".launch");
+            BufferedWriter out = new BufferedWriter(new FileWriter(file));
+            out.write(getSingleTestConf(clazz).toString());
+            out.close();
+         }
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         throw new BuildException(e);
+      }
+   }
+
+   public FileSet createFileset()
+   {
+      this.fileset = new FileSet();
+      return fileset;
+   }
+
+   private static String pathToFullClassName(String path)
+   {
+      // remove ".class" and replace slashes and backslashes with a dot
+      return path.substring(0, path.length() - 6).replaceAll("\\\\", ".").replaceAll("/", ".");
+   }
+
+   private static String pathToClassName(String path)
+   {
+      String fullClassName = pathToFullClassName(path);
+      return fullClassName.substring(fullClassName.lastIndexOf(".") + 1);
+   }
+
+   private LaunchConfiguration getSingleTestConf(String clazz)
+   {
+      LaunchConfiguration conf = new LaunchConfiguration();
+      conf.addEntryToListAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_PATHS", "/" + projectName + "/" + absoluteToRelativePath(srcDir) + "/"
+            + clazz.substring(0, clazz.length() - 6) + ".java");
+      conf.addEntryToListAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES", "1");
+      conf.putBooleanAttribute("org.eclipse.debug.core.appendEnvironmentVariables", true);
+      conf.putBooleanAttribute("org.eclipse.jdt.junit.KEEPRUNNING_ATTR", false);
+      conf.putStringAttribute("org.eclipse.jdt.junit.CONTAINER", "");
+      conf.putStringAttribute("org.eclipse.jdt.junit.TESTNAME", "");
+      conf.putStringAttribute("org.eclipse.jdt.junit.TEST_KIND", "org.eclipse.jdt.junit.loader.junit3");
+      conf.putStringAttribute("org.eclipse.jdt.launching.MAIN_TYPE", pathToFullClassName(clazz));
+      conf.putStringAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", projectName);
+      // computing the userDir; please note we get the relative path since we use the Eclipse $workspace_loc variable
+      String userDir = "${workspace_loc:" + projectName + "}/" + absoluteToRelativePath(projectWorkingDir);
+      String resourcesDir = "${workspace_loc:" + projectName + "}/" + absoluteToRelativePath(testResourcesDir);
+      String libsDir = "${workspace_loc:" + projectName + "}/" + absoluteToRelativePath(testLibsDir);
+      conf.putStringAttribute("org.eclipse.jdt.launching.VM_ARGUMENTS", getVMArguments(userDir, resourcesDir, libsDir));
+      conf.putStringAttribute("org.eclipse.jdt.launching.WORKING_DIRECTORY", userDir);
+      return conf;
+   }
+
+   private String getVMArguments(String userDir, String resourcesDir, String libsDir)
+   {
+      StringBuffer sb = new StringBuffer();
+      sb.append("-Djbossws.integration.target=").append(integrationTarget);
+      sb.append("&#10;-ea&#10;");
+      sb.append("-Dtest.execution.dir=").append(userDir);
+      sb.append("&#10;-Djava.endorsed.dirs=").append(endorsedDir);
+      sb.append("&#10;");
+      sb.append("-Djava.naming.provider.url=").append(namingProviderUrl);
+      sb.append("&#10;-Djava.protocol.handler.pkgs=org.jboss.virtual.protocol&#10;");
+      sb.append("-Djava.security.policy=").append(absoluteToRelativePath(securityPolicy));
+      sb.append("&#10;-Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory&#10;");
+      sb.append("-Duser.dir=").append(userDir);
+      sb.append("&#10;-Djboss.home=").append(jbossHome);
+      sb.append("&#10;-Djdk.home=${env_var:JAVA_HOME}");
+      sb.append("&#10;-Dtest.archive.directory=").append(libsDir);
+      sb.append("&#10;-Dtest.resources.directory=").append(resourcesDir);
+      sb.append("&#10;-Dbinary.distribution=true");
+      return sb.toString();
+   }
+
+   private String absoluteToRelativePath(String absolutePath)
+   {
+      String baseDir = getProject().getBaseDir().toString();
+      if (!absolutePath.startsWith(baseDir))
+         throw new IllegalArgumentException("The provided absolute path is outside the current basedir: " + baseDir);
+      return absolutePath.substring(baseDir.length() + 1);
+   }
+
+   public void setSrcDir(String srcDir)
+   {
+      this.srcDir = srcDir;
+   }
+
+   public void setProjectName(String projectName)
+   {
+      this.projectName = projectName;
+   }
+
+   public void setProjectWorkingDir(String projectWorkingDir)
+   {
+      this.projectWorkingDir = projectWorkingDir;
+   }
+
+   public void setIntegrationTarget(String integrationTarget)
+   {
+      this.integrationTarget = integrationTarget;
+   }
+
+   public void setJbossHome(String jbossHome)
+   {
+      this.jbossHome = jbossHome;
+   }
+
+   public void setNamingProviderUrl(String namingProviderUrl)
+   {
+      this.namingProviderUrl = namingProviderUrl;
+   }
+
+   public void setSecurityPolicy(String securityPolicy)
+   {
+      this.securityPolicy = securityPolicy;
+   }
+
+   public void setEndorsedDir(String endorsedDir)
+   {
+      this.endorsedDir = endorsedDir;
+   }
+
+   public void setTestResourcesDir(String testResourcesDir)
+   {
+      this.testResourcesDir = testResourcesDir;
+   }
+
+   public void setTestLibsDir(String testLibsDir)
+   {
+      this.testLibsDir = testLibsDir;
+   }
+
+   private class LaunchConfiguration
+   {
+      private Map<String, String> booleanAttributes = new LinkedHashMap<String, String>();
+      private Map<String, String> stringAttributes = new LinkedHashMap<String, String>();
+      private Map<String, List<String>> listAttributes = new LinkedHashMap<String, List<String>>();
+
+      public String toString()
+      {
+         StringBuffer sb = new StringBuffer();
+         sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+         sb.append("<launchConfiguration type=\"org.eclipse.jdt.junit.launchconfig\">\n");
+         for (String key : listAttributes.keySet())
+         {
+            sb.append("<listAttribute key=\"").append(key).append("\">\n");
+            for (String value : listAttributes.get(key))
+            {
+               sb.append("<listEntry value=\"").append(value).append("\"/>\n");
+            }
+            sb.append("</listAttribute>\n");
+         }
+         for (String key : booleanAttributes.keySet())
+         {
+            sb.append("<booleanAttribute key=\"").append(key);
+            sb.append("\" value=\"").append(booleanAttributes.get(key)).append("\"/>\n");
+         }
+         for (String key : stringAttributes.keySet())
+         {
+            sb.append("<stringAttribute key=\"").append(key);
+            sb.append("\" value=\"").append(stringAttributes.get(key)).append("\"/>\n");
+         }
+         sb.append("</launchConfiguration>");
+         return sb.toString();
+      }
+
+      public Map<String, String> getBooleanAttributes()
+      {
+         return booleanAttributes;
+      }
+
+      public void putBooleanAttribute(String name, boolean value)
+      {
+         this.booleanAttributes.put(name, String.valueOf(value));
+      }
+
+      public Map<String, String> getStringAttributes()
+      {
+         return stringAttributes;
+      }
+
+      public void putStringAttribute(String name, String value)
+      {
+         this.stringAttributes.put(name, value);
+      }
+
+      public Map<String, List<String>> getListAttributes()
+      {
+         return listAttributes;
+      }
+
+      public void addEntryToListAttribute(String attribute, String entryValue)
+      {
+         if (!listAttributes.containsKey(attribute))
+            listAttributes.put(attribute, new LinkedList<String>());
+         listAttributes.get(attribute).add(entryValue);
+      }
+   }
+}

Added: common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseProjectTask.java
===================================================================
--- common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseProjectTask.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/ws/tools/ant/EclipseProjectTask.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.ant;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * An Ant task creating a simple Eclipse .project file using the provided project name.
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 18-Feb-2008
+ */
+public class EclipseProjectTask extends Task
+{
+   private String projectName;
+   private String outputFile;
+
+   @Override
+   public void execute() throws BuildException
+   {
+      try
+      {
+         StringBuffer sb = new StringBuffer();
+         generateContent(sb);
+         File file;
+         if (outputFile != null)
+            file = new File(outputFile);
+         else
+            file = new File(getProject().getBaseDir(), ".project");
+         BufferedWriter out = new BufferedWriter(new FileWriter(file));
+         out.write(sb.toString());
+         out.close();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         throw new BuildException(e);
+      }
+   }
+   
+   private void generateContent(StringBuffer sb)
+   {
+      sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+      sb.append("<projectDescription>\n   <name>");
+      sb.append(projectName);
+      sb.append("</name>\n" +
+            "   <comment></comment>\n" +
+            "   <projects>\n" +
+            "   </projects>\n" +
+            "   <buildSpec>\n" +
+            "      <buildCommand>\n" +
+            "         <name>org.eclipse.jdt.core.javabuilder</name>\n" +
+            "         <arguments>\n" +
+            "         </arguments>\n" +
+            "      </buildCommand>\n" +
+            "   </buildSpec>\n" +
+            "   <natures>\n" +
+            "      <nature>org.eclipse.jdt.core.javanature</nature>\n" +
+            "   </natures>\n" +
+            "</projectDescription>");
+   }
+
+   public void setProjectName(String projectName)
+   {
+      this.projectName = projectName;
+   }
+
+   public void setOutputFile(String outputFile)
+   {
+      this.outputFile = outputFile;
+   }
+}

Added: common-tools/src/main/java/org/jboss/ws/tools/ant/FixPathTask.java
===================================================================
--- common-tools/src/main/java/org/jboss/ws/tools/ant/FixPathTask.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/ws/tools/ant/FixPathTask.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class FixPathTask extends Task
+{
+   private String propertyName;
+
+   @Override
+   public void execute() throws BuildException
+   {
+      String path = getProject().getProperty(propertyName);
+
+      if (path != null)
+      {
+         getProject().setProperty(propertyName, path.replace('\\', '/'));
+      }
+   }
+
+   public void setProperty(String propertyName)
+   {
+      this.propertyName = propertyName;
+   }
+}

Added: common-tools/src/main/java/org/jboss/ws/tools/ant/InstallModulesTask.java
===================================================================
--- common-tools/src/main/java/org/jboss/ws/tools/ant/InstallModulesTask.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/ws/tools/ant/InstallModulesTask.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.ant;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+
+/**
+ * An Ant task for installing AS7 module.xml files; reads the contents of the provided
+ * module.xml files, computes the module path from their full paths, updates the contents
+ * with the resource libs found at the corresponding module in the target dir location
+ * and finally write the destination module.xml files in the target module dir.
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 03-Feb-2011
+ *
+ */
+public class InstallModulesTask extends Task
+{
+   private String targetDir; //the target directory where modules are installed
+   private FileSet fileset; //the fileset of module.xml files to be processed 
+
+   @Override
+   public void execute() throws BuildException
+   {
+      try
+      {
+         DirectoryScanner dsc = fileset.getDirectoryScanner(getProject());
+         File baseDir = dsc.getBasedir();
+         String[] files = dsc.getIncludedFiles();
+         for (int i = 0; i < files.length; i++)
+         {
+            String currentFile = files[i];
+            File moduleXml = new File(baseDir, currentFile);
+            String modulePath = currentFile.substring(0, currentFile.lastIndexOf(File.separator));
+            File libDir = new File(targetDir, modulePath);
+            File destFile = new File(targetDir, currentFile);
+            System.out.println("Processing descriptor for module " + modulePath);
+            System.out.println("* Source module descriptor: " + moduleXml);
+            System.out.println("* Destination module descriptor: " + destFile);
+            String c = readFileContents(moduleXml);
+            if (libDir.exists())
+            {
+               String[] libs = libDir.list(new FilenameFilter()
+               {
+                  @Override
+                  public boolean accept(File dir, String name)
+                  {
+                     return name.endsWith(".jar") || name.endsWith(".ear") || name.endsWith(".sar")
+                           || name.endsWith(".war");
+                  }
+               });
+               BufferedWriter out = new BufferedWriter(new FileWriter(destFile));
+               out.write(updateContents(c, libs));
+               out.close();
+            }
+            else
+            {
+               libDir.mkdirs();
+               BufferedWriter out = new BufferedWriter(new FileWriter(destFile));
+               out.write(c);
+               out.close();
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         throw new BuildException(e);
+      }
+   }
+   
+   private static String readFileContents(File file) throws Exception
+   {
+      StringBuilder sb = new StringBuilder();
+      BufferedReader in = null;
+      try
+      {
+         in = new BufferedReader(new FileReader(file));
+         String line;
+         while ((line = in.readLine()) != null)
+         {
+            sb.append(line);
+            sb.append("\n");
+         }
+      }
+      finally
+      {
+         if (in != null)
+         {
+            try
+            {
+               in.close();
+            }
+            catch (Exception e)
+            {
+               //ignore
+            }
+         }
+      }
+      return sb.toString();
+   }
+   
+   private static String updateContents(String contents, String[] libs)
+   {
+      StringBuilder sb = new StringBuilder();
+      for (String f : libs) {
+         sb.append("<resource-root path=\"");
+         sb.append(f);
+         sb.append("\"/>\n        ");
+      }
+      return contents.replaceFirst("<!-- Insert resources here -->", sb.toString());
+   }
+
+   public FileSet createFileset()
+   {
+      this.fileset = new FileSet();
+      return fileset;
+   }
+
+   public void setTargetDir(String targetDir)
+   {
+      this.targetDir = targetDir;
+   }
+}

Added: common-tools/src/main/java/org/jboss/ws/tools/ant/PathWriterTask.java
===================================================================
--- common-tools/src/main/java/org/jboss/ws/tools/ant/PathWriterTask.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/ws/tools/ant/PathWriterTask.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.ant;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.util.StringTokenizer;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * An Ant task that writes a given path element to a file, so that
+ * it can be easily imported by other build files.
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 13-Mar-2008
+ */
+public class PathWriterTask extends Task
+{
+   private String pathId;
+   private String outputFile;
+   private String variables; //to perform path substitution, i.e. jboss.home <--> /dati/jboss-4.2.3.GA
+
+   @Override
+   public void execute() throws BuildException
+   {
+      Project project = getProject();
+      Path path = (Path)project.getReference(pathId);
+      String[] pathElements = path.list();
+      try
+      {
+         StringBuffer sb = new StringBuffer();
+         generateContent(sb, pathElements);
+         BufferedWriter out = new BufferedWriter(new FileWriter(new File(outputFile)));
+         out.write(sb.toString());
+         out.close();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         throw new BuildException(e);
+      }
+   }
+
+   private void generateContent(StringBuffer sb, String[] libs)
+   {
+      sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+      sb.append("<project>\n");
+      sb.append("<path id=\"");
+      sb.append(pathId);
+      sb.append("\">");
+      for (int i = 0; i < libs.length; i++)
+      {
+         sb.append("<pathelement location=\"");
+         sb.append(getPath(libs[i]));
+         sb.append("\"/>\n");
+      }
+      sb.append("</path>");
+      sb.append("</project>\n");
+   }
+
+   private String getPath(String absolutePath)
+   {
+      StringTokenizer st = new StringTokenizer(variables, ";:, ", false);
+      while (st.hasMoreTokens())
+      {
+         String v = st.nextToken();
+         String value = getProject().getProperty(v);
+         if (absolutePath.contains(value))
+         {
+            int begin = absolutePath.indexOf(value);
+            int end = begin + value.length();
+            absolutePath = absolutePath.substring(0, begin) + "${" + v + "}" + absolutePath.substring(end);
+         }
+      }
+      return absolutePath;
+   }
+
+   public void setPathId(String pathId)
+   {
+      this.pathId = pathId;
+   }
+
+   public void setOutputFile(String outputFile)
+   {
+      this.outputFile = outputFile;
+   }
+
+   public void setVariables(String variables)
+   {
+      this.variables = variables;
+   }
+
+}

Added: common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/AntTaskHelper.java
===================================================================
--- common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/AntTaskHelper.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/AntTaskHelper.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.tools.ant;
+
+import org.apache.tools.ant.types.CommandlineJava.SysProperties;
+import org.apache.tools.ant.types.Environment.Variable;
+
+/**
+ * Helper class for ANT tasks.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+final class AntTaskHelper
+{
+   /**
+    * Constructor.
+    */
+   private AntTaskHelper()
+   {
+      // forbidden constructor
+   }
+
+   /**
+    * Converts array of JVM arguments to ANT SysProperties object.
+    * 
+    * @param arguments to be converted.
+    * @return ANT SysProperties object.
+    */
+   static SysProperties toSystemProperties(final String[] arguments)
+   {
+      final SysProperties retVal = new SysProperties();
+
+      if (arguments != null && arguments.length != 0)
+      {
+         for (final String argument : arguments)
+         {
+            if (argument.startsWith("-D"))
+            {
+               Variable var = AntTaskHelper.toVariable(argument);
+               retVal.addVariable(var);
+            }
+         }
+      }
+
+      return retVal;
+   }
+
+   /**
+    * Converts JVM property of format -Dkey=value to ANT Variable object.
+    *
+    * @param argument to be converted
+    * @return ANT Variable object
+    */
+   private static Variable toVariable(final String argument)
+   {
+      final Variable retVal = new Variable();
+      final int equalSignIndex = argument.indexOf('=');
+
+      if (equalSignIndex == -1)
+      {
+         final String key = argument.substring(2);
+         retVal.setKey(key);
+      }
+      else
+      {
+         final String key = argument.substring(2, equalSignIndex);
+         retVal.setKey(key);
+         final String value = argument.substring(equalSignIndex + 1);
+         retVal.setValue(value);
+      }
+
+      return retVal;
+   }
+}

Added: common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java
===================================================================
--- common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.tools.ant;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+class SecurityActions
+{
+   /**
+    * Get context classloader.
+    * 
+    * @return the current context classloader
+    */
+   static ClassLoader getContextClassLoader()
+   {
+      SecurityManager sm = System.getSecurityManager();
+      if (sm == null)
+      {
+         return Thread.currentThread().getContextClassLoader();
+      }
+      else
+      {
+         return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+            public ClassLoader run()
+            {
+               return Thread.currentThread().getContextClassLoader();
+            }
+         });
+      }
+   }
+
+   /**
+    * Set context classloader.
+    *
+    * @param cl the classloader
+    * @return previous context classloader
+    * @throws Throwable for any error
+    */
+   static ClassLoader setContextClassLoader(final ClassLoader cl)
+   {
+      if (System.getSecurityManager() == null)
+      {
+         ClassLoader result = Thread.currentThread().getContextClassLoader();
+         if (cl != null)
+            Thread.currentThread().setContextClassLoader(cl);
+         return result;
+      }
+      else
+      {
+         try
+         {
+            return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
+               public ClassLoader run() throws Exception
+               {
+                  try
+                  {
+                     ClassLoader result = Thread.currentThread().getContextClassLoader();
+                     if (cl != null)
+                        Thread.currentThread().setContextClassLoader(cl);
+                     return result;
+                  }
+                  catch (Exception e)
+                  {
+                     throw e;
+                  }
+                  catch (Error e)
+                  {
+                     throw e;
+                  }
+                  catch (Throwable e)
+                  {
+                     throw new RuntimeException("Error setting context classloader", e);
+                  }
+               }
+            });
+         }
+         catch (PrivilegedActionException e)
+         {
+            throw new RuntimeException("Error running privileged action", e.getCause());
+         }
+      }
+   }
+   
+   /**
+    * Get classloader from class.
+    *
+    * @param clazz the class
+    * @return class's classloader
+    */
+   static ClassLoader getClassLoader(final Class<?> clazz)
+   {
+      SecurityManager sm = System.getSecurityManager();
+      if (sm == null)
+      {
+         return clazz.getClassLoader();
+      }
+      else
+      {
+         return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+            public ClassLoader run()
+            {
+               return clazz.getClassLoader();
+            }
+         });
+      }
+   }
+
+}

Added: common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java
===================================================================
--- common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,366 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.tools.ant;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.ExecuteJava;
+import org.apache.tools.ant.taskdefs.LogOutputStream;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.CommandlineJava;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.CommandlineJava.SysProperties;
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+/**
+ * Ant task which consumes a Web Service contract.
+ *
+ * <table border="1">
+ *   <tr align="left" BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><th>Attribute</th><th>Description</th><th>Default</th></tr>
+ *   <tr><td>fork</td><td>Whether or not to run the generation task in a separate VM.</td><td>true</td></tr>
+ *   <tr><td>keep</td><td>Keep/Enable Java source code generation.</td><td>false</td></tr>
+ *   <tr><td>catalog</td><td> Oasis XML Catalog file for entity resolution</td><td>none</td></tr>
+ *   <tr><td>package</td><td> The target Java package for generated code.</td><td>generated</td></tr>
+ *   <tr><td>binding</td><td>A JAX-WS or JAXB binding file</td><td>none</td></tr>
+ *   <tr><td>wsdlLocation</td><td>Value to use for @@WebService.wsdlLocation</td><td>generated</td></tr>
+ *   <tr><td>destdir</td><td>The output directory for generated artifacts.</td><td>"output"</td></tr>
+ *   <tr><td>sourcedestdir</td><td>The output directory for Java source.</td><td>value of destdir</td></tr>
+ *   <tr><td>extension</td><td>Enable SOAP 1.2 binding extension.</td><td>false</td></tr>
+ *   <tr><td>target</td><td>The JAX-WS specification target. Allowed values are 2.0, 2.1 and 2.2</td><td></td></tr>
+ *   <tr><td>verbose</td><td>Enables more informational output about cmd progress.</td><td>false</td><tr>
+ *   <tr><td>wsdl*</td><td>The WSDL file or URL</td><td>n/a</td><tr>
+ * </table>
+ * <b>* = required.</b>
+ *
+ * <p>Example:
+ *
+ * <pre>
+ * &lt;WSConsumeTask
+ *   fork=&quot;true&quot;
+ *   verbose=&quot;true&quot;
+ *   destdir=&quot;output&quot;
+ *   sourcedestdir=&quot;gen-src&quot;
+ *   keep=&quot;true&quot;
+ *   wsdllocation=&quot;handEdited.wsdl&quot;
+ *   wsdl=&quot;foo.wsdl&quot;&gt;
+ *   &lt;binding dir=&quot;binding-files&quot; includes=&quot;*.xml&quot; excludes=&quot;bad.xml&quot;/&gt;
+ * &lt;/wsimport&gt;
+ * </pre>
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+public class WSConsumeTask extends Task
+{
+   private CommandlineJava command = new CommandlineJava();
+   private String wsdl;
+   private File destdir;
+   private File sourcedestdir;
+   private List<File> bindingFiles = new ArrayList<File>();
+   private File catalog;
+   private String wsdlLocation;
+   private String targetPackage;
+   private boolean keep;
+   private boolean extension;
+   private boolean verbose;
+   private boolean fork;
+   private boolean debug;
+   private boolean nocompile;
+   private boolean additionalHeaders;
+   private String target;
+
+   // Not actually used right now
+   public void setDebug(boolean debug)
+   {
+      this.debug = debug;
+   }
+
+   public Commandline.Argument createJvmarg()
+   {
+      return command.createVmArgument();
+   }
+
+   public void setBinding(File bindingFile)
+   {
+      bindingFiles.add(bindingFile);
+   }
+
+   public void setCatalog(File catalog)
+   {
+      this.catalog = catalog;
+   }
+
+   public void setDestdir(File destdir)
+   {
+      this.destdir = destdir;
+   }
+
+   public void setFork(boolean fork)
+   {
+      this.fork = fork;
+   }
+
+   public void setKeep(boolean keep)
+   {
+      this.keep = keep;
+   }
+
+   public void setExtension(boolean extension)
+   {
+      this.extension = extension;
+   }
+   
+   public void setAdditionalHeaders(boolean additionalHeaders)
+   {
+      this.additionalHeaders = additionalHeaders;
+   }
+
+   public void setSourcedestdir(File sourcedestdir)
+   {
+      this.sourcedestdir = sourcedestdir;
+   }
+
+   public void setTarget(String target)
+   {
+      this.target = target;
+   }
+
+   public void setPackage(String targetPackage)
+   {
+      this.targetPackage = targetPackage;
+   }
+
+   public void setVerbose(boolean verbose)
+   {
+      this.verbose = verbose;
+   }
+
+   public void setNoCompile(boolean nocompile)
+   {
+      this.nocompile = nocompile;
+   }
+
+   public void setWsdl(String wsdl)
+   {
+      this.wsdl = wsdl;
+   }
+
+   public void setWsdlLocation(String wsdlLocation)
+   {
+      this.wsdlLocation = wsdlLocation;
+   }
+
+   public void addConfiguredBinding(FileSet fs)
+   {
+      DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+      File baseDir = ds.getBasedir();
+      for (String file : ds.getIncludedFiles())
+      {
+         bindingFiles.add(new File(baseDir, file));
+      }
+   }
+
+   public void executeNonForked()
+   {
+      ClassLoader prevCL = SecurityActions.getContextClassLoader();
+      ClassLoader antLoader = SecurityActions.getClassLoader(this.getClass());
+      SecurityActions.setContextClassLoader(antLoader);
+      try
+      {
+         WSContractConsumer consumer = WSContractConsumer.newInstance();
+         consumer.setGenerateSource(keep);
+         consumer.setExtension(extension);
+         consumer.setAdditionalHeaders(additionalHeaders);
+         consumer.setNoCompile(nocompile);
+         if (destdir != null)
+            consumer.setOutputDirectory(destdir);
+         if (sourcedestdir != null)
+            consumer.setSourceDirectory(sourcedestdir);
+         if (targetPackage != null)
+            consumer.setTargetPackage(targetPackage);
+         if (wsdlLocation != null)
+            consumer.setWsdlLocation(wsdlLocation);
+         if (catalog != null)
+         {
+            if (catalog.exists() && catalog.isFile())
+            {
+               consumer.setCatalog(catalog);
+            }
+            else
+            {
+               log("Catalog file not found: " + catalog, Project.MSG_WARN);
+            }
+         }
+         if (bindingFiles != null && bindingFiles.size() > 0)
+            consumer.setBindingFiles(bindingFiles);
+         if (target != null)
+            consumer.setTarget(target);
+
+         log("Consuming wsdl: " + wsdl, Project.MSG_INFO);
+
+         if (verbose)
+         {
+            consumer.setMessageStream(new PrintStream(new LogOutputStream(this, Project.MSG_INFO)));
+         }
+
+         try
+         {
+            consumer.setAdditionalCompilerClassPath(getTaskClassPathStrings());
+            consumer.consume(wsdl);
+         }
+         catch (Throwable e)
+         {
+            throw new BuildException(e, getLocation());
+         }
+      }
+      finally
+      {
+         SecurityActions.setContextClassLoader(prevCL);
+      }
+   }
+
+   public void execute() throws BuildException
+   {
+      if (wsdl == null)
+         throw new BuildException("The wsdl attribute must be specified!", getLocation());
+
+      if (fork)
+         executeForked();
+      else executeNonForked();
+   }
+
+   private Path getTaskClassPath()
+   {
+      // Why is everything in the Ant API a big hack???
+      ClassLoader cl = SecurityActions.getClassLoader(this.getClass());
+      if (cl instanceof AntClassLoader)
+      {
+         return new Path(getProject(), ((AntClassLoader)cl).getClasspath());
+      }
+
+      return new Path(getProject());
+   }
+
+   private List<String> getTaskClassPathStrings()
+   {
+      // Why is everything in the Ant API a big hack???
+      List<String> strings = new ArrayList<String>();
+      ClassLoader cl = SecurityActions.getClassLoader(this.getClass());
+      if (cl instanceof AntClassLoader)
+      {
+         for (String string : ((AntClassLoader)cl).getClasspath().split(File.pathSeparator))
+            strings.add(string);
+      }
+
+      return strings;
+   }
+
+   private void executeForked() throws BuildException
+   {
+      command.setClassname(org.jboss.wsf.spi.tools.cmd.WSConsume.class.getName());
+
+      Path path = command.createClasspath(getProject());
+      path.append(getTaskClassPath());
+
+      if (keep)
+         command.createArgument().setValue("-k");
+      
+      if (extension)
+         command.createArgument().setValue("-e");
+      
+      if (additionalHeaders)
+         command.createArgument().setValue("-a");
+
+      for (File file : bindingFiles)
+      {
+         command.createArgument().setValue("-b");
+         command.createArgument().setFile(file);
+      }
+
+      if (catalog != null)
+      {
+         command.createArgument().setValue("-c");
+         command.createArgument().setFile(catalog);
+      }
+
+      if (targetPackage != null)
+      {
+         command.createArgument().setValue("-p");
+         command.createArgument().setValue(targetPackage);
+      }
+
+      if (wsdlLocation != null)
+      {
+         command.createArgument().setValue("-w");
+         command.createArgument().setValue(wsdlLocation);
+      }
+
+      if (destdir != null)
+      {
+         command.createArgument().setValue("-o");
+         command.createArgument().setFile(destdir);
+      }
+
+      if (sourcedestdir != null)
+      {
+         command.createArgument().setValue("-s");
+         command.createArgument().setFile(sourcedestdir);
+      }
+
+      if (target != null)
+      {
+         command.createArgument().setValue("-t");
+         command.createArgument().setValue(target);
+      }
+
+      if (verbose)
+         command.createArgument().setValue("-v");
+
+      command.createArgument().setValue(wsdl);
+
+      log("Consuming wsdl: " + wsdl, Project.MSG_INFO);
+      
+      if (verbose)
+         log("Command invoked: " + command.getJavaCommand().toString());
+
+      ExecuteJava execute = new ExecuteJava();
+      execute.setClasspath(path);
+      execute.setJavaCommand(command.getJavaCommand());
+
+      // propagate system properties (useful e.g. for endorsing)
+      String[] arguments = command.getVmCommand().getArguments();
+      SysProperties properties = AntTaskHelper.toSystemProperties(arguments);
+      execute.setSystemProperties(properties);
+
+      if (execute.fork(this) != 0)
+         throw new BuildException("Could not invoke WSConsumeTask", getLocation());
+   }
+}

Added: common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java
===================================================================
--- common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,331 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.tools.ant;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.ExecuteJava;
+import org.apache.tools.ant.taskdefs.LogOutputStream;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.CommandlineJava;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+import org.apache.tools.ant.types.CommandlineJava.SysProperties;
+import org.apache.tools.ant.types.Environment.Variable;
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.StringTokenizer;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Ant task which invokes provides a Web Service contract and portable JAX-WS wrapper classes.
+ * 
+ * <table border="1">
+ *   <tr align="left" BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><th>Attribute</th><th>Description</th><th>Default</th></tr>
+ *   <tr><td>fork</td><td>Whether or not to run the generation task in a separate VM.</td><td>true</td></tr>
+ *   <tr><td>keep</td><td>Keep/Enable Java source code generation.</td><td>false</td></tr>
+ *   <tr><td>destdir</td><td>The output directory for generated artifacts.</td><td>"output"</td></tr>
+ *   <tr><td>resourcedestdir</td><td>The output directory for resource artifacts (WSDL/XSD).</td><td>value of destdir</td></tr>
+ *   <tr><td>sourcedestdir</td><td>The output directory for Java source.</td><td>value of destdir</td></tr>
+ *   <tr><td>genwsdl</td><td>Whether or not to generate WSDL.</td><td>false</td><tr>
+ *   <tr><td>extension</td><td>Enable SOAP 1.2 binding extension.</td><td>false</td></tr>
+ *   <tr><td>verbose</td><td>Enables more informational output about cmd progress.</td><td>false</td><tr>
+ *   <tr><td>sei</td><td>Service Endpoint Implementation.</td><td></td><tr>
+ *   <tr><td>classpath</td><td>The classpath that contains the service endpoint implementation.</td><td>""</tr>
+ * </table>
+ * <b>* = required.</b>
+ * 
+ * <p>Example:
+ * 
+ * <pre>
+ *  &lt;target name=&quot;test-wsproivde&quot; depends=&quot;init&quot;&gt;
+ *    &lt;taskdef name=&quot;WSProvideTask&quot; classname=&quot;org.jboss.wsf.spi.tools.ant.WSProvideTask&quot;&gt;
+ *      &lt;classpath refid=&quot;core.classpath&quot;/&gt;
+ *    &lt;/taskdef&gt;
+ *    &lt;WSProvideTask
+ *      fork=&quot;false&quot;
+ *      keep=&quot;true&quot;
+ *      destdir=&quot;out&quot;
+ *      resourcedestdir=&quot;out-resource&quot;
+ *      sourcedestdir=&quot;out-source&quot;
+ *      genwsdl=&quot;true&quot; 
+ *      extension=&quot;true&quot;
+ *      verbose=&quot;true&quot;
+ *      sei=&quot;org.jboss.test.ws.jaxws.jsr181.soapbinding.DocWrappedServiceImpl&quot;&gt;
+ *      &lt;classpath&gt;
+ *        &lt;pathelement path=&quot;${tests.output.dir}/classes&quot;/&gt;
+ *      &lt;/classpath&gt;
+ *    &lt;/WSProvideTask&gt;
+ *  &lt;/target&gt;
+ * </pre>
+ * 
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+public class WSProvideTask extends Task
+{
+   private Path classpath = new Path(getProject());
+   private CommandlineJava command = new CommandlineJava();
+   private String sei;
+   private File destdir;
+   private File resourcedestdir;
+   private File sourcedestdir;
+   private boolean keep;
+   private boolean extension;
+   private boolean genwsdl;
+   private boolean verbose;
+   private boolean fork;
+   private boolean debug;
+   
+   // Not actually used right now
+   public void setDebug(boolean debug)
+   {
+      this.debug = debug;
+   }
+   
+   public Commandline.Argument createJvmarg() 
+   {
+      return command.createVmArgument();
+   }
+   
+   public void setClasspath(Path classpath)
+   {
+      this.classpath = classpath;
+   }
+   
+   public void setClasspathRef(Reference ref)
+   {
+      createClasspath().setRefid(ref);
+   }
+   
+   public Path createClasspath()
+   {
+      return classpath;
+   }
+   
+   public void setDestdir(File destdir)
+   {
+      this.destdir = destdir;
+   }
+   
+   public void setExtension(boolean extension)
+   {
+      this.extension = extension;
+   }
+
+   public void setProtocol(String protocol)
+   {
+      if (protocol != null)
+      {
+         this.extension = protocol.toLowerCase().indexOf("Xsoap1.2") != -1;
+      }
+   }
+   
+   public void setKeep(boolean keep)
+   {
+      this.keep = keep;
+   }
+   
+   public void setSei(String sei)
+   {
+      this.sei = sei;
+   }
+   
+   public void setFork(boolean fork)
+   {
+      this.fork = fork;
+   }
+
+   public void setResourcedestdir(File resourcedestdir)
+   {
+      this.resourcedestdir = resourcedestdir;
+   }
+
+   public void setSourcedestdir(File sourcedestdir)
+   {
+      this.sourcedestdir = sourcedestdir;
+   }
+
+   public void setVerbose(boolean verbose)
+   {
+      this.verbose = verbose;
+   }
+
+   public void setGenwsdl(boolean genwsdl)
+   {
+      this.genwsdl = genwsdl;
+   }
+   
+   private ClassLoader getClasspathLoader(ClassLoader parent)
+   {
+		AntClassLoader antLoader = new AntClassLoader(parent, getProject(), classpath, false);
+
+		// It's necessary to wrap it into an URLLoader in order to extract that information
+		// within the actual provider impl.
+		// See SunRIProviderImpl for instance
+		List<URL> urls = new ArrayList<URL>();
+		StringTokenizer tok = new StringTokenizer(antLoader.getClasspath(), File.separator);
+		while(tok.hasMoreTokens())
+		{
+			try
+			{
+            String path = tok.nextToken();
+            if(!path.startsWith("file://"))
+               path = "file://"+path;
+
+            urls.add(new URL(path));
+			}
+			catch (MalformedURLException e)
+			{
+				throw new IllegalArgumentException("Failed to wrap classloader", e);
+			}
+
+		}
+
+		ClassLoader wrapper = new URLClassLoader(urls.toArray(new URL[0]), antLoader);
+		return wrapper;
+   }
+   
+   public void executeNonForked()
+   {
+      ClassLoader prevCL = SecurityActions.getContextClassLoader();
+      ClassLoader antLoader = SecurityActions.getClassLoader(this.getClass());
+      SecurityActions.setContextClassLoader(antLoader);
+      try
+      {
+         WSContractProvider gen = WSContractProvider.newInstance(
+					getClasspathLoader(antLoader)
+			);         
+         if (verbose)
+            gen.setMessageStream(new PrintStream(new LogOutputStream(this, Project.MSG_INFO)));
+         gen.setGenerateSource(keep);
+         gen.setGenerateWsdl(genwsdl);
+         gen.setExtension(extension);
+
+         if (destdir != null)
+            gen.setOutputDirectory(destdir);
+         if (resourcedestdir != null)
+            gen.setResourceDirectory(resourcedestdir);
+         if (sourcedestdir != null)
+            gen.setSourceDirectory(sourcedestdir);
+
+         log("Generating from endpoint: " + sei, Project.MSG_INFO);
+         
+         gen.provide(sei);
+      }
+      catch(Throwable t)
+      {
+         throw new BuildException(t, getLocation());  
+      }
+      finally
+      {
+         SecurityActions.setContextClassLoader(prevCL);
+      }
+   }
+   
+   public void execute() throws BuildException
+   {
+      if (sei == null)
+         throw new BuildException("The sei attribute must be specified!", getLocation());
+      
+      if (fork)
+         executeForked();
+      else
+         executeNonForked();
+   }
+   
+   private Path getTaskClassPath()
+   {
+      // Why is everything in the Ant API a big hack???
+      ClassLoader cl = this.getClass().getClassLoader();
+      if (cl instanceof AntClassLoader)
+      {
+         return new Path(getProject(), ((AntClassLoader)cl).getClasspath());
+      }
+      
+      return new Path(getProject());
+   }
+
+   private void executeForked() throws BuildException
+   {
+      command.setClassname(org.jboss.wsf.spi.tools.cmd.WSProvide.class.getName());
+      
+      Path path = command.createClasspath(getProject());
+      path.append(getTaskClassPath());
+      path.append(classpath);
+     
+      if (keep)
+         command.createArgument().setValue("-k");
+      
+      if (genwsdl)
+         command.createArgument().setValue("-w");
+      
+      if (extension)
+         command.createArgument().setValue("-e");
+      
+      if (destdir != null)
+      {
+         command.createArgument().setValue("-o");
+         command.createArgument().setFile(destdir);
+      }
+      if (resourcedestdir != null)
+      {
+         command.createArgument().setValue("-r");
+         command.createArgument().setFile(resourcedestdir);
+      }
+      if (sourcedestdir != null)
+      {
+         command.createArgument().setValue("-s");
+         command.createArgument().setFile(sourcedestdir);
+      }
+      
+      if (!verbose)
+         command.createArgument().setValue("-q");
+      
+      // Always dump traces
+      command.createArgument().setValue("-t");
+      command.createArgument().setValue(sei);
+      
+      if (verbose)
+         log("Command invoked: " + command.getJavaCommand().toString());
+      
+      ExecuteJava execute = new ExecuteJava();
+      execute.setClasspath(path);
+      execute.setJavaCommand(command.getJavaCommand());
+
+      // propagate system properties (useful e.g. for endorsing)
+      String[] arguments = command.getVmCommand().getArguments();
+      SysProperties properties = AntTaskHelper.toSystemProperties(arguments);
+      execute.setSystemProperties(properties);
+
+      if (execute.fork(this) != 0)
+         throw new BuildException("Could not invoke WSProvideTask", getLocation());
+   }
+}

Added: common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java
===================================================================
--- common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.tools.cmd;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+class SecurityActions
+{
+   /**
+    * Get context classloader.
+    * 
+    * @return the current context classloader
+    */
+   static ClassLoader getContextClassLoader()
+   {
+      SecurityManager sm = System.getSecurityManager();
+      if (sm == null)
+      {
+         return Thread.currentThread().getContextClassLoader();
+      }
+      else
+      {
+         return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+            public ClassLoader run()
+            {
+               return Thread.currentThread().getContextClassLoader();
+            }
+         });
+      }
+   }
+   
+   /**
+    * Set context classloader.
+    *
+    * @param classLoader the classloader
+    */
+   static void setContextClassLoader(final ClassLoader classLoader)
+   {
+      if (System.getSecurityManager() == null)
+      {
+         Thread.currentThread().setContextClassLoader(classLoader);
+      }
+      else
+      {
+         AccessController.doPrivileged(new PrivilegedAction<Object>()
+         {
+            public Object run()
+            {
+               Thread.currentThread().setContextClassLoader(classLoader);
+               return null;
+            }
+         });
+      }
+   }
+
+   static ClassLoader getModulesClassLoader()
+   {
+      SecurityManager sm = System.getSecurityManager();
+      if (sm == null)
+      {
+         return getModulesClassLoaderInternal();
+      }
+      else
+      {
+         return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+            public ClassLoader run()
+            {
+               return getModulesClassLoaderInternal();
+            }
+         });
+      }
+   }
+   
+   private static ClassLoader getModulesClassLoaderInternal()
+   {
+       // TODO: use SPI class loader facade, not reflection!
+       try {
+          Class<?> moduleClass = Class.forName("org.jboss.modules.Module");
+          Class<?> moduleIdentifierClass = Class.forName("org.jboss.modules.ModuleIdentifier");
+          Class<?> moduleLoaderClass = Class.forName("org.jboss.modules.ModuleLoader");
+          Object moduleLoader = moduleClass.getMethod("getBootModuleLoader").invoke(null);
+          Object moduleIdentifier = moduleIdentifierClass.getMethod("create", String.class).invoke(null, "org.jboss.as.webservices.server.integration");
+          Object module = moduleLoaderClass.getMethod("loadModule", moduleIdentifierClass).invoke(moduleLoader, moduleIdentifier);
+          return (ClassLoader)moduleClass.getMethod("getClassLoader").invoke(module);
+       } catch (Exception e) {
+          //ignore, JBoss Modules might not be available at all
+          return null;
+       }
+   }
+
+   /**
+    * Load a class using the provided classloader
+    * 
+    * @param name
+    * @return
+    * @throws PrivilegedActionException
+    */
+   static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+   {
+      SecurityManager sm = System.getSecurityManager();
+      if (sm == null)
+      {
+         return cl.loadClass(name);
+      }
+      else
+      {
+         return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+            public Class<?> run() throws PrivilegedActionException
+            {
+               try
+               {
+                  return cl.loadClass(name);
+               }
+               catch (Exception e)
+               {
+                  throw new PrivilegedActionException(e);
+               }
+            }
+         });
+      }
+   }
+
+   /**
+    * Get a system property
+    * 
+    * @param name
+    * @param defaultValue
+    * @return
+    */
+   static String getSystemProperty(final String name, final String defaultValue)
+   {
+      SecurityManager sm = System.getSecurityManager();
+      if (sm == null)
+      {
+         return System.getProperty(name, defaultValue);
+      }
+      else
+      {
+         PrivilegedAction<String> action = new PrivilegedAction<String>() {
+            public String run()
+            {
+               return System.getProperty(name, defaultValue);
+            }
+         };
+         return AccessController.doPrivileged(action);
+      }
+   }
+}

Added: common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java
===================================================================
--- common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,335 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.tools.cmd;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+import org.jboss.wsf.spi.util.Log4JUtil;
+import org.jboss.wsf.spi.util.Log4jOutputStream;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * WSConsumeTask is a cmd line tool that generates portable JAX-WS artifacts
+ * from a WSDL file.
+ *
+ * <pre>
+ *  usage: WSConsumeTask [options] &lt;wsdl-url&gt;
+ *  options:
+ *  <table>
+ *  <tr><td>-h, --help                      </td><td>Show this help message</td></tr>
+ *  <tr><td>-b, --binding=&lt;file&gt;      </td><td>One or more JAX-WS or JAXB binding files</td></tr>
+ *  <tr><td>-k, --keep                      </td><td>Keep/Generate Java source</td></tr>
+ *  <tr><td>-c, --catalog=&lt;file&gt;      </td><td>Oasis XML Catalog file for entity resolution</td></tr>
+ *  <tr><td>-p, --package=&lt;name&gt;      </td><td>The target package for generated source</td></tr>
+ *  <tr><td>-w, --wsdlLocation=&lt;loc&gt;  </td><td>Value to use for @@WebService.wsdlLocation</td></tr>
+ *  <tr><td>-o, --output=&lt;directory&gt;  </td><td>The directory to put generated artifacts</td></tr>
+ *  <tr><td>-s, --source=&lt;directory&gt;  </td><td>The directory to put Java source</td></tr>
+ *  <tr><td>-t, --target=&lt;2.0|2.1|2.2&gt;</td><td>The target specification target</td></tr>
+ *  <tr><td>-n, --nocompile                 </td><td>Do not compile generated sources</td></tr> 
+ *  <tr><td>-q, --quiet                     </td><td>Be somewhat more quiet</td></tr>
+ *  <tr><td>-v, --verbose                   </td><td>Show full exception stack traces</td></tr>
+ *  <tr><td>-l, --load-consumer             </td><td>Load the consumer and exit (debug utility)</td></tr>
+ *  <tr><td>-e, --extension                 </td><td>Enable SOAP 1.2 binding extension</td></tr>
+ *  <tr><td>-a, --additionalHeaders         </td><td>Enable SOAP 1.2 binding extension</td></tr>
+ *  </table>
+ * </pre>
+ *
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ */
+public class WSConsume
+{
+   private static final ClassLoader MODULES_LOADER = SecurityActions.getModulesClassLoader();
+   private List<File> bindingFiles = new ArrayList<File>();
+   private File outputDir = new File("output");
+   private boolean generateSource;
+   private File catalog;
+   private String targetPackage;
+   private String wsdlLocation;
+   private boolean quiet;
+   private boolean verbose;
+   private boolean loadConsumer;
+   private boolean extension;
+   private boolean additionalHeaders;
+   private boolean noCompile;
+   private File sourceDir;
+   private String target;
+   
+   public static final String PROGRAM_NAME = SecurityActions.getSystemProperty("program.name", WSConsume.class.getName());
+
+   public static void main(String[] args)
+   {
+      if (MODULES_LOADER != null)
+      {
+         final ClassLoader origLoader = SecurityActions.getContextClassLoader();
+         try
+         {
+            SecurityActions.setContextClassLoader(MODULES_LOADER);
+            mainInternal(args);
+         }
+         finally
+         {
+            SecurityActions.setContextClassLoader(origLoader);
+         }
+      }
+      else
+      {
+         mainInternal(args);
+      }
+   }
+   
+   private static void mainInternal(final String[] args)
+   {
+       WSConsume importer = new WSConsume();
+       URL wsdl = importer.parseArguments(args);
+       System.exit(importer.importServices(wsdl));
+   }
+
+   private URL parseArguments(String[] args)
+   {
+      String shortOpts = "b:c:p:w:o:s:t:khqvlnea";
+      LongOpt[] longOpts =
+      {
+         new LongOpt("binding", LongOpt.REQUIRED_ARGUMENT, null, 'b'),
+         new LongOpt("catalog", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
+         new LongOpt("package", LongOpt.REQUIRED_ARGUMENT, null, 'p'),
+         new LongOpt("wsdlLocation", LongOpt.REQUIRED_ARGUMENT, null, 'w'),
+         new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
+         new LongOpt("source", LongOpt.REQUIRED_ARGUMENT, null, 's'),
+         new LongOpt("target", LongOpt.REQUIRED_ARGUMENT, null, 't'),
+         new LongOpt("keep", LongOpt.NO_ARGUMENT, null, 'k'),
+         new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
+         new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q'),
+         new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'),
+         new LongOpt("nocompile", LongOpt.NO_ARGUMENT, null, 'n'),
+         new LongOpt("extension", LongOpt.NO_ARGUMENT, null, 'e'),
+         new LongOpt("additionalHeaders", LongOpt.NO_ARGUMENT, null, 'a'),
+         new LongOpt("load-consumer", LongOpt.NO_ARGUMENT, null, 'l'),
+      };
+
+      Getopt getopt = new Getopt(PROGRAM_NAME, args, shortOpts, longOpts);
+      int c;
+      while ((c = getopt.getopt()) != -1)
+      {
+         switch (c)
+         {
+            case 'b':
+               bindingFiles.add(new File(getopt.getOptarg()));
+               break;
+            case 'k':
+               generateSource = true;
+               break;
+            case 'c':
+               catalog = new File(getopt.getOptarg());
+               break;
+            case 'p':
+               targetPackage = getopt.getOptarg();
+               break;
+            case 'w':
+               wsdlLocation = getopt.getOptarg();
+               break;
+            case 'o':
+               outputDir = new File(getopt.getOptarg());
+               break;
+            case 's':
+               sourceDir = new File(getopt.getOptarg());
+               break;
+            case 't':
+               target = getopt.getOptarg();
+               break;
+            case 'q':
+               quiet = true;
+               break;
+            case 'v':
+               verbose = true;
+               break;
+            case 'l':
+               loadConsumer = true;
+               break;
+            case 'e':
+               extension = true;
+               break;
+            case 'a':
+               additionalHeaders = true;
+               break;
+            case 'n':
+               noCompile = true;
+               break;
+            case 'h':
+               printHelp();
+               System.exit(0);
+            case '?':
+               System.exit(1);
+         }
+      }
+
+      // debug output
+      if(loadConsumer)
+      {
+         WSContractConsumer importer = WSContractConsumer.newInstance();
+         System.out.println("WSContractConsumer instance: " + importer.getClass().getCanonicalName());
+         System.exit(0);
+      }
+
+      int wsdlPos = getopt.getOptind();
+      if (wsdlPos >= args.length)
+      {
+         System.err.println("Error: WSDL URL was not specified!");
+         printHelp();
+         System.exit(1);
+      }
+
+      URL url = null;
+      try
+      {
+         try
+         {
+            url = new URL(args[wsdlPos]);
+         }
+         catch (MalformedURLException e)
+         {
+            File file = new File(args[wsdlPos]);
+            url = file.toURI().toURL();
+         }
+      }
+      catch (MalformedURLException e)
+      {
+         System.err.println("Error: Invalid URI: " + args[wsdlPos]);
+         System.exit(1);
+      }
+
+      return url;
+   }
+
+
+   private int importServices(URL wsdl)
+   {
+      WSContractConsumer consumer = WSContractConsumer.newInstance();
+
+      consumer.setGenerateSource(generateSource);
+      consumer.setOutputDirectory(outputDir);
+      consumer.setExtension(extension);
+      consumer.setAdditionalHeaders(additionalHeaders);
+      if (sourceDir != null)
+         consumer.setSourceDirectory(sourceDir);
+
+      if (! quiet)
+      {
+         PrintStream ps;
+         if (Log4JUtil.isLog4jConfigurationAvailable())
+         {
+            ps = new PrintStream(new Log4jOutputStream(Logger.getLogger("WSConsume"), Level.INFO));
+         }
+         else
+         {
+            ps = System.out;
+            ps.println("Could not find log4j.xml configuration, logging to console.\n");
+         }
+         consumer.setMessageStream(ps);
+      }
+
+      if (catalog != null)
+      {
+         if (catalog.exists() && catalog.isFile())
+         {
+            consumer.setCatalog(catalog);
+         }
+         else
+         {
+            System.err.println("Warning: catalog file not found: " + catalog);
+         }
+      }
+
+      if (targetPackage != null)
+         consumer.setTargetPackage(targetPackage);
+
+      if (wsdlLocation != null)
+         consumer.setWsdlLocation(wsdlLocation);
+
+      if (bindingFiles != null && bindingFiles.size() > 0)
+         consumer.setBindingFiles(bindingFiles);
+
+      if(target!=null)
+         consumer.setTarget(target);
+      
+      if (noCompile)
+         consumer.setNoCompile(noCompile);
+
+      try
+      {
+         consumer.consume(wsdl);
+         return 0;
+      }
+      catch (Throwable t)
+      {
+         System.err.println("Error: Could not import. (use --verbose to see full traces)");
+         if (!verbose)
+         {
+            String message = t.getMessage();
+            if (message == null)
+               message = t.getClass().getSimpleName();
+            System.err.println("Error: " + message);
+         }
+         else
+         {
+            t.printStackTrace(System.err);
+         }
+
+      }
+
+      return 1;
+   }
+
+   private static void printHelp()
+   {
+      PrintStream out = System.out;
+      out.println("WSConsumeTask is a cmd line tool that generates portable JAX-WS artifacts from a WSDL file.\n");
+      out.println("usage: " + PROGRAM_NAME + " [options] <wsdl-url>\n");
+      out.println("options: ");
+      out.println("    -h, --help                  Show this help message");
+      out.println("    -b, --binding=<file>        One or more JAX-WS or JAXB binding files ");
+      out.println("    -k, --keep                  Keep/Generate Java source");
+      out.println("    -c  --catalog=<file>        Oasis XML Catalog file for entity resolution");
+      out.println("    -p  --package=<name>        The target package for generated source");
+      out.println("    -w  --wsdlLocation=<loc>    Value to use for @WebService.wsdlLocation");
+      out.println("    -o, --output=<directory>    The directory to put generated artifacts");
+      out.println("    -s, --source=<directory>    The directory to put Java source");
+      out.println("    -t, --target=<2.0|2.1|2.2>  The JAX-WS specification target");
+      out.println("    -q, --quiet                 Be somewhat more quiet");
+      out.println("    -v, --verbose               Show full exception stack traces");
+      out.println("    -l, --load-consumer         Load the consumer and exit (debug utility)");
+      out.println("    -e, --extension             Enable SOAP 1.2 binding extension");
+      out.println("    -a, --additionalHeaders     Enable processing of implicit SOAP headers");
+      out.println("    -n, --nocompile             Do not compile generated sources");
+      out.flush();
+   }
+}

Added: common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java
===================================================================
--- common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,269 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.tools.cmd;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+import org.jboss.wsf.spi.tools.WSContractProvider;
+import org.jboss.wsf.spi.util.Log4JUtil;
+import org.jboss.wsf.spi.util.Log4jOutputStream;
+
+/**
+ * WSProvideTask is a cmd line tool that generates portable JAX-WS artifacts
+ * for a service endpoint implementation.
+ * 
+ * <pre>
+ *  usage: WSProvideTask [options] &lt;endpoint class name&gt;
+ *  options: 
+ *  <table>
+ *  <tr><td>-h, --help                      </td><td>Show this help message</td></tr>
+ *  <tr><td>-k, --keep                      </td><td>Keep/Generate Java source</td></tr>
+ *  <tr><td>-w, --wsdl                      </td><td>Enable WSDL file generation</td></tr>
+ *  <tr><td>-c, --classpath=&lt;path&lt;    </td><td>The classpath that contains the endpoint</td></tr>
+ *  <tr><td>-o, --output=&lt;directory&gt;  </td><td>The directory to put generated artifacts</td></tr>
+ *  <tr><td>-r, --resource=&lt;directory&gt;</td><td>The directory to put resource artifacts</td></tr>
+ *  <tr><td>-s, --source=&lt;directory&gt;  </td><td>The directory to put Java source</td></tr>
+ *  <tr><td>-q, --quiet                     </td><td>Be somewhat more quiet</td></tr>
+ *  <tr><td>-t, --show-traces               </td><td>Show full exception stack traces</td></tr>
+ *  <tr><td>-l, --load-provider             </td><td>Load the provider and exit (debug utility)</td></tr>
+ *  <tr><td>-e, --extension                 </td><td>Enable SOAP 1.2 binding extension</td></tr>
+ * </pre>
+ * 
+ * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
+ */
+public class WSProvide
+{
+   private static final ClassLoader MODULES_LOADER = SecurityActions.getModulesClassLoader();
+   private ClassLoader loader = MODULES_LOADER != null ? MODULES_LOADER : SecurityActions.getContextClassLoader();
+   private File outputDir = new File("output");
+   private boolean generateSource;
+   private boolean generateWsdl;
+   private boolean extension;
+   private boolean quiet;
+   private boolean showTraces;
+   private boolean loadProvider;
+   private File resourceDir;
+   private File sourceDir;
+
+   public static final String PROGRAM_NAME = SecurityActions.getSystemProperty("program.name", WSProvide.class.getSimpleName());
+
+   public static void main(String[] args)
+   {
+      WSProvide generate = new WSProvide();
+      String endpoint = generate.parseArguments(args);
+      System.exit(generate.generate(endpoint));
+   }
+   
+   private String parseArguments(String[] args)
+   {
+      String shortOpts = "hwko:r:s:c:qtle";
+      LongOpt[] longOpts = 
+      {
+         new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
+         new LongOpt("wsdl", LongOpt.NO_ARGUMENT, null, 'w'),
+         new LongOpt("keep", LongOpt.NO_ARGUMENT, null, 'k'),
+         new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
+         new LongOpt("resource", LongOpt.REQUIRED_ARGUMENT, null, 'r'),
+         new LongOpt("source", LongOpt.REQUIRED_ARGUMENT, null, 's'),
+         new LongOpt("classpath", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
+         new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q'),
+         new LongOpt("show-traces", LongOpt.NO_ARGUMENT, null, 't'),
+         new LongOpt("load-provider", LongOpt.NO_ARGUMENT, null, 'l'),
+         new LongOpt("extension", LongOpt.NO_ARGUMENT, null, 'e'),
+      };
+      
+      Getopt getopt = new Getopt(PROGRAM_NAME, args, shortOpts, longOpts);
+      int c;
+      while ((c = getopt.getopt()) != -1)
+      {
+         switch (c)
+         {
+            case 'k':
+               generateSource = true;
+               break;
+            case 's':
+               sourceDir = new File(getopt.getOptarg());
+               break;
+            case 'r':
+               resourceDir = new File(getopt.getOptarg());
+               break;
+            case 'w':
+               generateWsdl = true;
+               break;
+            case 't':
+               showTraces = true;
+               break;
+            case 'o':
+               outputDir = new File(getopt.getOptarg());
+               break;
+            case 'q':
+               quiet = true;
+               break;
+            case 'c':
+               processClassPath(getopt.getOptarg());
+               break;
+            case 'l':
+               loadProvider = true;
+               break;
+            case 'e':
+               extension = true;
+               break;
+            case 'h':
+               printHelp();
+               System.exit(0);
+            case '?':
+               System.exit(1);
+         }
+      }
+
+      // debug output
+      if(loadProvider)
+      {
+         WSContractProvider gen = WSContractProvider.newInstance(loader);
+         System.out.println("WSContractProvider instance: " + gen.getClass().getCanonicalName());
+         System.exit(0);
+      }
+
+      int endpointPos = getopt.getOptind();
+      if (endpointPos >= args.length)
+      {
+         System.err.println("Error: endpoint implementation was not specified!");
+         printHelp();
+         System.exit(1);
+      }
+      
+      return args[endpointPos];
+   }
+   
+   
+   private int generate(String endpoint)
+   {
+      try
+      {
+         SecurityActions.loadClass(loader, endpoint);
+      }
+      catch (Exception e)
+      {
+         System.err.println("Error: Could not load class [" + endpoint + "]. Did you specify a valid --classpath?");
+         return 1;
+      }
+      
+      WSContractProvider gen = WSContractProvider.newInstance(loader);
+      gen.setGenerateWsdl(generateWsdl);
+      gen.setGenerateSource(generateSource);
+      gen.setOutputDirectory(outputDir);
+      gen.setExtension(extension);
+      if (resourceDir != null)
+         gen.setResourceDirectory(resourceDir);
+      if (sourceDir != null)
+         gen.setSourceDirectory(sourceDir);
+
+      if (! quiet)
+      {
+         PrintStream ps;
+         if (Log4JUtil.isLog4jConfigurationAvailable())
+         {
+            ps = new PrintStream(new Log4jOutputStream(Logger.getLogger("WSProvide"), Level.INFO));
+         }
+         else
+         {
+            ps = System.out;
+            ps.println("Could not find log4j.xml configuration, logging to console.\n");
+         }
+         gen.setMessageStream(ps);
+      }
+      
+      try
+      {
+         gen.provide(endpoint);
+         return 0;
+      }
+      catch (Throwable t)
+      {
+         System.err.println("Error: Could not generate. (use --show-traces to see full traces)");
+         if (!showTraces)
+         {
+            String message = t.getMessage();
+            if (message == null)
+               message = t.getClass().getSimpleName();
+            System.err.println("Error: " + message);
+         }
+         else
+         {
+            t.printStackTrace(System.err);
+         }
+         
+      }
+      
+      return 1;
+   }
+
+   private void processClassPath(String classPath)
+   {
+      String[] entries =  classPath.split(File.pathSeparator);
+      List<URL> urls= new ArrayList<URL>(entries.length);
+      for (String entry : entries)
+      {
+         try 
+         {
+            urls.add(new File(entry).toURI().toURL());
+         }
+         catch (MalformedURLException e)
+         {
+            System.err.println("Error: a classpath entry was malformed: " + entry);
+         }
+      }
+      loader = new URLClassLoader(urls.toArray(new URL[0]), loader);
+   }
+
+   private static void printHelp()
+   {
+      PrintStream out = System.out;
+      out.println("WSProvideTask generates portable JAX-WS artifacts for an endpoint implementation.\n");
+      out.println("usage: " + PROGRAM_NAME + " [options] <endpoint class name>\n");
+      out.println("options: ");
+      out.println("    -h, --help                  Show this help message");
+      out.println("    -k, --keep                  Keep/Generate Java source");
+      out.println("    -w, --wsdl                  Enable WSDL file generation");
+      out.println("    -c, --classpath=<path>      The classpath that contains the endpoint");
+      out.println("    -o, --output=<directory>    The directory to put generated artifacts");
+      out.println("    -r, --resource=<directory>  The directory to put resource artifacts");
+      out.println("    -s, --source=<directory>    The directory to put Java source");
+      out.println("    -e, --extension             Enable SOAP 1.2 binding extension");
+      out.println("    -q, --quiet                 Be somewhat more quiet");
+      out.println("    -t, --show-traces           Show full exception stack traces");
+      out.println("    -l, --load-provider         Load the provider and exit (debug utility)");
+      out.flush();
+   }
+}

Added: common-tools/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java
===================================================================
--- common-tools/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.util;
+
+import java.net.URL;
+
+import org.apache.log4j.helpers.Loader;
+
+/**
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 10-Jun-2010
+ *
+ */
+public class Log4JUtil
+{
+   public static final String LOG4J_CONFIGURATION = "log4j.configuration";
+   public static final String LOG4J_PROPERTIES = "log4j.properties";
+   
+   /**
+    * Returns true if a log4j configuration can be found given the current environment.
+    * See http://logging.apache.org/log4j/1.2/manual.html (Default Initialization Procedure)
+    * @return
+    */
+   public static boolean isLog4jConfigurationAvailable()
+   {
+      String log4jConfiguration = System.getProperty(LOG4J_CONFIGURATION);
+      String resource = log4jConfiguration != null ? log4jConfiguration : LOG4J_PROPERTIES;
+      URL url = null;
+      try
+      {
+         url = new URL(resource);
+      }
+      catch (Exception e1)
+      {
+         try
+         {
+            url = Loader.getResource(resource);
+         }
+         catch (Exception e2)
+         {
+            //ignore
+         }
+      }
+      return url != null;
+   }
+}

Added: common-tools/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java
===================================================================
--- common-tools/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java	                        (rev 0)
+++ common-tools/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.log4j.Category;
+import org.apache.log4j.Priority;
+
+/**
+ * An OutputStream that flushes out to a Category.<p>
+ * A simple port of <a href="mailto://Jim.Moore@rocketmail.com">Jim Moore</a>'s
+ * LoggingOutputStream contribution to log4j. 
+ * 
+ * Note that no data is written out to the Category until the stream is
+ *   flushed or closed.<p>
+ * 
+ * Example:<pre>
+ * // make sure everything sent to System.err is logged
+ * System.setErr(new PrintStream(new LoggingOutputStream(Category.getRoot(), Priority.WARN), true));
+ * 
+ * // make sure everything sent to System.out is also logged
+ * System.setOut(new PrintStream(new LoggingOutputStream(Category.getRoot(), Priority.INFO), true));
+ * </pre>
+ * 
+ */
+public class Log4jOutputStream extends OutputStream
+{
+   protected static final String LINE_SEPERATOR = System.getProperty("line.separator");
+
+   /**
+    * Used to maintain the contract of {@link #close()}.
+    */
+   protected boolean hasBeenClosed = false;
+
+   /**
+    * The internal buffer where data is stored. 
+    */
+   protected byte[] buf;
+
+   /**
+    * The number of valid bytes in the buffer. This value is always 
+    *   in the range <tt>0</tt> through <tt>buf.length</tt>; elements 
+    *   <tt>buf[0]</tt> through <tt>buf[count-1]</tt> contain valid 
+    *   byte data.
+    */
+   protected int count;
+
+   /**
+    * Remembers the size of the buffer for speed.
+    */
+   private int bufLength;
+
+   /**
+    * The default number of bytes in the buffer. =2048
+    */
+   public static final int DEFAULT_BUFFER_LENGTH = 2048;
+
+   /**
+    * The category to write to.
+    */
+   protected Category category;
+
+   /**
+    * The priority to use when writing to the Category.
+    */
+   protected Priority priority;
+
+   @SuppressWarnings("unused")
+   private Log4jOutputStream()
+   {
+      // illegal
+   }
+
+   /**
+    * Creates the LoggingOutputStream to flush to the given Category.
+    * 
+    * @param cat        the Category to write to
+    * 
+    * @param priority   the Priority to use when writing to the Category
+    * 
+    * @exception IllegalArgumentException
+    *                   if cat == null or priority == null
+    */
+   public Log4jOutputStream(Category cat, Priority priority) throws IllegalArgumentException
+   {
+      if (cat == null)
+      {
+         throw new IllegalArgumentException("cat == null");
+      }
+      if (priority == null)
+      {
+         throw new IllegalArgumentException("priority == null");
+      }
+
+      this.priority = priority;
+      category = cat;
+      bufLength = DEFAULT_BUFFER_LENGTH;
+      buf = new byte[DEFAULT_BUFFER_LENGTH];
+      count = 0;
+   }
+
+   /**
+    * Closes this output stream and releases any system resources
+    *   associated with this stream. The general contract of <code>close</code>
+    *   is that it closes the output stream. A closed stream cannot perform
+    *   output operations and cannot be reopened.
+    */
+   public void close()
+   {
+      flush();
+      hasBeenClosed = true;
+   }
+
+   /**
+    * Writes the specified byte to this output stream. The general
+    * contract for <code>write</code> is that one byte is written
+    * to the output stream. The byte to be written is the eight
+    * low-order bits of the argument <code>b</code>. The 24
+    * high-order bits of <code>b</code> are ignored.
+    * 
+    * @param b          the <code>byte</code> to write
+    * 
+    * @exception IOException
+    *                   if an I/O error occurs. In particular,
+    *                   an <code>IOException</code> may be thrown if the
+    *                   output stream has been closed.
+    */
+   public void write(final int b) throws IOException
+   {
+      if (hasBeenClosed)
+      {
+         throw new IOException("The stream has been closed.");
+      }
+
+      // don't log nulls
+      if (b == 0)
+      {
+         return;
+      }
+
+      // would this be writing past the buffer?
+      if (count == bufLength)
+      {
+         // grow the buffer
+         final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH;
+         final byte[] newBuf = new byte[newBufLength];
+
+         System.arraycopy(buf, 0, newBuf, 0, bufLength);
+
+         buf = newBuf;
+         bufLength = newBufLength;
+      }
+
+      buf[count] = (byte)b;
+      count++;
+   }
+
+   /**
+    * Flushes this output stream and forces any buffered output bytes
+    *   to be written out. The general contract of <code>flush</code> is
+    *   that calling it is an indication that, if any bytes previously
+    *   written have been buffered by the implementation of the output
+    *   stream, such bytes should immediately be written to their
+    *   intended destination.
+    */
+   public void flush()
+   {
+      if (count == 0)
+      {
+         return;
+      }
+
+      // don't print out blank lines; flushing from PrintStream puts out these
+      if (count == LINE_SEPERATOR.length())
+      {
+         if (((char)buf[0]) == LINE_SEPERATOR.charAt(0) && ((count == 1) || // <- Unix & Mac, -> Windows
+               ((count == 2) && ((char)buf[1]) == LINE_SEPERATOR.charAt(1))))
+         {
+            reset();
+            return;
+         }
+      }
+
+      final byte[] theBytes = new byte[count];
+
+      System.arraycopy(buf, 0, theBytes, 0, count);
+
+      category.log(priority, new String(theBytes));
+
+      reset();
+   }
+
+   private void reset()
+   {
+      // not resetting the buffer -- assuming that if it grew that it
+      //   will likely grow similarly again
+      count = 0;
+   }
+
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+/**
+ * Test the WSConsumeTask.
+ * This test needs to be executed in 'SPI_HOME/output/tests',
+ * because it works with relative paths.
+ * 
+ * @author Heiko.Braun at jboss.com
+ */
+public class AntConsumeTestCase extends BuildFileTest
+{
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      // cleanup events
+      CmdConsumeTracker.LAST_EVENT = "";
+
+      // enforce loading of the tracker implemenation
+      System.setProperty("org.jboss.wsf.spi.tools.ConsumerFactoryImpl", "org.jboss.test.wsf.spi.tools.CmdConsumeTrackerFactory");
+
+      configureProject("src/test/resources/smoke/tools/consume-test.xml");
+   }
+
+   public void testPlainInvocation()
+   {
+      executeTarget("plainInvocation");
+      assertTrue("consume() not invoked", CmdConsumeTracker.LAST_EVENT.indexOf("consume") != -1);
+   }
+
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ */
+public class AntProvideTestCase extends BuildFileTest
+{
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      // cleanup events
+      CmdProvideTracker.LAST_EVENT = "";
+
+      // enforce loading of the tracker implemenation
+      System.setProperty("org.jboss.wsf.spi.tools.ProviderFactoryImpl", "org.jboss.test.wsf.spi.tools.CmdProvideTrackerFactory");
+
+      configureProject("src/test/resources/smoke/tools/provide-test.xml");
+   }
+
+   public void testPlainInvocation()
+   {
+      executeTarget("plainInvocation");
+      assertTrue("provide() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("provide") != -1);
+   }
+
+   public void testIncludeWSDL()
+   {
+      executeTarget("includeWSDL");
+      assertTrue("setGenerateWsdl() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("setGenerateWsdl") != -1);
+   }
+
+   public void testExtraClasspath()
+   {
+      executeTarget("extraClasspath");
+
+   }
+
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,543 @@
+/*
+ *  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.jboss.test.wsf.spi.tools;
+
+import junit.framework.TestCase;
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.URL;
+
+/**
+ * A BuildFileTest is a TestCase which executes targets from an Ant buildfile
+ * for testing.
+ *
+ * This class provides a number of utility methods for particular build file
+ * tests which extend this class.
+ *
+ * @author Apache Ant contributors
+ */
+public abstract class BuildFileTest extends TestCase {
+
+   protected Project project;
+
+   private StringBuffer logBuffer;
+   private StringBuffer fullLogBuffer;
+   private StringBuffer outBuffer;
+   private StringBuffer errBuffer;
+   private BuildException buildException;
+
+   /**
+    * Default constructor for the BuildFileTest object.
+    */
+   public BuildFileTest() {
+      super();
+   }
+
+   /**
+    * Constructor for the BuildFileTest object.
+    *
+    * @param  name string to pass up to TestCase constructor
+    */
+   public BuildFileTest(String name) {
+      super(name);
+   }
+
+   /**
+    * Automatically calls the target called "tearDown"
+    * from the build file tested if it exits.
+    *
+    * This allows to use Ant tasks directly in the build file
+    * to clean up after each test. Note that no "setUp" target
+    * is automatically called, since it's trivial to have a
+    * test target depend on it.
+    */
+   protected void tearDown() throws Exception {
+      if (project == null) {
+         /*
+         * Maybe the BuildFileTest was subclassed and there is
+         * no initialized project. So we could avoid getting a
+         * NPE.
+         * If there is an initialized project getTargets() does
+         * not return null as it is initialized by an empty
+         * HashSet.
+         */
+         return;
+      }
+      final String tearDown = "tearDown";
+      if (project.getTargets().containsKey(tearDown)) {
+         project.executeTarget(tearDown);
+      }
+   }
+
+   /**
+    * run a target, expect for any build exception
+    *
+    * @param  target target to run
+    * @param  cause  information string to reader of report
+    */
+   public  void expectBuildException(String target, String cause) {
+      expectSpecificBuildException(target, cause, null);
+   }
+
+   /**
+    * Assert that only the given message has been logged with a
+    * priority &lt;= INFO when running the given target.
+    */
+   public void expectLog(String target, String log) {
+      executeTarget(target);
+      String realLog = getLog();
+      assertEquals(log, realLog);
+   }
+
+   /**
+    * Assert that the given substring is in the log messages.
+    */
+   public void assertLogContaining(String substring) {
+      String realLog = getLog();
+      assertTrue("expecting log to contain \"" + substring + "\" log was \""
+        + realLog + "\"",
+        realLog.indexOf(substring) >= 0);
+   }
+
+   /**
+    * Assert that the given substring is in the output messages.
+    * @since Ant1.7
+    */
+   public void assertOutputContaining(String substring) {
+      String realOutput = getOutput();
+      assertTrue("expecting output to contain \"" + substring
+        + "\" output was \"" + realOutput + "\"",
+        realOutput.indexOf(substring) >= 0);
+   }
+
+   /**
+    * Assert that the given message has been logged with a priority
+    * &lt;= INFO when running the given target.
+    */
+   public void expectLogContaining(String target, String log) {
+      executeTarget(target);
+      assertLogContaining(log);
+   }
+
+   /**
+    * Gets the log the BuildFileTest object.
+    * Only valid if configureProject() has been called.
+    *
+    * @pre logBuffer!=null
+    * @return    The log value
+    */
+   public  String getLog() {
+      return logBuffer.toString();
+   }
+
+   /**
+    * Assert that the given message has been logged with a priority
+    * &gt;= VERBOSE when running the given target.
+    */
+   public void expectDebuglog(String target, String log) {
+      executeTarget(target);
+      String realLog = getFullLog();
+      assertEquals(log, realLog);
+   }
+
+   /**
+    * Assert that the given substring is in the log messages.
+    */
+   public void assertDebuglogContaining(String substring) {
+      String realLog = getFullLog();
+      assertTrue("expecting debug log to contain \"" + substring
+        + "\" log was \""
+        + realLog + "\"",
+        realLog.indexOf(substring) >= 0);
+   }
+
+   /**
+    * Gets the log the BuildFileTest object.
+    *
+    * Only valid if configureProject() has been called.
+    *
+    * @pre fullLogBuffer!=null
+    * @return    The log value
+    */
+   public String getFullLog() {
+      return fullLogBuffer.toString();
+   }
+
+   /**
+    * execute the target, verify output matches expectations
+    *
+    * @param  target  target to execute
+    * @param  output  output to look for
+    */
+   public void expectOutput(String target, String output) {
+      executeTarget(target);
+      String realOutput = getOutput();
+      assertEquals(output, realOutput.trim());
+   }
+
+   /**
+    * Executes the target, verify output matches expectations
+    * and that we got the named error at the end
+    *
+    * @param  target  target to execute
+    * @param  output  output to look for
+    * @param  error   Description of Parameter
+    */
+   public void expectOutputAndError(String target, String output, String error) {
+      executeTarget(target);
+      String realOutput = getOutput();
+      assertEquals(output, realOutput);
+      String realError = getError();
+      assertEquals(error, realError);
+   }
+
+   public String getOutput() {
+      return cleanBuffer(outBuffer);
+   }
+
+   public String getError() {
+      return cleanBuffer(errBuffer);
+   }
+
+   public BuildException getBuildException() {
+      return buildException;
+   }
+
+   private String cleanBuffer(StringBuffer buffer) {
+      StringBuffer cleanedBuffer = new StringBuffer();
+      boolean cr = false;
+      for (int i = 0; i < buffer.length(); i++) {
+         char ch = buffer.charAt(i);
+         if (ch == '\r') {
+            cr = true;
+            continue;
+         }
+
+         if (!cr) {
+            cleanedBuffer.append(ch);
+         } else {
+            cleanedBuffer.append(ch);
+         }
+      }
+      return cleanedBuffer.toString();
+   }
+
+   /**
+    * Sets up to run the named project
+    *
+    * @param  filename name of project file to run
+    */
+   public void configureProject(String filename) throws BuildException {
+      configureProject(filename, Project.MSG_DEBUG);
+   }
+
+   /**
+    * Sets up to run the named project
+    *
+    * @param  filename name of project file to run
+    */
+   public void configureProject(String filename, int logLevel)
+     throws BuildException {
+      logBuffer = new StringBuffer();
+      fullLogBuffer = new StringBuffer();
+      project = new Project();
+      project.init();
+      File antFile = new File(System.getProperty("root"), filename);
+      project.setUserProperty("ant.file" , antFile.getAbsolutePath());
+      project.addBuildListener(new AntTestListener(logLevel));
+      ProjectHelper.configureProject(project, antFile);
+   }
+
+   /**
+    * Executes a target we have set up
+    *
+    * @pre configureProject has been called
+    * @param  targetName  target to run
+    */
+   public void executeTarget(String targetName) {
+      PrintStream sysOut = System.out;
+      PrintStream sysErr = System.err;
+      try {
+         sysOut.flush();
+         sysErr.flush();
+         outBuffer = new StringBuffer();
+         PrintStream out = new PrintStream(new AntOutputStream(outBuffer));
+         System.setOut(out);
+         errBuffer = new StringBuffer();
+         PrintStream err = new PrintStream(new AntOutputStream(errBuffer));
+         System.setErr(err);
+         logBuffer = new StringBuffer();
+         fullLogBuffer = new StringBuffer();
+         buildException = null;
+         project.executeTarget(targetName);
+      } finally {
+         System.setOut(sysOut);
+         System.setErr(sysErr);
+      }
+
+   }
+
+   /**
+    * Get the project which has been configured for a test.
+    *
+    * @return the Project instance for this test.
+    */
+   public Project getProject() {
+      return project;
+   }
+
+   /**
+    * Gets the directory of the project.
+    *
+    * @return the base dir of the project
+    */
+   public File getProjectDir() {
+      return project.getBaseDir();
+   }
+
+   /**
+    * Runs a target, wait for a build exception.
+    *
+    * @param  target target to run
+    * @param  cause  information string to reader of report
+    * @param  msg    the message value of the build exception we are waiting
+    *         for set to null for any build exception to be valid
+    */
+   public void expectSpecificBuildException(String target, String cause, String msg) {
+      try {
+         executeTarget(target);
+      } catch (org.apache.tools.ant.BuildException ex) {
+         buildException = ex;
+         if ((null != msg) && (!ex.getMessage().equals(msg))) {
+            fail("Should throw BuildException because '" + cause
+              + "' with message '" + msg
+              + "' (actual message '" + ex.getMessage() + "' instead)");
+         }
+         return;
+      }
+      fail("Should throw BuildException because: " + cause);
+   }
+
+   /**
+    * run a target, expect an exception string
+    * containing the substring we look for (case sensitive match)
+    *
+    * @param  target target to run
+    * @param  cause  information string to reader of report
+    * @param  contains  substring of the build exception to look for
+    */
+   public void expectBuildExceptionContaining(String target, String cause, String contains) {
+      try {
+         executeTarget(target);
+      } catch (org.apache.tools.ant.BuildException ex) {
+         buildException = ex;
+         if ((null != contains) && (ex.getMessage().indexOf(contains) == -1)) {
+            fail("Should throw BuildException because '" + cause + "' with message containing '" + contains + "' (actual message '" + ex.getMessage() + "' instead)");
+         }
+         return;
+      }
+      fail("Should throw BuildException because: " + cause);
+   }
+
+   /**
+    * call a target, verify property is as expected
+    *
+    * @param target build file target
+    * @param property property name
+    * @param value expected value
+    */
+   public void expectPropertySet(String target, String property, String value) {
+      executeTarget(target);
+      assertPropertyEquals(property, value);
+   }
+
+   /**
+    * assert that a property equals a value; comparison is case sensitive.
+    *
+    * @param property property name
+    * @param value expected value
+    */
+   public void assertPropertyEquals(String property, String value) {
+      String result = project.getProperty(property);
+      assertEquals("property " + property,value,result);
+   }
+
+   /**
+    * assert that a property equals "true".
+    *
+    * @param property property name
+    */
+   public  void assertPropertySet(String property) {
+      assertPropertyEquals(property, "true");
+   }
+
+   /**
+    * assert that a property is null.
+    *
+    * @param property property name
+    */
+   public  void assertPropertyUnset(String property) {
+      assertPropertyEquals(property, null);
+   }
+
+   /**
+    * call a target, verify named property is "true".
+    *
+    * @param target build file target
+    * @param property property name
+    */
+   public  void expectPropertySet(String target, String property) {
+      expectPropertySet(target, property, "true");
+   }
+
+   /**
+    * Call a target, verify property is null.
+    *
+    * @param target build file target
+    * @param property property name
+    */
+   public  void expectPropertyUnset(String target, String property) {
+      expectPropertySet(target, property, null);
+   }
+
+   /**
+    * Retrieve a resource from the caller classloader to avoid
+    * assuming a vm working directory. The resource path must be
+    * relative to the package name or absolute from the root path.
+    *
+    * @param resource the resource to retrieve its url.
+    * @throws junit.framework.AssertionFailedError if the resource is not found.
+    */
+   public  URL getResource(String resource){
+      URL url = getClass().getResource(resource);
+      assertNotNull("Could not find resource :" + resource, url);
+      return url;
+   }
+
+   /**
+    * an output stream which saves stuff to our buffer.
+    */
+   private static class AntOutputStream extends java.io.OutputStream {
+      private StringBuffer buffer;
+
+      public AntOutputStream( StringBuffer buffer ) {
+         this.buffer = buffer;
+      }
+
+      public void write(int b) {
+         buffer.append((char)b);
+      }
+   }
+
+   /**
+    * Our own personal build listener.
+    */
+   private class AntTestListener implements BuildListener
+   {
+      private int logLevel;
+
+      /**
+       * Constructs a test listener which will ignore log events
+       * above the given level.
+       */
+      public AntTestListener(int logLevel) {
+         this.logLevel = logLevel;
+      }
+
+      /**
+       * Fired before any targets are started.
+       */
+      public void buildStarted(BuildEvent event) {
+      }
+
+      /**
+       * Fired after the last target has finished. This event
+       * will still be thrown if an error occurred during the build.
+       *
+       * @see BuildEvent#getException()
+       */
+      public void buildFinished(BuildEvent event) {
+      }
+
+      /**
+       * Fired when a target is started.
+       *
+       * @see BuildEvent#getTarget()
+       */
+      public void targetStarted(BuildEvent event) {
+         System.out.println("targetStarted " + event.getTarget().getName());
+      }
+
+      /**
+       * Fired when a target has finished. This event will
+       * still be thrown if an error occurred during the build.
+       *
+       * @see BuildEvent#getException()
+       */
+      public void targetFinished(BuildEvent event) {
+         System.out.println("targetFinished " + event.getTarget().getName());
+      }
+
+      /**
+       * Fired when a task is started.
+       *
+       * @see BuildEvent#getTask()
+       */
+      public void taskStarted(BuildEvent event) {
+         //System.out.println("taskStarted " + event.getTask().getTaskName());
+      }
+
+      /**
+       * Fired when a task has finished. This event will still
+       * be throw if an error occurred during the build.
+       *
+       * @see BuildEvent#getException()
+       */
+      public void taskFinished(BuildEvent event) {
+         //System.out.println("taskFinished " + event.getTask().getTaskName());
+      }
+
+      /**
+       * Fired whenever a message is logged.
+       *
+       * @see BuildEvent#getMessage()
+       * @see BuildEvent#getPriority()
+       */
+      public void messageLogged(BuildEvent event) {
+         if (event.getPriority() > logLevel) {
+            // ignore event
+            return;
+         }
+
+         if (event.getPriority() == Project.MSG_INFO ||
+           event.getPriority() == Project.MSG_WARN ||
+           event.getPriority() == Project.MSG_ERR) {
+            logBuffer.append(event.getMessage());
+         }
+         fullLogBuffer.append(event.getMessage());
+      }
+   }
+
+}
+

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+// We just need to load it, therefore we skip the JSR 181 annotations here
+public class CalculatorBean
+{
+   public int add(int a, int b)
+   {
+      return a+b;
+   }
+
+   public int subtract(int a, int b)
+   {
+      return a-b;
+   }
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.cmd.WSConsume;
+
+/**
+ * Test the command line interface to WSConsume.
+ *
+ * @author Heiko.Braun at jboss.com
+ */
+public class CmdConsumeTestCase extends CommandlineTestBase
+{
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      // cleanup events
+      CmdConsumeTracker.LAST_EVENT = "";
+      
+      // enforce loading of the tracker implemenation
+      System.setProperty(
+        "org.jboss.wsf.spi.tools.ConsumerFactoryImpl",
+        "org.jboss.test.wsf.spi.tools.CmdConsumeTrackerFactory"
+        );
+   }
+
+   public void testInvalidBindingOption() throws Exception
+   {
+      executeCmd("-b", true);
+   }
+
+   public void testValidBindingOption() throws Exception
+   {
+      executeCmd("-b binding-file.xml Service.wsdl", false);
+      assertTrue("setBindingFiles() not invoked",  CmdConsumeTracker.LAST_EVENT.indexOf("setBindingFiles")!=-1);
+   }
+
+   public void testMissingOptions() throws Exception
+   {
+      executeCmd(null, true);
+   }
+
+   // TODO: add arbitrary combinations on a case by case basis
+
+
+   void runDelegate(String[] args) throws Exception
+   {
+      WSConsume.main(args);
+   }
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.List;
+import java.net.URL;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ */
+public class CmdConsumeTracker extends WSContractConsumer
+{
+   public static String LAST_EVENT = "";
+
+   @Override
+   public void setBindingFiles(List<File> bindingFiles)
+   {
+      LAST_EVENT += "setBindingFiles";
+   }
+
+   @Override
+   public void setCatalog(File catalog)
+   {
+      LAST_EVENT += "setCatalog";
+   }
+
+   @Override
+   public void setOutputDirectory(File directory)
+   {
+      LAST_EVENT += "setOutputDirectory";
+   }
+
+   @Override
+   public void setSourceDirectory(File directory)
+   {
+      LAST_EVENT += "setSourceDirectory";
+   }
+
+   @Override
+   public void setGenerateSource(boolean generateSource)
+   {
+      LAST_EVENT += "setGenerateSource";
+   }
+
+   @Override
+   public void setTargetPackage(String targetPackage)
+   {
+      LAST_EVENT += "setTargetPackage";
+   }
+
+   @Override
+   public void setWsdlLocation(String wsdlLocation)
+   {
+      LAST_EVENT += "setWsdlLocation";
+   }
+
+   @Override
+   public void setMessageStream(PrintStream messageStream)
+   {
+      LAST_EVENT += "setMessageStream";
+   }
+
+   @Override
+   public void setAdditionalCompilerClassPath(List<String> classPath)
+   {
+      LAST_EVENT += "setAdditionalCompilerClassPath";
+   }
+   
+   @Override
+   public void setAdditionalHeaders(boolean additionalHeaders)
+   {
+      LAST_EVENT += "setAdditionalHeaders";
+   }
+
+   @Override
+   public void setTarget(String target)
+   {
+      LAST_EVENT += "setTarget";
+   }
+
+   @Override
+   public void consume(URL wsdl)
+   {
+      LAST_EVENT += "consume";
+   }
+
+   @Override
+   public void setExtension(boolean extension)
+   {
+      LAST_EVENT += "setExtension";
+   }
+
+   @Override
+   public void setNoCompile(boolean nocompile)
+   {
+      LAST_EVENT += "setNoCompile";
+   }
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractConsumerFactory;
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ */
+public class CmdConsumeTrackerFactory implements WSContractConsumerFactory
+{
+
+   public WSContractConsumer createConsumer()
+   {
+      return new CmdConsumeTracker();
+   }
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.cmd.WSProvide;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ */
+public class CmdProvideTestCase extends CommandlineTestBase
+{
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      // clear events
+      CmdProvideTracker.LAST_EVENT = "";
+
+      // enforce loading of the tracker implemenation
+      System.setProperty(
+        "org.jboss.wsf.spi.tools.ProviderFactoryImpl",
+        "org.jboss.test.wsf.spi.tools.CmdProvideTrackerFactory"
+      );
+   }
+
+   /** <pre>
+ *  usage: WSProvideTask [options] &lt;endpoint class name&gt;
+ *  options:
+ *  -h, --help                  Show this help message
+ *  -k, --keep                  Keep/Generate Java source
+ *  -w, --wsdl                  Enable WSDL file generation
+ *  -c, --classpath=&lt;path&lt;      The classpath that contains the endpoint
+ *  -o, --output=&lt;directory&gt;    The directory to put generated artifacts
+ *  -r, --resource=&lt;directory&gt;  The directory to put resource artifacts
+ *  -s, --source=&lt;directory&gt;    The directory to put Java source
+ *  -q, --quiet                 Be somewhat more quiet
+ *  -t, --show-traces           Show full exception stack traces
+ *  -l, --load-provider           Load the provider and exit (debug utility)
+ * </pre>
+    * */
+
+   public void testMissingOptions() throws Exception
+   {
+      executeCmd(null, true);   
+   }
+
+   public void testValidOutputDir() throws Exception
+   {
+      executeCmd("-o outputDir org.jboss.test.wsf.spi.tools.CalculatorBean", false);
+      assertTrue("setOutputDirectory() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("setOutputDirectory")!=-1);
+   }
+
+   void runDelegate(String[] args) throws Exception
+   {
+      WSProvide.main(args);
+   }
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+import java.io.File;
+import java.io.PrintStream;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ */
+public class CmdProvideTracker extends WSContractProvider
+{
+
+   public static String LAST_EVENT = "";
+
+   public void setGenerateWsdl(boolean generateWsdl)
+   {
+      LAST_EVENT += "setGenerateWsdl";
+   }
+
+   public void setExtension(boolean extension)
+   {
+      LAST_EVENT += "setExtension";
+   }
+
+   public void setGenerateSource(boolean generateSource)
+   {
+      LAST_EVENT += "setGenerateSource";
+   }
+
+   public void setOutputDirectory(File directory)
+   {
+      LAST_EVENT += "setOutputDirectory";
+   }
+
+   public void setResourceDirectory(File directory)
+   {
+      LAST_EVENT += "setResourceDirectory";
+   }
+
+   public void setSourceDirectory(File directory)
+   {
+      LAST_EVENT += "setSourceDirectory";
+   }
+
+   public void setClassLoader(ClassLoader loader)
+   {
+      LAST_EVENT += "setClassLoader";
+   }
+
+   public void provide(String endpointClass)
+   {
+      LAST_EVENT += "provide";   
+   }
+
+   public void provide(Class<?> endpointClass)
+   {
+      LAST_EVENT += "provide";
+   }
+
+   public void setMessageStream(PrintStream messageStream)
+   {
+      LAST_EVENT += "setMessageStream";
+   }
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractProviderFactory;
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ */
+public class CmdProvideTrackerFactory implements WSContractProviderFactory
+{
+
+   public WSContractProvider createProvider(ClassLoader loader)
+   {
+      return new CmdProvideTracker();  
+   }
+}

Added: common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java
===================================================================
--- common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java	                        (rev 0)
+++ common-tools/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import junit.framework.TestCase;
+
+import java.security.Permission;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ */
+public abstract class CommandlineTestBase extends TestCase
+{
+   SecurityManager systemDefault = System.getSecurityManager();
+   SecurityManager interceptor = new InterceptedSecurity();
+
+   protected void swapSecurityManager()
+   {
+      if(System.getSecurityManager() instanceof InterceptedSecurity)
+         System.setSecurityManager(systemDefault);
+      else
+         System.setSecurityManager(interceptor);
+   }
+
+   class InterceptedSecurity extends  SecurityManager
+   {
+      private final SecurityManager parent = systemDefault;
+
+      public void checkPermission(Permission perm)
+      {
+         if (parent != null)
+         {
+            parent.checkPermission(perm);
+         }
+      }
+
+      public void checkExit(int status)
+      {
+         String msg = (status == 0) ? "Delegate did exit without errors" : "Delegate did exit with an error";
+         throw new InterceptedExit(msg, status);
+      }
+   }
+
+   static protected class InterceptedExit extends SecurityException
+   {
+      private static final long serialVersionUID = 1L;
+      private int exitCode;
+
+      public InterceptedExit(String s, int code)
+      {
+         super(s);
+         this.exitCode = code;
+      }
+
+
+      public int getExitCode()
+      {
+         return exitCode;
+      }
+   }
+
+   protected void executeCmd(String arguments,  boolean expectedException) throws Exception
+   {
+      swapSecurityManager();
+
+      String[] args = arguments!=null ? arguments.split("\\s"): new String[0];
+      try
+      {
+         runDelegate(args);
+         if(expectedException)
+            fail("Did expect exception on args: " +args);
+      }
+      catch (CommandlineTestBase.InterceptedExit e)
+      {
+         boolean positivStatus = (e.getExitCode() == 0);
+         if( (expectedException && positivStatus)
+           || (!expectedException && !positivStatus) )
+         {
+            String s = expectedException ? "Did expect an exception, but " : "Did not expect an exception, but ";
+            String s2 = positivStatus ? "status was positiv" : "status was negativ";
+            throw new Exception(s+s2);
+         }
+
+      }
+      finally
+      {
+         swapSecurityManager();
+      }
+   }
+
+   // the actual tools execution
+   abstract void runDelegate(String[] args) throws Exception;
+   
+}

Added: common-tools/src/test/resources/smoke/tools/consume-test.xml
===================================================================
--- common-tools/src/test/resources/smoke/tools/consume-test.xml	                        (rev 0)
+++ common-tools/src/test/resources/smoke/tools/consume-test.xml	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+    <!--
+       An example build file that used to test the WSConsume Task
+    -->
+    
+<project name="consume-test" basedir=".">
+
+  <property name="spi.dir" value="@SPI_DIR@"/>
+
+  <!-- Define the JAX-WS wsconsume task -->
+  <taskdef name="wsconsume" classname="org.jboss.wsf.spi.tools.ant.WSConsumeTask">
+    <classpath>
+      <pathelement location="${spi.dir}/output/lib/jbossws-spi.jar"/>
+    </classpath>
+  </taskdef>
+
+  <target name="plainInvocation">
+     <wsconsume wsdl="Service.wsdl" verbose="true"/>
+   </target>
+
+</project>
\ No newline at end of file

Added: common-tools/src/test/resources/smoke/tools/provide-test.xml
===================================================================
--- common-tools/src/test/resources/smoke/tools/provide-test.xml	                        (rev 0)
+++ common-tools/src/test/resources/smoke/tools/provide-test.xml	2011-04-18 11:04:20 UTC (rev 14136)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   An example build file that used to test the WSConsume Task
+-->
+
+<project name="provide-test" basedir=".">
+
+  <property name="spi.dir" value="@SPI_DIR@"/>
+
+  <!-- Define the JAX-WS wsconsume task -->
+  <taskdef name="wsprovide" classname="org.jboss.wsf.spi.tools.ant.WSProvideTask">
+    <classpath>
+      <pathelement location="${spi.dir}/output/lib/jbossws-spi.jar"/>
+    </classpath>
+  </taskdef>
+
+  <target name="plainInvocation">
+    <wsprovide genwsdl="false" sei="org.jboss.test.wsf.spi.smoke.tools.CalculatorBean"/>
+  </target>
+
+  <target name="includeWSDL">
+    <wsprovide genwsdl="true" sei="org.jboss.test.wsf.spi.smoke.tools.CalculatorBean"/>
+  </target>
+
+  <target name="extraClasspath">
+    <wsprovide genwsdl="false" sei="org.jboss.test.wsf.spi.smoke.tools.CalculatorBean">
+      <classpath>
+        <pathelement location="${spi.dir}/output/test/classes"/>
+      </classpath>
+    </wsprovide>
+  </target>
+</project>
\ No newline at end of file



More information about the jbossws-commits mailing list