You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Luciano Resende <lu...@gmail.com> on 2010/04/29 07:20:47 UTC
Widget related changes, was Re: svn commit: r939029 - in
/tuscany/sca-java-2.x/trunk/modules: implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/
implementation-widget-runtime/src/main/java/org/apache/t
On Wed, Apr 28, 2010 at 10:51 AM, <rf...@apache.org> wrote:
> Author: rfeng
> Date: Wed Apr 28 17:51:44 2010
> New Revision: 939029
>
> URL: http://svn.apache.org/viewvc?rev=939029&view=rev
> Log:
> Fix the generated JavaScript to use tuscany.sca.Reference
> Use ServletHost.getContextPath() to establish the context path
>
> Modified:
> tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java
> tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
>
> Modified: tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java
> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java?rev=939029&r1=939028&r2=939029&view=diff
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java (original)
> +++ tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime-dojo/src/main/java/org/apache/tuscany/sca/implementation/widget/dojo/DojoJavaScriptComponentGeneratorImpl.java Wed Apr 28 17:51:44 2010
> @@ -183,10 +183,10 @@ public class DojoJavaScriptComponentGene
> 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 DojoJavaScriptComponentGene
> * @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 DojoJavaScriptComponentGene
> */
> 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 DojoJavaScriptComponentGene
> 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("}");
> }
>
>
> Modified: tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java?rev=939029&r1=939028&r2=939029&view=diff
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java (original)
> +++ tuscany/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java Wed Apr 28 17:51:44 2010
> @@ -21,7 +21,10 @@ package org.apache.tuscany.sca.implement
> 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.javasc
> * @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 imple
> */
> 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();
> + }
> }
> }
> }
>
>
>
Were you able to run embedded store application with these changes ?
I have noticed that the store.js is now being registered in the wrong
URI, related to the getContextPath changes.
INFO: Added Servlet mapping: http://store.js:8080/
Also, I was wondering if the changes to use tuscany.sca.Reference have
any implications to using this in IE as mentioned in revision
#770287...
--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/