summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-12-04 15:11:00 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-12-04 15:11:00 +0000
commita10633370206b6060f58a5723478e2cbf72c1248 (patch)
tree3170f26824b9f9a409bf5b175c69f3834c24f713 /sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache
parent62c97ce41ae36c5dc3ee3a90cc72ed859fb76776 (diff)
Update the Tomcat distribution so that SCA contributions can be deployed to exsiting Hosts instead of running in the Tuscany webapp. This means they run just like a regular web application and can be managed with the usual Tomcat admin and use all the usual Tomcat Host and Context features. Also update to configure the domain from the context so the domain nad be customized fro the Tomcat instance and each contribution via a context parameter. That removes the need for the singleton install option so that is removed. Also update the install page to have a bit of text about whats going on in the intsall
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@887223 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache')
-rw-r--r--sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java74
-rw-r--r--sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java26
-rw-r--r--sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java4
3 files changed, 7 insertions, 97 deletions
diff --git a/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java b/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java
deleted file mode 100644
index 972aafd8b6..0000000000
--- a/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.tuscany.sca.tomcat.foo;
-
-import java.io.File;
-import java.net.MalformedURLException;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.apache.tuscany.sca.node.Contribution;
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
-import org.apache.tuscany.sca.war.Installer;
-
-public class TuscanyTomcatNode implements ServletContextListener {
-
- protected Node tomcatNode;
-
- public void contextInitialized(ServletContextEvent arg0) {
- if (!Installer.isTuscanyHookRunning()) {
- return;
- }
-
- // TODO: this relys on the location of webapp folder, find way to get actual catalina base
- File tomcatBase = new File(arg0.getServletContext().getRealPath("/")).getParentFile().getParentFile();
-
- File contributionDir = new File(tomcatBase, "sca-contributions");
- if (!contributionDir.exists()) {
- return;
- }
- File[] contributionFiles = contributionDir.listFiles();
- if (contributionFiles.length < 1) {
- return;
- }
-
- Contribution[] nodeContributions = new Contribution[contributionFiles.length];
- for (int i = 0; i<contributionFiles.length; i++) {
- try {
- nodeContributions[i] =
- new Contribution(contributionFiles[i].getName(), contributionFiles[i].toURI().toURL().toString());
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
-
- tomcatNode = NodeFactory.newInstance().createNode(nodeContributions);
- tomcatNode.start();
- }
-
- public void contextDestroyed(ServletContextEvent arg0) {
- if (tomcatNode != null) {
- tomcatNode.stop();
- }
- }
-
-}
diff --git a/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java b/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java
index 2251a2e833..40651050fa 100644
--- a/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java
+++ b/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
-import java.util.Properties;
import org.apache.tuscany.sca.tomcat.TuscanyLifecycleListener;
import org.codehaus.swizzle.stream.DelimitedTokenReplacementInputStream;
@@ -72,10 +71,10 @@ public class Installer {
return status;
}
- public boolean install(boolean singleton) {
+ public boolean install() {
try {
- doInstall(singleton);
+ doInstall();
status = "Install successful, Tomcat restart required.";
restartRequired = true;
return true;
@@ -95,8 +94,7 @@ public class Installer {
try {
doUnintsall();
- status =
- "Tuscany removed from server.xml, please restart Tomcat and manually remove Tuscany jars from Tomcat lib";
+ status = "Tuscany removed from server.xml, please restart Tomcat and manually remove Tuscany jars from Tomcat lib";
restartRequired = true;
return true;
@@ -123,7 +121,7 @@ public class Installer {
}
- private boolean doInstall(boolean singleton) {
+ private boolean doInstall() {
// First verify all the file locations are as expected
if (!tuscanyWAR.exists()) {
throw new IllegalStateException("Tuscany war missing: " + tuscanyWAR.getAbsolutePath());
@@ -154,20 +152,6 @@ public class Installer {
// Copy tuscany-tomcat jar from the tuscany webapp web-inf/lib to Tomcat server/lib
copyFile(tuscanyTomcatJar, new File(serverLib, tuscanyTomcatJar.getName()));
- if (singleton) {
- try {
- // Write out a property file
- File propFile = new File(tuscanyWAR, "tuscany.properties");
- FileOutputStream os = new FileOutputStream(propFile);
- Properties props = new Properties();
- props.put("singleton", "true");
- props.store(os, "Apache Tuscany properties for Tomcat");
- os.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
// Add Tuscany LifecycleListener to Tomcat server.xml
updateServerXml(serverXml);
@@ -186,7 +170,7 @@ public class Installer {
static final String tuscanyListener =
"\r\n" + " <!-- Tuscany plugin for Tomcat -->\r\n"
- + "<Listener className=\"org.apache.tuscany.sca.tomcat.TuscanyLifecycleListener\" />";
+ + " <Listener className=\"org.apache.tuscany.sca.tomcat.TuscanyLifecycleListener\" />";
private void updateServerXml(File serverXmlFile) {
String serverXML = readAll(serverXmlFile);
diff --git a/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java b/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java
index a7e5c7e3d7..efcc2711f3 100644
--- a/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java
+++ b/sca-java-2.x/trunk/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java
@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletResponse;
public class InstallerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
+
private transient ServletConfig servletConfig;
private transient Installer installer;
@@ -56,8 +57,7 @@ public class InstallerServlet extends HttpServlet {
protected void doIt(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
if ("Install".equalsIgnoreCase(req.getParameter("action"))) {
- String singleton = req.getParameter("singleton");
- installer.install(singleton!=null && singleton.equalsIgnoreCase("true"));
+ installer.install();
} else if ("Uninstall".equalsIgnoreCase(req.getParameter("action"))) {
installer.uninstall();
}