summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-web-runtime/src/main
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-12 15:48:49 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-12 15:48:49 +0000
commit3fa5f014676cbb394c6018c5d2d3075449cb4ed6 (patch)
tree9591bf7b027d35570787cca31651cf76ffaf6ae6 /java/sca/modules/implementation-web-runtime/src/main
parentf72fa6e3ad51268fde91a3214890fc340f5ac504 (diff)
Remove the need for the WebSingleton
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685204 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-web-runtime/src/main')
-rw-r--r--java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java10
-rw-r--r--java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/WebSingleton.java73
-rw-r--r--java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java3
3 files changed, 7 insertions, 79 deletions
diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java
index 052b87f714..6e79b417aa 100644
--- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java
+++ b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java
@@ -23,7 +23,9 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.servlet.ServletConfig;
@@ -52,6 +54,7 @@ public class ComponentContextServlet extends HttpServlet {
protected transient Map<String, Object> attributes = new HashMap<String, Object>();
protected transient ServletContext servletContext;
+ private transient List<ContextScriptProcessor> contextScriptProcessors = new ArrayList<ContextScriptProcessor>();
@Override
public void init(ServletConfig servletConfig) throws ServletException {
@@ -106,7 +109,7 @@ public class ComponentContextServlet extends HttpServlet {
out.println("}");
- for (ContextScriptProcessor csp : WebSingleton.INSTANCE.getContextScriptProcessors()) {
+ for (ContextScriptProcessor csp : contextScriptProcessors) {
csp.scriptInit(req, response);
}
}
@@ -123,7 +126,7 @@ public class ComponentContextServlet extends HttpServlet {
for (ComponentReference cr : component.getReferences()) {
String ref = "// SCA Reference " + cr.getName() + "\n";
out.write(ref);
- for (ContextScriptProcessor csp : WebSingleton.INSTANCE.getContextScriptProcessors()) {
+ for (ContextScriptProcessor csp : contextScriptProcessors) {
csp.scriptReference(cr, out);
}
}
@@ -150,7 +153,6 @@ public class ComponentContextServlet extends HttpServlet {
}
public void addContextScriptProcessor(ContextScriptProcessor csp) {
- // TODO Auto-generated method stub
-
+ contextScriptProcessors.add(csp);
}
}
diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/WebSingleton.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/WebSingleton.java
deleted file mode 100644
index 5fcf2a2799..0000000000
--- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/WebSingleton.java
+++ /dev/null
@@ -1,73 +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;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.ComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * Singleton instance to share data between the ModuleActivator,
- * ContextScriptProcessorExtensionPoint, and Taglib tags.
- *
- * TODO: find a way to share the data without needing a singleton
- */
-public class WebSingleton {
-
- private List<ContextScriptProcessor> contextScriptProcessors = new ArrayList<ContextScriptProcessor>();
- private RuntimeComponent runtimeComponent;
-
- public static final WebSingleton INSTANCE = new WebSingleton();
- private WebSingleton() {
- }
-
- public ComponentReference getComponentReference(String name) {
- if (runtimeComponent == null) {
- throw new IllegalStateException("RuntimeComponent is null. Missing a <implementation.web>?");
- }
- for (ComponentReference cr : runtimeComponent.getReferences()) {
- if (cr.getName().equals(name)) {
- return cr;
- }
- }
- return null;
- }
-
- public void addContextScriptProcessor(ContextScriptProcessor csp) {
- contextScriptProcessors.add(csp);
- }
-
- public List<ContextScriptProcessor> getContextScriptProcessors() {
- return contextScriptProcessors;
- }
-
- public RuntimeComponent getRuntimeComponent() {
- return runtimeComponent;
- }
-
- public void setRuntimeComponent(RuntimeComponent rc) {
- if (this.runtimeComponent != null) {
- throw new IllegalStateException("adding component '" + rc.getName() + "' but web module already has a component: " + runtimeComponent.getName());
- }
- this.runtimeComponent = rc;
- }
-}
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 3b2f821b4f..d532c6e80f 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
@@ -23,7 +23,6 @@ import java.util.List;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
-import org.apache.tuscany.sca.host.webapp.WebAppServletHost;
import org.apache.tuscany.sca.implementation.web.ComponentContextServlet;
import org.apache.tuscany.sca.implementation.web.ContextScriptProcessorExtensionPoint;
import org.apache.tuscany.sca.implementation.web.DefaultContextScriptProcessorExtensionPoint;
@@ -57,7 +56,7 @@ public class WebImplementationProviderFactory implements ImplementationProviderF
servletHost.addServletMapping("org.osoa.sca.componentContext.js", contextServlet);
contextServlet.setAttribute("org.osoa.sca.ComponentContext", new ComponentContextProxy(component));
contextServlet.setAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent", component);
- WebAppServletHost.getInstance().setAttribute("org.osoa.sca.ComponentContext", new ComponentContextProxy(component));
+// WebAppServletHost.getInstance().setAttribute("org.osoa.sca.ComponentContext", new ComponentContextProxy(component));
return new ImplementationProvider() {
public Invoker createInvoker(RuntimeComponentService arg0, Operation arg1) {