Author: veithen Date: Tue Dec 11 19:22:12 2012 New Revision: 1420339 URL: http://svn.apache.org/viewvc?rev=1420339&view=rev Log: Added a goal to the maven-axis-server-plugin that allows to run a Jetty instance in a separate JVM (and that is more convenient than jetty-maven-plugin).
Added: axis/axis1/java/trunk/jetty-daemon/ (with props) axis/axis1/java/trunk/jetty-daemon/pom.xml (with props) axis/axis1/java/trunk/jetty-daemon/src/ axis/axis1/java/trunk/jetty-daemon/src/main/ axis/axis1/java/trunk/jetty-daemon/src/main/java/ axis/axis1/java/trunk/jetty-daemon/src/main/java/org/ axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/ axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/ axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/tools/ axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/tools/daemon/ axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/tools/daemon/jetty/ axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/tools/daemon/jetty/WebAppDaemon.java (with props) axis/axis1/java/trunk/maven/maven-axis-server-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java (with props) Modified: axis/axis1/java/trunk/axis-standalone-server/pom.xml axis/axis1/java/trunk/pom.xml axis/axis1/java/trunk/tests/spring-compat-tests/pom.xml Modified: axis/axis1/java/trunk/axis-standalone-server/pom.xml URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-standalone-server/pom.xml?rev=1420339&r1=1420338&r2=1420339&view=diff ============================================================================== --- axis/axis1/java/trunk/axis-standalone-server/pom.xml (original) +++ axis/axis1/java/trunk/axis-standalone-server/pom.xml Tue Dec 11 19:22:12 2012 @@ -46,17 +46,14 @@ <dependency> <groupId>commons-cli</groupId> <artifactId>commons-cli</artifactId> - <version>1.2</version> </dependency> <dependency> <groupId>commons-daemon</groupId> <artifactId>commons-daemon</artifactId> </dependency> <dependency> - <!-- Jetty 6.1 is the last version with support for Java 1.4 --> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty</artifactId> - <version>6.1.26</version> </dependency> </dependencies> <build> Propchange: axis/axis1/java/trunk/jetty-daemon/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Dec 11 19:22:12 2012 @@ -0,0 +1,4 @@ +.classpath +.project +target +.settings Added: axis/axis1/java/trunk/jetty-daemon/pom.xml URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/jetty-daemon/pom.xml?rev=1420339&view=auto ============================================================================== --- axis/axis1/java/trunk/jetty-daemon/pom.xml (added) +++ axis/axis1/java/trunk/jetty-daemon/pom.xml Tue Dec 11 19:22:12 2012 @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> +<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> + <parent> + <groupId>org.apache.axis</groupId> + <artifactId>axis-project</artifactId> + <version>1.4.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>jetty-daemon</artifactId> + <name>Jetty Daemon</name> + <description> + Daemon implementation used by maven-axis-server-plugin to launch a Jetty server in a separate JVM. + </description> + <dependencies> + <dependency> + <groupId>commons-daemon</groupId> + <artifactId>commons-daemon</artifactId> + </dependency> + <dependency> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> + </dependency> + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty</artifactId> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <configuration> + <skip>true</skip> + <skipDeploy>true</skipDeploy> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: axis/axis1/java/trunk/jetty-daemon/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/tools/daemon/jetty/WebAppDaemon.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/tools/daemon/jetty/WebAppDaemon.java?rev=1420339&view=auto ============================================================================== --- axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/tools/daemon/jetty/WebAppDaemon.java (added) +++ axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/tools/daemon/jetty/WebAppDaemon.java Tue Dec 11 19:22:12 2012 @@ -0,0 +1,85 @@ +/* + * 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.daemon.jetty; + +import java.io.File; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; +import org.apache.commons.daemon.Daemon; +import org.apache.commons.daemon.DaemonContext; +import org.apache.commons.daemon.DaemonInitException; +import org.mortbay.jetty.Server; +import org.mortbay.jetty.webapp.WebAppContext; +import org.mortbay.resource.Resource; +import org.mortbay.resource.ResourceCollection; + +/** + * + * + * @author Andreas Veithen + */ +public class WebAppDaemon implements Daemon { + private Server server; + + public void init(DaemonContext daemonContext) throws DaemonInitException, Exception { + Options options = new Options(); + + { + Option option = new Option("p", true, "the HTTP port"); + option.setArgName("port"); + option.setRequired(true); + options.addOption(option); + } + + { + Option option = new Option("r", true, "a list of resource directories"); + option.setArgName("dirs"); + option.setRequired(true); + options.addOption(option); + } + + CommandLineParser parser = new GnuParser(); + CommandLine cmdLine = parser.parse(options, daemonContext.getArguments()); + + server = new Server(Integer.parseInt(cmdLine.getOptionValue("p"))); + WebAppContext context = new WebAppContext(server, null, "/"); + String[] resourceDirs = cmdLine.getOptionValue("r").split(File.pathSeparator); + Resource[] resources = new Resource[resourceDirs.length]; + for (int i=0; i<resourceDirs.length; i++) { + resources[i] = Resource.newResource(resourceDirs[i]); + } + context.setBaseResource(new ResourceCollection(resources)); + } + + public void start() throws Exception { + server.start(); + } + + public void stop() throws Exception { + server.stop(); + } + + public void destroy() { + server = null; + } +} Propchange: axis/axis1/java/trunk/jetty-daemon/src/main/java/org/apache/axis/tools/daemon/jetty/WebAppDaemon.java ------------------------------------------------------------------------------ svn:eol-style = native Added: axis/axis1/java/trunk/maven/maven-axis-server-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/maven/maven-axis-server-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java?rev=1420339&view=auto ============================================================================== --- axis/axis1/java/trunk/maven/maven-axis-server-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java (added) +++ axis/axis1/java/trunk/maven/maven-axis-server-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java Tue Dec 11 19:22:12 2012 @@ -0,0 +1,56 @@ +/* + * 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 java.io.File; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.codehaus.plexus.util.StringUtils; + +/** + * + * + * @goal start-webapp + * @phase pre-integration-test + * @requiresDependencyResolution test + */ +public class StartWebAppMojo extends AbstractStartDaemonMojo { + /** + * The HTTP port. + * + * @parameter default-value="8080" + * @required + */ + private int port; + + /** + * + * + * @parameter + * @required + */ + private File[] resourceBases; + + protected void doStartDaemon() 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(".")); + } +} Propchange: axis/axis1/java/trunk/maven/maven-axis-server-plugin/src/main/java/org/apache/axis/tools/maven/server/StartWebAppMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: axis/axis1/java/trunk/pom.xml URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/pom.xml?rev=1420339&r1=1420338&r2=1420339&view=diff ============================================================================== --- axis/axis1/java/trunk/pom.xml (original) +++ axis/axis1/java/trunk/pom.xml Tue Dec 11 19:22:12 2012 @@ -83,6 +83,7 @@ <module>distribution</module> <module>integration</module> <module>interop-mock</module> + <module>jetty-daemon</module> <module>maven</module> <module>samples</module> <module>soapmonitor-applet</module> @@ -137,6 +138,17 @@ <artifactId>commons-daemon</artifactId> <version>1.0.10</version> </dependency> + <dependency> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> + <version>1.2</version> + </dependency> + <dependency> + <!-- Jetty 6.1 is the last version with support for Java 1.4 --> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty</artifactId> + <version>6.1.26</version> + </dependency> </dependencies> </dependencyManagement> <prerequisites> 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=1420339&r1=1420338&r2=1420339&view=diff ============================================================================== --- axis/axis1/java/trunk/tests/spring-compat-tests/pom.xml (original) +++ axis/axis1/java/trunk/tests/spring-compat-tests/pom.xml Tue Dec 11 19:22:12 2012 @@ -105,7 +105,6 @@ <phase>pre-integration-test</phase> <configuration> <portNames> - <portName>jetty.stopPort</portName> <portName>test.httpPort</portName> </portNames> </configuration> @@ -113,39 +112,27 @@ </executions> </plugin> <plugin> - <groupId>org.mortbay.jetty</groupId> - <artifactId>jetty-maven-plugin</artifactId> - <configuration> - <stopKey>foo</stopKey> - <stopPort>${jetty.stopPort}</stopPort> - <connectors> - <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> - <port>${test.httpPort}</port> - </connector> - </connectors> - <webApp> - <resourceBases> - <resourceBase>${basedir}/src/main/webapp</resourceBase> - <resourceBase>${project.build.directory}/webapp</resourceBase> - </resourceBases> - </webApp> - </configuration> + <groupId>${project.groupId}</groupId> + <artifactId>maven-axis-server-plugin</artifactId> + <version>${project.version}</version> <executions> <execution> - <id>start-jetty</id> - <phase>pre-integration-test</phase> + <id>start-webapp</id> <goals> - <goal>run</goal> + <goal>start-webapp</goal> </goals> <configuration> - <daemon>true</daemon> + <port>${test.httpPort}</port> + <resourceBases> + <resourceBase>src/main/webapp</resourceBase> + <resourceBase>${project.build.directory}/webapp</resourceBase> + </resourceBases> </configuration> </execution> <execution> - <id>stop-jetty</id> - <phase>post-integration-test</phase> + <id>stop-all</id> <goals> - <goal>stop</goal> + <goal>stop-all</goal> </goals> </execution> </executions>