diff options
Diffstat (limited to 'java')
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 |