summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-05-29 09:42:53 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-05-29 09:42:53 +0000
commit5fe2b172caeeb5743da06868a28ffc882f3b6db2 (patch)
tree1630eeaf17753fedc92fac12e2bc523682250c24 /java/sca
parent0ff5b1526032147746a2f43b9463e791e115b872 (diff)
Start adding support for non-webapp contributions. The idea being to enable using regular SCA contribution jas/zips/folders as well as webapps and have them all in the same sca domain and wiring between each other. None of the domain works yet as we need to make more progress on the dynamic doamin discussion. Eventually the non-webapp contributions would use the tomcat host config facilities so support hot deployment, and there'd be some domain management panels in the tuscany webapp to view and modify the domain. Could potentially have multiple domains within a tomcat instance though lets leave that for now as it adds some complications. Would also be good to get the SCAClient API able to talk to the tomcat domain so JSE clients can call sca services in tomcat
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@779906 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java13
-rw-r--r--java/sca/distribution/tomcat/tomcat-servlet/pom.xml7
-rw-r--r--java/sca/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java74
3 files changed, 92 insertions, 2 deletions
diff --git a/java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java b/java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java
index 5757c13206..d5622bc396 100644
--- a/java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java
+++ b/java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java
@@ -45,6 +45,7 @@ public class TuscanyStandardContext extends StandardContext {
protected static final String TUSCANY_FILTER_NAME = "TuscanyFilter";
protected static final String TUSCANY_SERVLET_FILTER = "org.apache.tuscany.sca.host.webapp.TuscanyServletFilter";
protected static final String TUSCANY_CONTEXT_LISTENER = "org.apache.tuscany.sca.host.webapp.TuscanyContextListener";
+ protected static final String TUSCANY_MANAGER_LISTENER = "org.apache.tuscany.sca.tomcat.foo.TuscanyTomcatNode";
private boolean isSCAApp;
@@ -65,7 +66,7 @@ public class TuscanyStandardContext extends StandardContext {
}
ClassLoader parent = getParentClassLoader();
- if (isSCAApp = isSCAApplication()) {
+ if (isSCAApp = isSCAApplication() || isTuscanyManager()) {
String sharedProp = System.getProperty(TuscanyLifecycleListener.TUSCANY_SHARED_PROP, "false");
boolean shared = "true".equalsIgnoreCase(sharedProp);
if (!shared) {
@@ -81,7 +82,11 @@ public class TuscanyStandardContext extends StandardContext {
@Override
public boolean listenerStart() {
- if (isSCAApp) {
+ if (isTuscanyManager()) {
+ // this isn't great having the manager app config scattered about different modules
+ // but is temp until this is all tidied up in a refactor after the basics are working
+ addApplicationListener(TUSCANY_MANAGER_LISTENER);
+ } else if (isSCAApp) {
enableTuscany();
}
return super.listenerStart();
@@ -151,6 +156,10 @@ public class TuscanyStandardContext extends StandardContext {
return true;
}
+ private boolean isTuscanyManager() {
+ return "/tuscany".equals(getName());
+ }
+
private static URLClassLoader copy(URLClassLoader classLoader) {
return new URLClassLoader(classLoader.getURLs(), classLoader.getParent());
}
diff --git a/java/sca/distribution/tomcat/tomcat-servlet/pom.xml b/java/sca/distribution/tomcat/tomcat-servlet/pom.xml
index 8816fb6c4d..19c9381f83 100644
--- a/java/sca/distribution/tomcat/tomcat-servlet/pom.xml
+++ b/java/sca/distribution/tomcat/tomcat-servlet/pom.xml
@@ -39,6 +39,13 @@
</dependency>
<dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.codehaus.swizzle</groupId>
<artifactId>swizzle-stream</artifactId>
<version>1.0.2</version>
diff --git a/java/sca/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java b/java/sca/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java
new file mode 100644
index 0000000000..69b0c77b72
--- /dev/null
+++ b/java/sca/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java
@@ -0,0 +1,74 @@
+/*
+ * 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();
+ }
+ }
+
+}