summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-0.90/modules/host-webapp/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-0.90/modules/host-webapp/src/main/java/org')
-rw-r--r--branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/SCADomainHelper.java68
-rw-r--r--branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/TuscanyContextListener.java51
-rw-r--r--branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/TuscanyServlet.java63
-rw-r--r--branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/WebAppModuleActivator.java46
-rw-r--r--branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/WebAppServletHost.java88
5 files changed, 0 insertions, 316 deletions
diff --git a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/SCADomainHelper.java b/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/SCADomainHelper.java
deleted file mode 100644
index 61a7b54a0c..0000000000
--- a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/SCADomainHelper.java
+++ /dev/null
@@ -1,68 +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.webapp;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.servlet.ServletContext;
-
-import org.apache.tuscany.sca.host.embedded.SCADomain;
-
-/**
- * Utility class to initialize the SCADomian associated with a webapp
- */
-public class SCADomainHelper {
-
- public static final String SCA_DOMAIN_ATTRIBUTE = "org.apache.tuscany.sca.SCADomain";
-
- /**
- * Initializes the SCADomian associated with a webapp context. If a SCADomain
- * doesn't exist already then one is create based on the webapp config.
- */
- public static SCADomain initSCADomain(ServletContext servletContext) {
- SCADomain scaDomain = (SCADomain)servletContext.getAttribute(SCA_DOMAIN_ATTRIBUTE);
-
- String domainURI = "http://localhost/" + servletContext.getServletContextName().replace(' ', '.');
- String contributionRoot = null;
-
- try {
- URL rootURL = servletContext.getResource("/");
- if (rootURL.getProtocol().equals("jndi")) {
- //this is tomcat case, we should use getRealPath
- File warRootFile = new File(servletContext.getRealPath("/"));
- contributionRoot = warRootFile.toURL().toString();
- } else {
- //this is jetty case
- contributionRoot = rootURL.toString();
- }
- } catch(MalformedURLException mf) {
- //ignore, pass null
- }
-
-
- if (scaDomain == null) {
- scaDomain = SCADomain.newInstance(domainURI, contributionRoot);
- servletContext.setAttribute(SCA_DOMAIN_ATTRIBUTE, scaDomain);
- }
- return scaDomain;
- }
-}
diff --git a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/TuscanyContextListener.java b/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/TuscanyContextListener.java
deleted file mode 100644
index e88ace8d32..0000000000
--- a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/TuscanyContextListener.java
+++ /dev/null
@@ -1,51 +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.webapp;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.apache.tuscany.sca.host.embedded.SCADomain;
-
-/**
- * A ServletContextListener to create and close the SCADomain
- * when the webapp is initialized or destroyed.
- */
-public class TuscanyContextListener implements ServletContextListener {
-
- public void contextInitialized(ServletContextEvent event) {
- ServletContext servletContext = event.getServletContext();
- try {
- SCADomainHelper.initSCADomain(servletContext);
- } catch (Throwable e) {
- servletContext.log("exception initializing SCADomain", e);
- }
- }
-
- public void contextDestroyed(ServletContextEvent event) {
- ServletContext servletContext = event.getServletContext();
- SCADomain scaDomain = (SCADomain) servletContext.getAttribute(SCADomainHelper.SCA_DOMAIN_ATTRIBUTE);
- if (scaDomain != null) {
- scaDomain.close();
- }
- }
-
-}
diff --git a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/TuscanyServlet.java b/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/TuscanyServlet.java
deleted file mode 100644
index ae2cb59e35..0000000000
--- a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/TuscanyServlet.java
+++ /dev/null
@@ -1,63 +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.webapp;
-
-import java.io.IOException;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * A servlet that forwards requests to the servlets registered with the Tuscany
- * ServletHost.
- */
-public class TuscanyServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
-
- protected transient WebAppServletHost servletHost;
-
- @Override
- public void init(ServletConfig config) throws ServletException {
- ServletContext servletContext = config.getServletContext();
- SCADomainHelper.initSCADomain(servletContext);
-
- // TODO: must be a better way to get this than using a static
- servletHost = WebAppServletHost.getInstance();
- servletHost.init(config);
- }
-
- @Override
- public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
- String path = ((HttpServletRequest)req).getPathInfo();
- Servlet servlet = servletHost.getServlet(path);
- if (servlet == null) {
- throw new IllegalStateException("No servlet registered for path: " + path);
- }
-
- servlet.service(req, res);
- }
-
-}
diff --git a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/WebAppModuleActivator.java b/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/WebAppModuleActivator.java
deleted file mode 100644
index 2dee6f3ae2..0000000000
--- a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/WebAppModuleActivator.java
+++ /dev/null
@@ -1,46 +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.webapp;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.ModuleActivator;
-import org.apache.tuscany.sca.http.ServletHostExtensionPoint;
-
-/**
- * Activates the webapp host by registering the webapp ServletHost impl
- */
-public class WebAppModuleActivator implements ModuleActivator {
-
- public void start(ExtensionPointRegistry extensionPointRegistry) {
-
- ServletHostExtensionPoint servletHosts =
- extensionPointRegistry.getExtensionPoint(ServletHostExtensionPoint.class);
-
- servletHosts.addServletHost(WebAppServletHost.getInstance());
- }
-
- public void stop(ExtensionPointRegistry registry) {
- }
-
- public Object[] getExtensionPoints() {
- return null;
- }
-
-}
diff --git a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/WebAppServletHost.java b/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/WebAppServletHost.java
deleted file mode 100644
index 29c54b3153..0000000000
--- a/branches/sca-java-0.90/modules/host-webapp/src/main/java/org/apache/tuscany/sca/webapp/WebAppServletHost.java
+++ /dev/null
@@ -1,88 +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.webapp;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-
-import org.apache.tuscany.sca.http.ServletHost;
-import org.apache.tuscany.sca.http.ServletMappingException;
-
-/**
- * ServletHost impl singleton thats shared between the SCADomain
- * instance and the TuscanyServlet instance.
- * TODO: using a static singleton seems a big hack but how
- * should it be shared? Need some way for TuscanyServlet
- * to pull it out of the SCADomain instance.
- *
- */
-public class WebAppServletHost implements ServletHost {
-
- private static WebAppServletHost instance = new WebAppServletHost();
-
- private Map<String, Servlet> servlets;
-
- private WebAppServletHost() {
- servlets = new HashMap<String, Servlet>();
- }
-
- public void addServletMapping(String path, Servlet servlet) throws ServletMappingException {
- URI pathURI = URI.create(path);
- // for webapps just use the path and ignore the host and port
- servlets.put(pathURI.getPath(), servlet);
- }
-
- public Servlet removeServletMapping(String path) throws ServletMappingException {
- URI pathURI = URI.create(path);
- // for webapps just use the path and ignore the host and port
- return servlets.remove(pathURI.getPath());
- }
-
- public Servlet getServlet(String path) {
- Servlet servlet = servlets.get(path);
- if (servlet != null) {
- return servlet;
- }
- for (String servletPath : servlets.keySet()) {
- if (servletPath.endsWith("*")) {
- if (path.startsWith(servletPath.substring(0, servletPath.length()-1))) {
- return servlets.get(servletPath);
- }
- }
- }
- return null;
- }
-
- public static WebAppServletHost getInstance() {
- return instance;
- }
-
- public void init(ServletConfig config) throws ServletException {
- for (Servlet servlet : servlets.values()) {
- servlet.init(config);
- }
- }
-
-}