diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2010-06-04 02:38:54 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2010-06-04 02:38:54 +0000 |
commit | 21a870046c18047f1505da9ec97180bd17920919 (patch) | |
tree | 4abf72f15c44d1d8f979d6ffb4766818232c19fb /sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main | |
parent | 6d260660f6a14a6aeac68e8819a77f46602bb346 (diff) |
TUSCANY-3565 - Registering dojo resource servlet only when implementation widget starts...
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@951242 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main')
2 files changed, 28 insertions, 8 deletions
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 96b1561d5c..28f041b919 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 @@ -28,6 +28,7 @@ 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; +import org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.provider.ImplementationProvider; @@ -46,6 +47,7 @@ class WidgetImplementationProvider implements ImplementationProvider { private RuntimeComponent component; + private WidgetImplementationJavascriptProvider javascriptProvider; private ComponentJavaScriptGenerator javaScriptGenerator; private ServletHost servletHost; @@ -59,9 +61,11 @@ class WidgetImplementationProvider implements ImplementationProvider { * Constructs a new resource implementation provider. */ WidgetImplementationProvider(RuntimeComponent component, - WidgetImplementation implementation, + WidgetImplementation implementation, + WidgetImplementationJavascriptProvider javascriptProvider, ComponentJavaScriptGenerator javaScriptGenerator, ServletHost servletHost) { + this.component = component; this.javaScriptGenerator = javaScriptGenerator; @@ -86,7 +90,6 @@ class WidgetImplementationProvider implements ImplementationProvider { public void start() { String baseURI = getBaseURI(); - // get the ScaDomainScriptServlet, if it doesn't yet exist create one // this uses removeServletMapping / addServletMapping as there is no getServletMapping facility scriptURI = URI.create(baseURI + "/" + this.widgetName + ".js").toString(); Servlet servlet = servletHost.getServletMapping(scriptURI); @@ -95,6 +98,12 @@ class WidgetImplementationProvider implements ImplementationProvider { widgetScriptServlet = new WidgetComponentScriptServlet(this.component, javaScriptGenerator); servletHost.addServletMapping(scriptURI, widgetScriptServlet); } + + // If added to the class path, start dojo provider + if(javascriptProvider != null) { + javascriptProvider.start(); + } + } public void stop() { @@ -104,6 +113,10 @@ class WidgetImplementationProvider implements ImplementationProvider { // Remove the Servlet mapping servletHost.removeServletMapping(scriptURI); } + + if(javascriptProvider != null) { + javascriptProvider.stop(); + } } diff --git a/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java b/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java index dddc0a41ed..9c140f0913 100644 --- a/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java +++ b/sca-java-2.x/trunk/modules/implementation-widget-runtime/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProviderFactory.java @@ -19,9 +19,11 @@ package org.apache.tuscany.sca.implementation.widget.provider; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.host.http.ServletHostHelper; import org.apache.tuscany.sca.implementation.widget.WidgetImplementation; +import org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider; import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.provider.ImplementationProviderFactory; import org.apache.tuscany.sca.runtime.RuntimeComponent; @@ -35,21 +37,26 @@ import org.apache.tuscany.sca.web.javascript.ComponentJavaScriptGeneratorExtensi */ public class WidgetImplementationProviderFactory implements ImplementationProviderFactory<WidgetImplementation> { private ServletHost servletHost; - private ComponentJavaScriptGenerator javaScriptGenerator; + + private WidgetImplementationJavascriptProvider javascriptProvider; + private ComponentJavaScriptGenerator javascriptGenerator; /** * Constructs a resource implementation. */ - public WidgetImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { - this.servletHost = ServletHostHelper.getServletHost(extensionPoints); + public WidgetImplementationProviderFactory(ExtensionPointRegistry registry) { + this.servletHost = ServletHostHelper.getServletHost(registry); + + UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); + javascriptProvider = utilities.getUtility(WidgetImplementationJavascriptProvider.class); - ComponentJavaScriptGeneratorExtensionPoint javascriptGeneratorExtensionPoint = extensionPoints.getExtensionPoint(ComponentJavaScriptGeneratorExtensionPoint.class); - javaScriptGenerator = javascriptGeneratorExtensionPoint.getComponentJavaScriptGenerators().get(0); + ComponentJavaScriptGeneratorExtensionPoint javascriptGeneratorExtensionPoint = registry.getExtensionPoint(ComponentJavaScriptGeneratorExtensionPoint.class); + javascriptGenerator = javascriptGeneratorExtensionPoint.getComponentJavaScriptGenerators().get(0); } public ImplementationProvider createImplementationProvider(RuntimeComponent component, WidgetImplementation implementation) { - return new WidgetImplementationProvider(component, implementation, javaScriptGenerator, servletHost); + return new WidgetImplementationProvider(component, implementation, javascriptProvider, javascriptGenerator, servletHost); } public Class<WidgetImplementation> getModelType() { |