summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-04-28 17:51:44 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-04-28 17:51:44 +0000
commit6f95f82f0361b2c08fbc101b419ee4e35003feb6 (patch)
tree635863b29a17b06be2d30ecec015072aa4b311c5
parent085a0d843cc6a3a2ee90c929c124111030dd40a7 (diff)
Fix the generated JavaScript to use tuscany.sca.Reference
Use ServletHost.getContextPath() to establish the context path git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@939029 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java22
-rw-r--r--sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java19
2 files changed, 25 insertions, 16 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java b/sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java
index 64c75b4a7b..3a14c99030 100644
--- a/sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java
+++ b/sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java
@@ -183,10 +183,10 @@ public class DojoJavaScriptComponentGeneratorImpl implements ComponentJavaScript
pw.println("if (!window.tuscany) { \n" +
"window.tuscany = {}; \n" +
"}");
- pw.println("var __tus = window.tuscany;");
+ pw.println("var tuscany = window.tuscany;");
- pw.println("if (!__tus.sca) { \n" +
- "__tus.sca = {}; \n" +
+ pw.println("if (!tuscany.sca) { \n" +
+ "tuscany.sca = {}; \n" +
"}");
}
@@ -197,15 +197,15 @@ public class DojoJavaScriptComponentGeneratorImpl implements ComponentJavaScript
* @throws IOException
*/
private static void generateJavaScriptPropertyFunction(RuntimeComponent component, PrintWriter pw) throws IOException {
- pw.println("__tus.sca.propertyMap = {};");
+ pw.println("tuscany.sca.propertyMap = {};");
for(ComponentProperty property : component.getProperties()) {
String propertyName = property.getName();
- pw.println("__tus.sca.propertyMap." + propertyName + " = new String(\"" + getPropertyValue(property) + "\");");
+ pw.println("tuscany.sca.propertyMap." + propertyName + " = new String(\"" + getPropertyValue(property) + "\");");
}
- pw.println("__tus.sca.Property = function (name) {");
- pw.println(" return __tus.sca.propertyMap[name];");
+ pw.println("tuscany.sca.Property = function (name) {");
+ pw.println(" return tuscany.sca.propertyMap[name];");
pw.println("}");
}
@@ -238,7 +238,7 @@ public class DojoJavaScriptComponentGeneratorImpl implements ComponentJavaScript
*/
private static void generateJavaScriptReferenceFunction (RuntimeComponent component, JavascriptProxyFactoryExtensionPoint javascriptProxyFactories, PrintWriter pw) throws IOException {
- pw.println("__tus.sca.referenceMap = {};");
+ pw.println("tuscany.sca.referenceMap = {};");
for(ComponentReference reference : component.getReferences()) {
for(EndpointReference epr : reference.getEndpointReferences()) {
Endpoint targetEndpoint = epr.getTargetEndpoint();
@@ -254,13 +254,13 @@ public class DojoJavaScriptComponentGeneratorImpl implements ComponentJavaScript
String referenceName = reference.getName();
JavascriptProxyFactory jsProxyFactory = javascriptProxyFactories.getProxyFactory(binding.getClass());
- pw.println("__tus.sca.referenceMap." + referenceName + " = new " + jsProxyFactory.createJavascriptReference(reference) + ";");
+ pw.println("tuscany.sca.referenceMap." + referenceName + " = new " + jsProxyFactory.createJavascriptReference(reference) + ";");
}
}
}
- pw.println("__tus.sca.Reference = function (name) {");
- pw.println(" return __tus.sca.referenceMap[name];");
+ pw.println("tuscany.sca.Reference = function (name) {");
+ pw.println(" return tuscany.sca.referenceMap[name];");
pw.println("}");
}
diff --git a/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java b/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
index 08f2fbe679..bfc875edc1 100644
--- a/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
+++ b/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
@@ -21,7 +21,10 @@ package org.apache.tuscany.sca.implementation.widget.provider;
import java.net.URI;
import javax.servlet.Servlet;
+import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.implementation.widget.WidgetImplementation;
@@ -39,6 +42,7 @@ import org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGenerator;
* @version $Rev$ $Date$
*/
class WidgetImplementationProvider implements ImplementationProvider {
+ private static final QName BINDING_HTTP = new QName(Base.SCA11_TUSCANY_NS, "binding.http");
private RuntimeComponent component;
@@ -109,12 +113,17 @@ class WidgetImplementationProvider implements ImplementationProvider {
*/
private String getContextRoot() {
String contextRoot = null;
+ if (servletHost != null) {
+ contextRoot = servletHost.getContextPath();
+ }
- for(ComponentService service : component.getServices()) {
- if("Widget".equals(service.getName())) {
- for(org.apache.tuscany.sca.assembly.Binding binding : service.getBindings()) {
- if( binding.getClass().getName().contains("HTTPBinding")) {
- contextRoot = binding.getURI();
+ if (contextRoot == null) {
+ for (ComponentService service : component.getServices()) {
+ if ("Widget".equals(service.getName())) {
+ for (Binding binding : service.getBindings()) {
+ if (binding.getType().equals(BINDING_HTTP)) {
+ contextRoot = binding.getURI();
+ }
}
}
}