diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-31 18:29:04 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-31 18:29:04 +0000 |
commit | 02508ecec9c4c6a7ce88b58dc86fe06b5a9d3891 (patch) | |
tree | 0541120f284a783c0eca01b8061fd7ea9499b6ff /sca-java-2.x/trunk | |
parent | 5fe7e15f37d722a5563ca625a45dc101cf65045c (diff) |
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
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r-- | sca-java-2.x/trunk/maven/maven-tuscany-plugin/pom.xml | 41 | ||||
-rw-r--r-- | sca-java-2.x/trunk/maven/maven-tuscany-plugin/src/main/java/org/apache/tuscany/maven/plugin/TuscanyRunMojo.java | 33 |
2 files changed, 63 insertions, 11 deletions
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 @@ <artifactId>maven-artifact</artifactId>
<version>2.0.3</version>
</dependency>
-
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-base-runtime</artifactId>
@@ -59,16 +58,36 @@ <artifactId>tuscany-domain-hazelcast</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- <version>0.9.95-huynhjl</version>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.1.19</version>
- </dependency>
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>0.9.95-huynhjl</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ <version>7.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-juli</artifactId>
+ <version>7.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-jasper</artifactId>
+ <version>7.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jasper-el</artifactId>
+ <version>7.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jdt.core.compiler</groupId>
+ <artifactId>ecj</artifactId>
+ <version>3.5.1</version>
+ </dependency>
</dependencies>
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...");
|