tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r745770 - in /tuscany/java/sca/modules: host-http/src/main/java/org/apache/tuscany/sca/host/http/ host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/ host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ implementation-node-...
Date Thu, 19 Feb 2009 07:52:33 GMT
Author: antelder
Date: Thu Feb 19 07:52:32 2009
New Revision: 745770

URL: http://svn.apache.org/viewvc?rev=745770&view=rev
Log:
Simplify implementation-web-runtime by adding a facility to set context attributes to the
servlet host

Removed:
    tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/InitServlet.java
Modified:
    tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
    tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
    tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
    tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
    tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java
    tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java

Modified: tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java?rev=745770&r1=745769&r2=745770&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
(original)
+++ tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
Thu Feb 19 07:52:32 2009
@@ -120,4 +120,8 @@
     public void setContextPath(String path) {
         getDefaultServletHost().setContextPath(path);
     }
+
+    public void setAttribute(String name, Object value) {
+        getDefaultServletHost().setAttribute(name, value);
+    }
 }

Modified: tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java?rev=745770&r1=745769&r2=745770&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
(original)
+++ tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
Thu Feb 19 07:52:32 2009
@@ -108,4 +108,11 @@
      * @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);
 }

Modified: tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java?rev=745770&r1=745769&r2=745770&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
(original)
+++ tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
Thu Feb 19 07:52:32 2009
@@ -483,4 +483,8 @@
         }
     }
 
+    public void setAttribute(String name, Object value) {
+        throw new UnsupportedOperationException();
+    }
+
 }

Modified: tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java?rev=745770&r1=745769&r2=745770&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
(original)
+++ tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
Thu Feb 19 07:52:32 2009
@@ -67,6 +67,7 @@
     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 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 void setAttribute(String name, Object value) {
-        servletContext.setAttribute(name, value);
+        if (servletContext != null) {
+            servletContext.setAttribute(name, value);
+        } else {
+            tempAttributes.put(name, value);
+        }
     }
 }

Modified: tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java?rev=745770&r1=745769&r2=745770&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java
(original)
+++ tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/webapp/NodeWebAppServletHost.java
Thu Feb 19 07:52:32 2009
@@ -389,4 +389,8 @@
         };
         return servletConfig;
     }
+
+    public void setAttribute(String name, Object value) {
+        // TODO Auto-generated method stub
+    }
 }

Modified: tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java?rev=745770&r1=745769&r2=745770&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java
(original)
+++ tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java
Thu Feb 19 07:52:32 2009
@@ -34,7 +34,6 @@
 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 @@
         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() {
             



Mime
View raw message