From 02508ecec9c4c6a7ce88b58dc86fe06b5a9d3891 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 31 Mar 2011 18:29:04 +0000 Subject: Add start of a way to run webapps from the tuscany plugin git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1087400 13f79535-47bb-0310-9956-ffa450edef68 --- .../trunk/maven/maven-tuscany-plugin/pom.xml | 41 ++++++++++++++++------ .../tuscany/maven/plugin/TuscanyRunMojo.java | 33 +++++++++++++++++ 2 files changed, 63 insertions(+), 11 deletions(-) (limited to 'sca-java-2.x/trunk') diff --git a/sca-java-2.x/trunk/maven/maven-tuscany-plugin/pom.xml b/sca-java-2.x/trunk/maven/maven-tuscany-plugin/pom.xml index a6057e528b..8fec7956f5 100644 --- a/sca-java-2.x/trunk/maven/maven-tuscany-plugin/pom.xml +++ b/sca-java-2.x/trunk/maven/maven-tuscany-plugin/pom.xml @@ -48,7 +48,6 @@ maven-artifact 2.0.3 - org.apache.tuscany.sca tuscany-base-runtime @@ -59,16 +58,36 @@ tuscany-domain-hazelcast 2.0-SNAPSHOT - - jline - jline - 0.9.95-huynhjl - - - org.mortbay.jetty - jetty - 6.1.19 - + + jline + jline + 0.9.95-huynhjl + + + org.apache.tomcat.embed + tomcat-embed-core + 7.0.8 + + + org.apache.tomcat.embed + tomcat-embed-logging-juli + 7.0.8 + + + org.apache.tomcat.embed + tomcat-embed-jasper + 7.0.8 + + + org.apache.tomcat + tomcat-jasper-el + 7.0.8 + + + org.eclipse.jdt.core.compiler + ecj + 3.5.1 + diff --git a/sca-java-2.x/trunk/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java b/sca-java-2.x/trunk/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java index 4b9e523740..312e4f0e5f 100644 --- a/sca-java-2.x/trunk/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java +++ b/sca-java-2.x/trunk/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java @@ -26,6 +26,12 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.List; +import javax.servlet.ServletException; + +import org.apache.catalina.LifecycleException; +import org.apache.catalina.core.AprLifecycleListener; +import org.apache.catalina.core.StandardServer; +import org.apache.catalina.startup.Tomcat; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -114,11 +120,38 @@ public class TuscanyRunMojo extends AbstractMojo { public void execute() throws MojoExecutionException, MojoFailureException { if (mainClass != null) { executeMainMethod(); + } else if (".war".equals(packaging)) { + try { + executeTomcat(); + } catch (Exception e) { + throw new MojoExecutionException("Exception running Tuscany/Tomcat", e); + } } else { executeShell(); } } + private void executeTomcat() throws ServletException, LifecycleException, MalformedURLException { + getLog().info("Starting Tuscany/Tomcat..."); + + Tomcat tomcat = new Tomcat(); + tomcat.setPort(8080); + + tomcat.setBaseDir("target"); + String appBase = "../src/main/webapp"; + tomcat.getHost().setAppBase("."); + String contextPath = "/" + artifactId; + + StandardServer server = (StandardServer)tomcat.getServer(); + server.setParentClassLoader(getMainClassLoader()); + AprLifecycleListener listener = new AprLifecycleListener(); + server.addLifecycleListener(listener); + + tomcat.addWebapp(contextPath, appBase); + tomcat.start(); + tomcat.getServer().await(); + } + private void executeShell() throws MojoExecutionException { getLog().info("Starting Tuscany Shell..."); -- cgit v1.2.3