summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-06 17:40:32 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-06 17:40:32 +0000
commit4d72e26425ad1501ae3f5b41203533e905b3c640 (patch)
treeb1c1bb2f013f91cdce2ca981ab7813a05d95e065 /java/sca/modules
parent9e75baa6a3d450854e7ad05001a6b0ca750a643b (diff)
Add missing files and use name attribute to identify the host
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@822369 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java4
-rw-r--r--java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java8
-rw-r--r--java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java4
-rw-r--r--java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java2
-rw-r--r--java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java4
-rw-r--r--java/sca/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost2
-rw-r--r--java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.java9
-rw-r--r--java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java4
-rw-r--r--java/sca/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost18
9 files changed, 50 insertions, 5 deletions
diff --git a/java/sca/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java b/java/sca/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java
index eba50bf84c..db77162b41 100644
--- a/java/sca/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java
+++ b/java/sca/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java
@@ -268,4 +268,8 @@ public class OSGiServletHost implements ServletHost, BundleActivator {
}
}
+ public String getName() {
+ return "osgi";
+ }
+
}
diff --git a/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java b/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
index 7573141656..d91485cbb5 100644
--- a/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
+++ b/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
@@ -95,7 +95,7 @@ public class DefaultServletHostExtensionPoint implements ServletHostExtensionPoi
* A data binding facade allowing data bindings to be lazily loaded and
* initialized.
*/
- private class LazyServletHost implements ServletHost, LifeCycleListener {
+ public class LazyServletHost implements ServletHost, LifeCycleListener {
private ServiceDeclaration sd;
private ServletHost host;
@@ -107,7 +107,7 @@ public class DefaultServletHostExtensionPoint implements ServletHostExtensionPoi
this.sd = sd;
}
- private synchronized ServletHost getServletHost() {
+ public synchronized ServletHost getServletHost() {
if (host == null) {
try {
Class<?> cls = sd.loadClass();
@@ -168,6 +168,10 @@ public class DefaultServletHostExtensionPoint implements ServletHostExtensionPoi
public void setDefaultPort(int port) {
getServletHost().setDefaultPort(port);
}
+
+ public String getName() {
+ return sd.getAttributes().get("name");
+ }
public void start() {
}
diff --git a/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java b/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
index 5b11735166..4dfa1dd8a3 100644
--- a/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
+++ b/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
@@ -124,4 +124,8 @@ public class ExtensibleServletHost implements ServletHost {
public void setAttribute(String name, Object value) {
getDefaultServletHost().setAttribute(name, value);
}
+
+ public String getName() {
+ return getDefaultServletHost().getName();
+ }
}
diff --git a/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java b/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
index 2eb9f70601..dffc1e73d4 100644
--- a/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
+++ b/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
@@ -115,4 +115,6 @@ public interface ServletHost {
* @param value the attribute value
*/
void setAttribute(String name, Object value);
+
+ String getName();
}
diff --git a/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java b/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
index 70a3455a6e..f57e189344 100644
--- a/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
+++ b/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
@@ -127,6 +127,10 @@ public class JettyServer implements ServletHost, LifeCycleListener {
}
});
}
+
+ public String getName() {
+ return "jetty";
+ }
public void setDefaultPort(int port) {
defaultPort = port;
diff --git a/java/sca/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost b/java/sca/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
index b1b8ddc387..e74aba0093 100644
--- a/java/sca/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
+++ b/java/sca/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
# Implementation class for the ServletHost
-org.apache.tuscany.sca.http.jetty.JettyServer;ranking=100 \ No newline at end of file
+org.apache.tuscany.sca.http.jetty.JettyServer;name=jetty,ranking=100 \ No newline at end of file
diff --git a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.java b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.java
index 1205e86684..2ff16eeac7 100644
--- a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.java
+++ b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.java
@@ -32,6 +32,7 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.DefaultServletHostExtensionPoint;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
import org.apache.tuscany.sca.node.Node;
@@ -163,8 +164,12 @@ public class ServletHostHelper {
throw new IllegalStateException("No ServletHost found");
}
for (ServletHost servletHost : hosts) {
- if ((servletHost instanceof WebAppServletHost)) {
- return (WebAppServletHost)servletHost;
+ if ("webapp".equals(servletHost.getName())) {
+ if(servletHost instanceof DefaultServletHostExtensionPoint.LazyServletHost) {
+ return (WebAppServletHost) ((DefaultServletHostExtensionPoint.LazyServletHost) servletHost).getServletHost();
+ } else if(servletHost instanceof WebAppServletHost) {
+ return (WebAppServletHost) servletHost;
+ }
}
}
throw new IllegalStateException("No WebApp Servlet host is configured");
diff --git a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
index f4315ad07e..7617169b9b 100644
--- a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
+++ b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
@@ -67,6 +67,10 @@ public class WebAppServletHost implements ServletHost {
public int getDefaultPort() {
return defaultPortNumber;
}
+
+ public String getName() {
+ return "webapp";
+ }
public void addServletMapping(String suri, Servlet servlet) throws ServletMappingException {
URI pathURI = URI.create(suri);
diff --git a/java/sca/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost b/java/sca/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
new file mode 100644
index 0000000000..463ce1e5b2
--- /dev/null
+++ b/java/sca/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
@@ -0,0 +1,18 @@
+# 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.
+# Implementation class for the ServletHost
+org.apache.tuscany.sca.host.webapp.WebAppServletHost;name=webapp,ranking=0 \ No newline at end of file