Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The objective of this proposal is to generically implement a configuration option from where the user can specify the javascript framework he like to use. And as a starting step, integrate today’s most popular javascript framework i.e. jQuery, with Apache Tuscany. Once the option is in place future contributors can include more js frameworks to Apache.

2. Detailed Description

2.1

...

Reuse Existing Javascript Configuration Management

As of now Tuscany is configured to use Pojo as it's default framework. The previous contiributors have left out sufficient options to integrate a javascript framework in future. So currently those options are configured to use pojo in Java classes and other file inside the framework and is not exposed to the users to change that from outside.

Code Block
titleDojoJavaScriptComponentGeneratorImpl.java
borderStylesolid

class DojoJavaScriptComponentGeneratorImpl {
    //This is used to identify different generators supporting different JavaScript frameworks
    private static final QName NAME = new QName("http://tuscany.apache.org/xmlns/sca/1.1", "component.script.generator.dojo");

    private ExtensionPointRegistry extensionPoints;

    private JavascriptProxyFactoryExtensionPoint javascriptProxyFactories;
    public void generateJavaScriptCode(RuntimeComponent component, PrintWriter pw) throws IOException {
    ...
    }
}

As a next step, the values for these options should be supplied from files which are visible and editable by the user. So by the time this step is finished the user will have a place to configure the usage of any supported javascript. The dependency files will by included according to the configuration. Currently, the pojo.js is included as shown below.

Code Block
titleWidgetImplementationProvider.java
borderStylesolid

class WidgetImplementationProvider implements ImplementationProvider {
    private static final QName BINDING_HTTP = new QName(Base.SCA11_TUSCANY_NS, "binding.http");
    ...
      public void start() {
        String baseURI = getBaseURI();

        // this uses removeServletMapping / addServletMapping as there is no getServletMapping facility
        scriptURI = URI.create(baseURI + "/" + this.widgetName + ".js").toString();
        Servlet servlet = servletHost.getServletMapping(scriptURI);
        if (servlet == null /*|| servlet instanceof HTTPGetListenerServlet*/) {
            WidgetComponentScriptServlet widgetScriptServlet;
            widgetScriptServlet = new WidgetComponentScriptServlet(this.component, javaScriptGenerator);
            servletHost.addServletMapping(scriptURI, widgetScriptServlet);
        }     

        // If added to the class path, start dojo provider
        if(javascriptProvider != null) {
            javascriptProvider.start();
        }
        
    }
    ...
}

2.2 Implement jQuery Javascript Generator

For every pojo framework supported application there is an automatic javascript file generated that acts as a bridge between the tuscany specific javascript syntax and its counterpart in pojo framework. This javascript is generated by the following file.

Code Block
titleDojoJavaScriptComponentGeneratorImpl.java
borderStylesolid

public class DojoJavaScriptComponentGeneratorImpl implements ComponentJavaScriptGenerator {

   public void generateJavaScriptCode(RuntimeComponent component, PrintWriter pw) throws IOException {
       ...
       generateJavaScriptHeader(component, javascriptProxyFactories,pw);
       ...
       generateJavaScriptNamespace(pw);
       ...
       generateJavaScriptPropertyFunction(component, pw);
       ...
       generateJavaScriptReferenceFunction(component, javascriptProxyFactories,pw);
       ...
   }
}

Similar to this file there would be a JQueryJavaScriptComponentGeneratorImpl.java and other related files that generate the javascript file for the applications configured to use javascript.

2.3

Removing some hardcoded values for pojo. 

...

Deliverables

Javascript Generator is used to implement the GUI features of the Luke application as it is Apache Licensed and can be used in the Lucene trunk.

...