diff options
Diffstat (limited to '')
9 files changed, 74 insertions, 107 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-widget-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/implementation-widget-runtime/META-INF/MANIFEST.MF index 54fc5e918d..fd792c336f 100644 --- a/sca-java-2.x/trunk/modules/implementation-widget-runtime/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/implementation-widget-runtime/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Import-Package: javax.servlet, org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.host.http;version="2.0.0",
org.apache.tuscany.sca.implementation.widget;version="2.0.0",
+ org.apache.tuscany.sca.implementation.widget.javascript;version="2.0.0",
org.apache.tuscany.sca.implementation.widget.provider;version="2.0.0",
org.apache.tuscany.sca.interfacedef;version="2.0.0",
org.apache.tuscany.sca.invocation;version="2.0.0",
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() { diff --git a/sca-java-2.x/trunk/modules/implementation-widget/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/implementation-widget/META-INF/MANIFEST.MF index 84a8c8380a..fcc1ede5d2 100644 --- a/sca-java-2.x/trunk/modules/implementation-widget/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/implementation-widget/META-INF/MANIFEST.MF @@ -6,7 +6,8 @@ Export-Package: org.apache.tuscany.sca.implementation.widget;version="2.0.0"; org.apache.tuscany.sca.contribution.resolver,
org.apache.tuscany.sca.contribution.processor,
org.apache.tuscany.sca.core,
- javax.xml.namespace"
+ javax.xml.namespace",
+ org.apache.tuscany.sca.implementation.widget.javascript;version="2.0.0"
SCA-Version: 1.1
Bundle-Name: Apache Tuscany SCA Widget Implementation Model
Bundle-Vendor: The Apache Software Foundation
diff --git a/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/javascript/WidgetImplementationJavascriptProvider.java b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/javascript/WidgetImplementationJavascriptProvider.java new file mode 100644 index 0000000000..55cf7dbf0e --- /dev/null +++ b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/javascript/WidgetImplementationJavascriptProvider.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.implementation.widget.javascript; + +import org.apache.tuscany.sca.core.ModuleActivator; + + +/** + * A widget javascript provider which + * provides dojo and tuscany dojo extensions + * to an application using implementation.widget + * + * @version $Rev$ $Date$ + */ +public interface WidgetImplementationJavascriptProvider extends ModuleActivator { + +} diff --git a/sca-java-2.x/trunk/modules/web-javascript-dojo/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/web-javascript-dojo/META-INF/MANIFEST.MF index 2730e38cbb..176b77572a 100644 --- a/sca-java-2.x/trunk/modules/web-javascript-dojo/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/web-javascript-dojo/META-INF/MANIFEST.MF @@ -15,6 +15,7 @@ Import-Package: javax.servlet, org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.extensibility;version="2.0.0",
org.apache.tuscany.sca.host.http;version="2.0.0",
+ org.apache.tuscany.sca.implementation.widget.javascript;version="2.0.0",
org.apache.tuscany.sca.monitor;version="2.0.0",
org.apache.tuscany.sca.runtime;version="2.0.0"
Bundle-SymbolicName: org.apache.tuscany.sca.core.web.javascript.dojo
diff --git a/sca-java-2.x/trunk/modules/web-javascript-dojo/pom.xml b/sca-java-2.x/trunk/modules/web-javascript-dojo/pom.xml index be75ad8eb4..f41739a7cb 100644 --- a/sca-java-2.x/trunk/modules/web-javascript-dojo/pom.xml +++ b/sca-java-2.x/trunk/modules/web-javascript-dojo/pom.xml @@ -35,6 +35,12 @@ <artifactId>tuscany-core</artifactId> <version>2.0-SNAPSHOT</version> </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-widget</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.tuscany.sca</groupId> diff --git a/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoModuleActivator.java b/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoModuleActivator.java deleted file mode 100644 index f9fdd96e1f..0000000000 --- a/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/java/org/apache/tuscany/sca/web/javascript/dojo/DojoModuleActivator.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.web.javascript.dojo; - -import java.net.URI; -import java.util.logging.Logger; - -import javax.servlet.Servlet; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.host.http.ServletHost; -import org.apache.tuscany.sca.host.http.ServletHostHelper; -import org.apache.tuscany.sca.host.http.ServletMappingException; - -public class DojoModuleActivator implements ModuleActivator { - private final static Logger logger = Logger.getLogger(DojoModuleActivator.class.getName()); - - private static final String dojoBaseUri = URI.create("/dojo").toString(); - private static final String dojoUri = URI.create("/dojo/*").toString(); - - private static final String tuscanyBaseUri = URI.create("/tuscany").toString(); - private static final String tuscanyUri = URI.create("/tuscany/*").toString(); - - private ServletHost servletHost; - - public DojoModuleActivator(ExtensionPointRegistry registry) { - this.servletHost = ServletHostHelper.getServletHost(registry); - } - - public void start() { - - if (servletHost == null) { - throw new IllegalStateException("Can't find ServletHost reference !"); - } - - Servlet servlet = null; - - servlet = servletHost.getServletMapping(dojoBaseUri); - if(servlet == null) { - try { - DojoResourceServlet baseResourceServlet = new DojoResourceServlet(); - servletHost.addServletMapping(dojoBaseUri, baseResourceServlet); - - DojoResourceServlet resourceServlet = new DojoResourceServlet(); - servletHost.addServletMapping(dojoUri, resourceServlet); - } catch (ServletMappingException me ) { - logger.warning("Dojo already registered at :" + dojoBaseUri); - } - } - - servlet = servletHost.getServletMapping(tuscanyBaseUri); - if(servlet == null) { - try { - DojoResourceServlet baseResourceServlet = new DojoResourceServlet(); - servletHost.addServletMapping(tuscanyBaseUri, baseResourceServlet); - - DojoResourceServlet resourceServlet = new DojoResourceServlet(); - servletHost.addServletMapping(tuscanyUri, resourceServlet); - } catch (ServletMappingException me ) { - logger.warning("Tuscany dojo extensions already registered at :" + tuscanyBaseUri); - } - } - - } - - public void stop() { - Servlet servlet = servletHost.getServletMapping(dojoBaseUri); - if(servlet != null) { - servletHost.removeServletMapping(dojoBaseUri); - servletHost.removeServletMapping(dojoUri); - - servletHost.removeServletMapping(tuscanyBaseUri); - servletHost.removeServletMapping(tuscanyUri); - } - - servletHost = null; - - } -} diff --git a/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider index 34edcb5199..70d29a5d86 100644 --- a/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator +++ b/sca-java-2.x/trunk/modules/web-javascript-dojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.widget.javascript.WidgetImplementationJavascriptProvider @@ -14,5 +14,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +# # Implementation class for the ModuleActivator -org.apache.tuscany.sca.web.javascript.dojo.DojoModuleActivator;priority=9999 +org.apache.tuscany.sca.web.javascript.dojo.DojoWidgetJavascriptProvider;priority=9999 |