Author: veithen Date: Fri Jul 3 22:53:59 2015 New Revision: 1689104 URL: http://svn.apache.org/r1689104 Log: Support the -Daxis.server.foreground=true flag also for Jetty instances started by the axis-server:start-webapp goal.
Added: axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/AbstractStartWebServerMojo.java (with props) Modified: axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartServerMojo.java axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java axis/axis1/java/trunk/tests/spring-compat-tests/pom.xml Added: axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/AbstractStartWebServerMojo.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/AbstractStartWebServerMojo.java?rev=1689104&view=auto ============================================================================== --- axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/AbstractStartWebServerMojo.java (added) +++ axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/AbstractStartWebServerMojo.java Fri Jul 3 22:53:59 2015 @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.axis.tools.maven.server; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; + +public abstract class AbstractStartWebServerMojo extends AbstractStartDaemonMojo { + /** + * The HTTP port. + * + * @parameter default-value="8080" + * @required + */ + private int port; + + /** + * If this flag is set to <code>true</code>, then the execution of the goal will block after the + * server has been started. This is useful if one wants to manually test some services deployed + * on the server or if one wants to run the integration tests from an IDE. The flag should only + * be set using the command line, but not in the POM. + * + * @parameter expression="${axis.server.foreground}" default-value="false" + */ + // Note: this feature is implemented using a flag (instead of a distinct goal) to make sure that + // the server is configured in exactly the same way as in a normal integration test execution. + private boolean foreground; + + /** + * Specifies an alternate port number that will override {@link #port} if {@link #foreground} is + * set to <code>true</code>. This parameter should be used if the port number configured with + * the {@link #port} parameter is allocated dynamically. This makes it easier to run integration + * tests from an IDE. For more information, see the <a href="usage.html">usage + * documentation</a>. + * + * @parameter + */ + private int foregroundPort = -1; + + protected final void doStartDaemon() throws MojoExecutionException, MojoFailureException { + Log log = getLog(); + + doStartDaemon(foreground && foregroundPort != -1 ? foregroundPort : port); + + if (foreground) { + log.info("Server started in foreground mode. Press CRTL-C to stop."); + Object lock = new Object(); + synchronized (lock) { + try { + lock.wait(); + } catch (InterruptedException ex) { + // Set interrupt flag and continue + Thread.currentThread().interrupt(); + } + } + } + } + + protected abstract void doStartDaemon(int port) throws MojoExecutionException, MojoFailureException; +} Propchange: axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/AbstractStartWebServerMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartServerMojo.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartServerMojo.java?rev=1689104&r1=1689103&r2=1689104&view=diff ============================================================================== --- axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartServerMojo.java (original) +++ axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartServerMojo.java Fri Jul 3 22:53:59 2015 @@ -31,7 +31,6 @@ import org.apache.axis.model.wsdd.Deploy import org.apache.axis.model.wsdd.WSDDUtil; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; @@ -45,7 +44,7 @@ import org.xml.sax.InputSource; * @phase pre-integration-test * @requiresDependencyResolution test */ -public class StartServerMojo extends AbstractStartDaemonMojo { +public class StartServerMojo extends AbstractStartWebServerMojo { /** * @parameter default-value="${project.build.directory}/axis-server" * @required @@ -54,14 +53,6 @@ public class StartServerMojo extends Abs private File workDirBase; /** - * The port of the Axis server. - * - * @parameter default-value="8080" - * @required - */ - private int port; - - /** * The maximum number of concurrently active sessions. * * @parameter default-value="100" @@ -90,43 +81,15 @@ public class StartServerMojo extends Abs */ private FileSet[] configs; - /** - * If this flag is set to <code>true</code>, then the execution of the goal will block after the - * server has been started and the services are deployed. This is useful if one wants to - * manually test some services deployed on the server or if one wants to run the integration - * tests from an IDE. The flag should only be set using the command line, but not in the POM. - * - * @parameter expression="${axis.server.foreground}" default-value="false" - */ - // Note: this feature is implemented using a flag (instead of a distinct goal) to make sure that - // the server is configured in exactly the same way as in a normal integration test execution. - private boolean foreground; - - /** - * Specifies an alternate port number that will override {@link #port} if {@link #foreground} is - * set to <code>true</code>. This parameter should be used if the port number configured with - * the {@link #port} parameter is allocated dynamically. This makes it easier to run integration - * tests from an IDE. For more information, see the <a href="usage.html">usage - * documentation</a>. - * - * @parameter - */ - private int foregroundPort = -1; - - protected void doStartDaemon() throws MojoExecutionException, MojoFailureException { - Log log = getLog(); - + protected void doStartDaemon(int port) throws MojoExecutionException, MojoFailureException { // Need to setup additional dependencies before building the default configuration! addAxisDependency("axis-standalone-server"); if (jwsDirs != null && jwsDirs.length > 0) { addAxisDependency("axis-rt-jws"); } - // Determine the port to be used - int actualPort = foreground && foregroundPort != -1 ? foregroundPort : port; - // Prepare a work directory where we can place the server-config.wsdd file - File workDir = new File(workDirBase, String.valueOf(actualPort)); + File workDir = new File(workDirBase, String.valueOf(port)); if (workDir.exists()) { try { FileUtils.deleteDirectory(workDir); @@ -198,7 +161,7 @@ public class StartServerMojo extends Abs // Start the server List args = new ArrayList(); args.add("-p"); - args.add(String.valueOf(actualPort)); + args.add(String.valueOf(port)); args.add("-w"); args.add(workDir.getAbsolutePath()); if (jwsDirs != null && jwsDirs.length > 0) { @@ -209,26 +172,13 @@ public class StartServerMojo extends Abs args.add(String.valueOf(maxSessions)); try { startDaemon( - "Server on port " + actualPort, + "Server on port " + port, "org.apache.axis.server.standalone.daemon.AxisServerDaemon", (String[])args.toArray(new String[args.size()]), workDir); } catch (Exception ex) { throw new MojoFailureException("Failed to start server", ex); } - - if (foreground) { - log.info("Server started in foreground mode. Press CRTL-C to stop."); - Object lock = new Object(); - synchronized (lock) { - try { - lock.wait(); - } catch (InterruptedException ex) { - // Set interrupt flag and continue - Thread.currentThread().interrupt(); - } - } - } } private ClassLoader buildClassLoader() throws MojoExecutionException { Modified: axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java?rev=1689104&r1=1689103&r2=1689104&view=diff ============================================================================== --- axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java (original) +++ axis/axis1/java/trunk/maven/axis-server-maven-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java Fri Jul 3 22:53:59 2015 @@ -31,15 +31,7 @@ import org.codehaus.plexus.util.StringUt * @phase pre-integration-test * @requiresDependencyResolution test */ -public class StartWebAppMojo extends AbstractStartDaemonMojo { - /** - * The HTTP port. - * - * @parameter default-value="8080" - * @required - */ - private int port; - +public class StartWebAppMojo extends AbstractStartWebServerMojo { /** * * @@ -48,7 +40,7 @@ public class StartWebAppMojo extends Abs */ private File[] resourceBases; - protected void doStartDaemon() throws MojoExecutionException, MojoFailureException { + protected void doStartDaemon(int port) throws MojoExecutionException, MojoFailureException { addAxisDependency("jetty-daemon"); startDaemon("HTTP server on port " + port, "org.apache.axis.tools.daemon.jetty.WebAppDaemon", new String[] { "-p", String.valueOf(port), "-r", StringUtils.join(resourceBases, File.pathSeparator) }, new File(".")); Modified: axis/axis1/java/trunk/tests/spring-compat-tests/pom.xml URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/tests/spring-compat-tests/pom.xml?rev=1689104&r1=1689103&r2=1689104&view=diff ============================================================================== --- axis/axis1/java/trunk/tests/spring-compat-tests/pom.xml (original) +++ axis/axis1/java/trunk/tests/spring-compat-tests/pom.xml Fri Jul 3 22:53:59 2015 @@ -122,6 +122,7 @@ </goals> <configuration> <port>${test.httpPort}</port> + <foregroundPort>8080</foregroundPort> <resourceBases> <resourceBase>src/main/webapp</resourceBase> <resourceBase>${project.build.directory}/webapp</resourceBase>