summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-12 13:50:49 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-12 13:50:49 +0000
commit8b6715b0a49263ab101682148daf09594cfd187e (patch)
treec0ef7bc0547322237ccaedcc2145af53af74295d /java
parentd265ff25c247dc3bb3933b468762cac419854944 (diff)
Add the script initilization code
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685149 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextServlet.java21
1 files changed, 21 insertions, 0 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 d6d015992d..052b87f714 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
@@ -85,6 +85,27 @@ public class ComponentContextServlet extends HttpServlet {
*/
protected void doScriptInit(HttpServletRequest req, HttpServletResponse response) throws IOException, UnsupportedEncodingException {
+ PrintWriter out = response.getWriter();
+
+ out.println("if (SCA == undefined) var SCA = new Object();");
+ out.println("if (SCA.componentContext == undefined) {");
+ out.println(" SCA.componentContext = new Object();");
+ out.println(" SCA.componentContext.serviceNames = [];");
+ out.println(" SCA.componentContext.serviceProxys = [];");
+ out.println(" SCA.componentContext.getService = function(serviceName){");
+ out.println(" var i = SCA.componentContext.serviceNames.indexOf(serviceName);");
+ out.println(" return SCA.componentContext.serviceProxys[i];");
+ out.println(" };");
+ out.println(" if (componentContext == undefined) var componentContext = SCA.componentContext;");
+
+ // TODO remove this dummy service once the rest is implemented
+ out.println(" var proxy = new Object();");
+ out.println(" proxy.sayHello = function(s, f) {f('proxyHello ' + s);};");
+ out.println(" SCA.componentContext.serviceProxys.push(proxy);");
+ out.println(" SCA.componentContext.serviceNames.push('service');");
+
+ out.println("}");
+
for (ContextScriptProcessor csp : WebSingleton.INSTANCE.getContextScriptProcessors()) {
csp.scriptInit(req, response);
}