[jbossws-commits] JBossWS SVN: r13004 - projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Wed Sep 22 08:32:30 EDT 2010
Author: alessio.soldano at jboss.com
Date: 2010-09-22 08:32:30 -0400 (Wed, 22 Sep 2010)
New Revision: 13004
Added:
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/MavenLogStreamConsumer.java
Modified:
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractWsConsumeMojo.java
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractWsProvideMojo.java
projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/WSContractDelegate.java
Log:
Use proper logger and leverage CommandLineUtils for fork mode
Modified: projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractWsConsumeMojo.java
===================================================================
--- projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractWsConsumeMojo.java 2010-09-22 09:21:56 UTC (rev 13003)
+++ projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractWsConsumeMojo.java 2010-09-22 12:32:30 UTC (rev 13004)
@@ -131,7 +131,7 @@
params.setWsdlLocation(wsdlLocation);
params.setArgLine(argLine);
params.setFork(fork);
- WSContractDelegate delegate = new WSContractDelegate();
+ WSContractDelegate delegate = new WSContractDelegate(getLog());
for (String wsdl : wsdls)
{
Modified: projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractWsProvideMojo.java
===================================================================
--- projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractWsProvideMojo.java 2010-09-22 09:21:56 UTC (rev 13003)
+++ projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/AbstractWsProvideMojo.java 2010-09-22 12:32:30 UTC (rev 13004)
@@ -102,7 +102,7 @@
params.setFork(fork);
params.setArgLine(argLine);
- WSContractDelegate delegate = new WSContractDelegate();
+ WSContractDelegate delegate = new WSContractDelegate(getLog());
delegate.runProvider(params);
updateProjectSourceRoots();
Added: projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/MavenLogStreamConsumer.java
===================================================================
--- projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/MavenLogStreamConsumer.java (rev 0)
+++ projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/MavenLogStreamConsumer.java 2010-09-22 12:32:30 UTC (rev 13004)
@@ -0,0 +1,65 @@
+/*
+ * 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.ws.plugins.tools;
+
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * A StreamConsumer that redirects logs to the maven log system
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 22-Sep-2010
+ */
+public class MavenLogStreamConsumer implements StreamConsumer
+{
+
+ public static enum Type {
+ OUTPUT, ERROR
+ }
+ private final Type type;
+ private final Log log;
+
+ public MavenLogStreamConsumer(Log log, Type type)
+ {
+ this.log = log;
+ this.type = type;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
+ */
+ public void consumeLine(String line)
+ {
+ if (Type.ERROR.equals(type))
+ {
+ log.error(line);
+ }
+ else
+ {
+ log.info(line);
+ }
+ }
+
+}
Modified: projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/WSContractDelegate.java
===================================================================
--- projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/WSContractDelegate.java 2010-09-22 09:21:56 UTC (rev 13003)
+++ projects/plugins/maven/jaxws-tools/trunk/src/main/java/org/jboss/ws/plugins/tools/WSContractDelegate.java 2010-09-22 12:32:30 UTC (rev 13004)
@@ -29,12 +29,21 @@
import java.util.LinkedList;
import java.util.List;
-import org.codehaus.plexus.util.Os;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.jboss.ws.plugins.tools.MavenLogStreamConsumer.Type;
public class WSContractDelegate
{
private static final PrintStream PS = System.out;
+ private Log log;
+ public WSContractDelegate(Log log)
+ {
+ this.log = log;
+ }
+
public void runProvider(WSContractProviderParams params) throws Exception
{
if (params.isFork())
@@ -68,9 +77,15 @@
List<String> commandList = initCommandList(params.getArgLine(), classpath, "org.jboss.wsf.spi.tools.cmd.WSProvide");
String commandLine = getProviderCommandLine(commandList, params);
- System.out.println("*oooooooooooooooooooooooooo* commandline: ***" + commandLine +"*oooooooooooooooooooo*");
- Process p = Runtime.getRuntime().exec(commandLine);
- int result = p.waitFor();
+ if (log.isDebugEnabled())
+ {
+ log.debug("Running command line: " + commandLine);
+ }
+
+ MavenLogStreamConsumer out = new MavenLogStreamConsumer(log, Type.OUTPUT);
+ MavenLogStreamConsumer err = new MavenLogStreamConsumer(log, Type.ERROR);
+ int result = CommandLineUtils.executeCommandLine(new Commandline(commandLine), out, err);
+
if (result != 0)
{
throw new Exception("Process terminated with code " + result);
@@ -104,9 +119,15 @@
List<String> commandList = initCommandList(params.getArgLine(), params.getAdditionalCompilerClassPath(), "org.jboss.wsf.spi.tools.cmd.WSConsume");
String commandLine = getConsumerCommandLine(commandList, params, wsdl);
- System.out.println("************** commandline: ***" + commandLine +"***");
- Process p = Runtime.getRuntime().exec(commandLine);
- int result = p.waitFor();
+ if (log.isDebugEnabled())
+ {
+ log.debug("Running command line: " + commandLine);
+ }
+
+ MavenLogStreamConsumer out = new MavenLogStreamConsumer(log, Type.OUTPUT);
+ MavenLogStreamConsumer err = new MavenLogStreamConsumer(log, Type.ERROR);
+ int result = CommandLineUtils.executeCommandLine(new Commandline(commandLine), out, err);
+
if (result != 0)
{
throw new Exception("Process terminated with code " + result);
@@ -116,17 +137,6 @@
private static List<String> initCommandList(String argLine, List<String> classpath, String toolClass)
{
List<String> commandList = new ArrayList<String>();
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- if ( Os.isFamily( Os.FAMILY_WIN9X ) )
- {
- commandList.add("command.com /c");
- }
- else
- {
- commandList.add("cmd.exe /c");
- }
- }
commandList.add("java");
if (argLine != null)
{
More information about the jbossws-commits
mailing list