summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to '')
-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.java7
-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-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java12
-rw-r--r--java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java4
-rw-r--r--java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/InitServlet.java53
-rw-r--r--java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java6
7 files changed, 31 insertions, 59 deletions
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 4be5de4100..5b11735166 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
@@ -120,4 +120,8 @@ public class ExtensibleServletHost implements ServletHost {
public void setContextPath(String path) {
getDefaultServletHost().setContextPath(path);
}
+
+ public void setAttribute(String name, Object value) {
+ getDefaultServletHost().setAttribute(name, value);
+ }
}
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 e5dbd59a07..2eb9f70601 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
@@ -108,4 +108,11 @@ public interface ServletHost {
* @return the URL mapped to the specified URI
*/
URL getURLMapping(String uri);
+
+ /**
+ * Set an attribute in the application ServletContext
+ * @param name the name of the attribute
+ * @param value the attribute value
+ */
+ void setAttribute(String name, Object value);
}
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 dfb34f11a5..780fb5887d 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
@@ -483,4 +483,8 @@ public class JettyServer implements ServletHost {
}
}
+ public void setAttribute(String name, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
}
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 118403fd67..edfb8c4a44 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,7 @@ public class WebAppServletHost implements ServletHost {
private String contributionRoot;
private ServletContext servletContext;
+ private Map<String, Object> tempAttributes = new HashMap<String, Object>();
WebAppServletHost() {
servlets = new HashMap<String, Servlet>();
@@ -213,6 +214,11 @@ public class WebAppServletHost implements ServletHost {
public void init(ServletConfig config) throws ServletException {
servletContext = config.getServletContext();
+
+ for (String name : tempAttributes.keySet()) {
+ servletContext.setAttribute(name, tempAttributes.get(name));
+ }
+
if (servletContext.getAttribute(SCA_NODE_ATTRIBUTE) == null) {
initContextPath(config);
contributionRoot = getContributionRoot(servletContext);
@@ -331,6 +337,10 @@ public class WebAppServletHost implements ServletHost {
}
public void setAttribute(String name, Object value) {
- servletContext.setAttribute(name, value);
+ if (servletContext != null) {
+ servletContext.setAttribute(name, value);
+ } else {
+ tempAttributes.put(name, value);
+ }
}
}
diff --git a/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java b/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java
index 43c91ac9af..5bf4f188f4 100644
--- a/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java
+++ b/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java
@@ -389,4 +389,8 @@ public class NodeWebAppServletHost implements ServletHost, Filter {
};
return servletConfig;
}
+
+ public void setAttribute(String name, Object value) {
+ // TODO Auto-generated method stub
+ }
}
diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/InitServlet.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/InitServlet.java
deleted file mode 100644
index 074f41453d..0000000000
--- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/InitServlet.java
+++ /dev/null
@@ -1,53 +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.implementation.web.runtime;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.GenericServlet;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-public class InitServlet extends GenericServlet {
- private static final long serialVersionUID = 1L;
-
- private Map<String, Object> attributes = new HashMap<String, Object>();
-
- public void init(ServletConfig config) throws ServletException {
- ServletContext context = config.getServletContext();
- for (String name : attributes.keySet()) {
- context.setAttribute(name, attributes.get(name));
- }
- }
-
- @Override
- public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException {
- throw new IllegalStateException();
- }
-
- public void setAttribute(String name, Object value) {
- attributes.put(name, value);
- }
-}
diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java
index 6a43a4e8ab..663af52877 100644
--- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java
+++ b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java
@@ -34,7 +34,6 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
public class WebImplementationProviderFactory implements ImplementationProviderFactory<WebImplementation> {
private ServletHost servletHost;
- private InitServlet servlet;
public WebImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
@@ -42,13 +41,10 @@ public class WebImplementationProviderFactory implements ImplementationProviderF
if (!hosts.isEmpty()) {
this.servletHost = hosts.get(0);
}
-
- servlet = new InitServlet();
}
public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation) {
- servletHost.addServletMapping("org.apache.tuscany.sca.implementation.web.dummy", servlet);
- servlet.setAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent", component);
+ servletHost.setAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent", component);
return new ImplementationProvider() {