summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-04-03 08:22:24 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-04-03 08:22:24 +0000
commitc64843596c20e81802eef543fd2c51216d9c7d96 (patch)
treee3743d0c620310b1ad8c2f1b617cddd196362d33 /branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider
parente416b6615af1bc2b2e52dc34b7bda7421b054de2 (diff)
TUSCANY-2878 - Changes to support new JavaScript Generator extension point and new generators for tuscany specific scripts and dojo toolkit
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@761562 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetComponentScriptServlet.java21
-rw-r--r--branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java25
-rw-r--r--branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java12
-rw-r--r--branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java14
4 files changed, 37 insertions, 35 deletions
diff --git a/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetComponentScriptServlet.java b/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetComponentScriptServlet.java
index 819159d553..45cb86bf4d 100644
--- a/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetComponentScriptServlet.java
+++ b/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetComponentScriptServlet.java
@@ -20,17 +20,16 @@
package org.apache.tuscany.sca.implementation.widget.provider;
import java.io.IOException;
-import java.net.URISyntaxException;
+import java.io.PrintWriter;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.tuscany.sca.core.web.ComponentJavaScriptGenerator;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.core.web.JavascriptProxyFactoryExtensionPoint;
-
/**
* Servlet to handle requests for the widget component .js script.
@@ -40,7 +39,7 @@ import org.apache.tuscany.sca.core.web.JavascriptProxyFactoryExtensionPoint;
public class WidgetComponentScriptServlet extends HttpServlet {
private static final long serialVersionUID = 2454705532282398190L;
- private transient JavascriptProxyFactoryExtensionPoint javascriptProxyFactories;
+ private transient ComponentJavaScriptGenerator javaScriptgenerator;
private transient RuntimeComponent component;
@@ -48,18 +47,16 @@ public class WidgetComponentScriptServlet extends HttpServlet {
* Constructor receiving the runtimeComponent reference that is going to be used to generate the widget client js
* @param component
*/
- public WidgetComponentScriptServlet(RuntimeComponent component, JavascriptProxyFactoryExtensionPoint javascriptProxyFactories) {
+ public WidgetComponentScriptServlet(RuntimeComponent component, ComponentJavaScriptGenerator javaScriptgenerator) {
this.component = component;
- this.javascriptProxyFactories = javascriptProxyFactories;
+ this.javaScriptgenerator = javaScriptgenerator;
}
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
- try {
- ServletOutputStream os = response.getOutputStream();
- WidgetComponentScriptGenerator.generateWidgetCode(component, javascriptProxyFactories, os);
- }catch(URISyntaxException e) {
- throw new IOException("Invalid uri creating JavaScript resource");
- }
+ ServletOutputStream os = response.getOutputStream();
+ PrintWriter pw = new PrintWriter(os);
+
+ javaScriptgenerator.generateJavaScriptCode(component, pw);
}
}
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 9d5fa7ae5b..b6b7ae907b 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
@@ -19,13 +19,15 @@
package org.apache.tuscany.sca.implementation.widget.provider;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintWriter;
import java.net.MalformedURLException;
-import java.net.URISyntaxException;
import java.net.URL;
-import org.apache.tuscany.sca.core.web.JavascriptProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.web.ComponentJavaScriptGenerator;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -38,14 +40,14 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent;
*/
class WidgetImplementationInvoker implements Invoker {
private RuntimeComponent component;
- private JavascriptProxyFactoryExtensionPoint javascriptProxyFactories;
+ private ComponentJavaScriptGenerator javaScriptGenerator;
private String widgetName;
private String widgetFolderURL;
private String widgetLocationURL;
- WidgetImplementationInvoker(RuntimeComponent component, JavascriptProxyFactoryExtensionPoint javascriptProxyFactories, String widgetName, String widgetFolderURL, String widgetLocationURL) {
+ WidgetImplementationInvoker(RuntimeComponent component, ComponentJavaScriptGenerator javaScriptGenerator, String widgetName, String widgetFolderURL, String widgetLocationURL) {
this.component = component;
- this.javascriptProxyFactories = javascriptProxyFactories;
+ this.javaScriptGenerator = javaScriptGenerator;
this.widgetName = widgetName + ".js";
this.widgetFolderURL = widgetFolderURL;
this.widgetLocationURL = widgetLocationURL;
@@ -67,7 +69,13 @@ class WidgetImplementationInvoker implements Invoker {
} else if (id.equals(widgetName)) {
// Generate JavaScript header for use in the Widget
- InputStream is = WidgetComponentScriptGenerator.generateWidgetCode(component, javascriptProxyFactories);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(bos);
+
+ javaScriptGenerator.generateJavaScriptCode(component, pw);
+
+ InputStream is = new ByteArrayInputStream(bos.toByteArray());
+
msg.setBody(is);
} else {
@@ -83,11 +91,6 @@ class WidgetImplementationInvoker implements Invoker {
// Report exception as a fault
msg.setFaultBody(e);
- } catch (URISyntaxException e) {
-
- // Report exception as a fault
- msg.setFaultBody(e);
-
} catch (IOException e) {
// Report exception as a fault
diff --git a/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java b/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
index 8f1511f483..81341ac1d6 100644
--- a/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
+++ b/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
@@ -23,7 +23,7 @@ import java.net.URI;
import javax.servlet.Servlet;
import org.apache.tuscany.sca.assembly.ComponentService;
-import org.apache.tuscany.sca.core.web.JavascriptProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.web.ComponentJavaScriptGenerator;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.implementation.widget.WidgetImplementation;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -42,7 +42,7 @@ class WidgetImplementationProvider implements ImplementationProvider {
private RuntimeComponent component;
- private JavascriptProxyFactoryExtensionPoint javascriptProxyFactories;
+ private ComponentJavaScriptGenerator javaScriptGenerator;
private ServletHost servletHost;
private String widgetLocationURL;
@@ -56,11 +56,11 @@ class WidgetImplementationProvider implements ImplementationProvider {
*/
WidgetImplementationProvider(RuntimeComponent component,
WidgetImplementation implementation,
- JavascriptProxyFactoryExtensionPoint javascriptProxyFactories,
+ ComponentJavaScriptGenerator javaScriptGenerator,
ServletHost servletHost) {
this.component = component;
- this.javascriptProxyFactories = javascriptProxyFactories;
+ this.javaScriptGenerator = javaScriptGenerator;
this.servletHost = servletHost;
widgetLocationURL = implementation.getLocationURL().toString();
@@ -71,7 +71,7 @@ class WidgetImplementationProvider implements ImplementationProvider {
}
public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
- WidgetImplementationInvoker invoker = new WidgetImplementationInvoker(component, javascriptProxyFactories, widgetName, widgetFolderURL, widgetLocationURL);
+ WidgetImplementationInvoker invoker = new WidgetImplementationInvoker(component, javaScriptGenerator, widgetName, widgetFolderURL, widgetLocationURL);
return invoker;
}
@@ -88,7 +88,7 @@ class WidgetImplementationProvider implements ImplementationProvider {
Servlet servlet = servletHost.getServletMapping(scriptURI);
if (servlet == null /*|| servlet instanceof HTTPGetListenerServlet*/) {
WidgetComponentScriptServlet widgetScriptServlet;
- widgetScriptServlet = new WidgetComponentScriptServlet(this.component, javascriptProxyFactories);
+ widgetScriptServlet = new WidgetComponentScriptServlet(this.component, javaScriptGenerator);
servletHost.addServletMapping(scriptURI, widgetScriptServlet);
} else {
System.out.println(">>>Servlet::" + servlet.getClass().toString());
diff --git a/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java b/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java
index 3cc1a64a68..f31e42a0ed 100644
--- a/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java
+++ b/branches/sca-java-1.x/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java
@@ -19,7 +19,8 @@
package org.apache.tuscany.sca.implementation.widget.provider;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.web.JavascriptProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.web.ComponentJavaScriptGenerator;
+import org.apache.tuscany.sca.core.web.ComponentJavaScriptGeneratorExtensionPoint;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
import org.apache.tuscany.sca.implementation.widget.WidgetImplementation;
@@ -34,9 +35,8 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent;
*/
public class WidgetImplementationProviderFactory implements ImplementationProviderFactory<WidgetImplementation> {
private ServletHost servletHost;
- private JavascriptProxyFactoryExtensionPoint javascriptProxyFactories;
-
-
+ private ComponentJavaScriptGenerator javaScriptGenerator;
+
/**
* Constructs a resource implementation.
*/
@@ -44,11 +44,13 @@ public class WidgetImplementationProviderFactory implements ImplementationProvid
ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
this.servletHost = servletHosts.getServletHosts().get(0);
- this.javascriptProxyFactories = extensionPoints.getExtensionPoint(JavascriptProxyFactoryExtensionPoint.class);
+ ComponentJavaScriptGeneratorExtensionPoint javascriptGeneratorExtensionPoint = extensionPoints.getExtensionPoint(ComponentJavaScriptGeneratorExtensionPoint.class);
+ javaScriptGenerator = javascriptGeneratorExtensionPoint.getComponentJavaScriptGenerators().get(0);
+
}
public ImplementationProvider createImplementationProvider(RuntimeComponent component, WidgetImplementation implementation) {
- return new WidgetImplementationProvider(component, implementation, javascriptProxyFactories, servletHost);
+ return new WidgetImplementationProvider(component, implementation, javaScriptGenerator, servletHost);
}
public Class<WidgetImplementation> getModelType() {