summaryrefslogtreecommitdiffstats
path: root/branches
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-03-24 03:45:43 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-03-24 03:45:43 +0000
commit8553a4c382f3f4cf6e0d91f1c739990b25b1a832 (patch)
treeb566756957dddaba1b95213fbcf83fe49fa8e2c9 /branches
parentcfbfc4f92020ab02f1fe8c56458e0c54ebd47b4d (diff)
TUSCANY-2933 - Runtime changes to properly define widget functions in it's own namespace
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@757645 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches')
-rw-r--r--branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java42
1 files changed, 28 insertions, 14 deletions
diff --git a/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java b/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java
index 7d91dcd29b..cbeb2566b3 100644
--- a/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java
+++ b/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java
@@ -137,9 +137,16 @@ class WidgetImplementationInvoker implements Invoker {
}
}
+ //define tuscany.sca namespace
+ generateJavaScriptNamespace(pw);
+
+ pw.println();
+
//process properties
generateJavaScriptPropertyFunction(pw);
-
+
+ pw.println();
+
//process references
generateJavaScriptReferenceFunction(pw);
@@ -171,22 +178,30 @@ class WidgetImplementationInvoker implements Invoker {
pw.println();
}
+ private void generateJavaScriptNamespace(PrintWriter pw) throws IOException {
+ pw.println("if (!tuscany) { \n" +
+ "var tuscany = {}; \n" +
+ "}");
+ pw.println("if (!tuscany.sca) { \n" +
+ "tuscany.sca = {}; \n" +
+ "}");
+ }
+
/**
* Generate JavaScript code to inject SCA Properties
* @param pw
* @throws IOException
*/
- private void generateJavaScriptPropertyFunction(PrintWriter pw) throws IOException {
-
- pw.println("var propertyMap = new String();");
+ private void generateJavaScriptPropertyFunction(PrintWriter pw) throws IOException {
+ pw.println("tuscany.sca.propertyMap = new String();");
for(ComponentProperty property : component.getProperties()) {
String propertyName = property.getName();
- pw.println("propertyMap." + propertyName + " = \"" + getPropertyValue(property) + "\"");
+ pw.println("tuscany.sca.propertyMap." + propertyName + " = \"" + getPropertyValue(property) + "\"");
}
- pw.println("function Property(name) {");
- pw.println(" return propertyMap[name];");
+ pw.println("tuscany.sca.Property = function (name) {");
+ pw.println(" return tuscany.sca.propertyMap[name];");
pw.println("}");
}
@@ -217,7 +232,7 @@ class WidgetImplementationInvoker implements Invoker {
*/
private void generateJavaScriptReferenceFunction (PrintWriter pw) throws IOException, URISyntaxException {
- pw.println("var referenceMap = new Object();");
+ pw.println("tuscany.sca.referenceMap = new Object();");
for(ComponentReference reference : component.getReferences()) {
String referenceName = reference.getName();
Binding binding = reference.getBindings().get(0);
@@ -246,18 +261,17 @@ class WidgetImplementationInvoker implements Invoker {
String targetPath = targetURI.getPath();
if(proxyClient.equals("JSONRpcClient")) {
- //FIXME Proxies should follow the same pattern, saving us from having to test
- // for JSONRpc here
- pw.println("referenceMap." + referenceName + " = new " + proxyClient + "(\"" + targetPath + "\").Service;");
+ //FIXME Proxies should follow the same pattern, saving us from having to test for JSONRpc here
+ pw.println("tuscany.sca.referenceMap." + referenceName + " = new " + proxyClient + "(\"" + targetPath + "\").Service;");
} else {
- pw.println("referenceMap." + referenceName + " = new " + proxyClient + "(\"" + targetPath + "\");");
+ pw.println("tuscany.sca.referenceMap." + referenceName + " = new " + proxyClient + "(\"" + targetPath + "\");");
}
}
}
}
- pw.println("function Reference(name) {");
- pw.println(" return referenceMap[name];");
+ pw.println("tuscany.sca.Reference = function (name) {");
+ pw.println(" return tuscany.sca.referenceMap[name];");
pw.println("}");
}