diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-22 05:44:18 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-22 05:44:18 +0000 |
commit | ad3556602a27b731bfeaebe306e5c0c3e15222ae (patch) | |
tree | 56f1767be588f1c3198595e3105f4a08ba308f17 /branches/sca-equinox/modules/implementation-script-runtime/src | |
parent | 5575cb865ad5f7c4f4f6126aadef6c428ee7609d (diff) |
Another fix for TUSCANY-2396. Split implementation-script into two modules, model and runtime. Got the script implementations that use componentTypes working.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@697664 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
19 files changed, 383 insertions, 727 deletions
diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java deleted file mode 100644 index 87820c18ed..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java +++ /dev/null @@ -1,99 +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.implementation.script; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.apache.tuscany.sca.contribution.Artifact; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.extension.helper.utils.ResourceHelper; - -/** - * Represents a Script implementation. - * - * @version $Rev$ $Date$ - */ -public class ScriptImplementation { - - protected String scriptName; - protected URL scriptURL; - protected String scriptSrc; - protected String scriptLanguage; - - public String getScript() { - return scriptName; - } - - public void setScript(String scriptName) { - this.scriptName = scriptName; - } - - public void setLanguage(String language) { - this.scriptLanguage = language; - } - - public void setElementText(String elementText) { - scriptSrc = elementText; - } - - public String getScriptLanguage() { - if (scriptLanguage == null || scriptLanguage.length() < 1) { - int i = scriptName.lastIndexOf('.'); - if (i > 0) { - scriptLanguage = scriptName.substring(i + 1); - } - } - return scriptLanguage; - } - - public String getScriptSrc() { - if (scriptSrc == null) { - if (scriptName == null) { - throw new IllegalArgumentException("script name is null and no inline source used"); - } - if (scriptURL == null) { - throw new RuntimeException("No script: " + scriptName); - } - - scriptSrc = ResourceHelper.readResource(scriptURL); - } - return scriptSrc; - } - - public void resolve(ModelResolver resolver) { - - if (scriptName != null) { - //FIXME The contribution factory should be injected - ContributionFactory contributionFactory = new DefaultContributionFactory(); - Artifact artifact = contributionFactory.createArtifact(); - artifact.setURI(scriptName); - artifact = resolver.resolveModel(Artifact.class, artifact); - if (artifact.getLocation() != null) { - try { - scriptURL = new URL(artifact.getLocation()); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - } - } -} diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationActivator.java b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationActivator.java deleted file mode 100644 index a7c4b9074f..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationActivator.java +++ /dev/null @@ -1,49 +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.implementation.script; - -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.extension.helper.ImplementationActivator; -import org.apache.tuscany.sca.extension.helper.InvokerFactory; -import org.apache.tuscany.sca.extension.helper.utils.PropertyValueObjectFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * - * @version $Rev$ $Date$ - */ -public class ScriptImplementationActivator implements ImplementationActivator<ScriptImplementation> { - - // TODO: seems wrong to need PropertyValueObjectFactory, could it be on Property somehow? - protected PropertyValueObjectFactory propertyFactory; - - public ScriptImplementationActivator(PropertyValueObjectFactory propertyFactory) { - this.propertyFactory = propertyFactory; - } - - public Class<ScriptImplementation> getImplementationClass() { - return ScriptImplementation.class; - } - - public InvokerFactory createInvokerFactory(RuntimeComponent rc, ComponentType ct, ScriptImplementation implementation) { - return new ScriptInvokerFactory(rc, ct, implementation, propertyFactory); - } - -} diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvokerFactory.java b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvokerFactory.java deleted file mode 100644 index 9359590424..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvokerFactory.java +++ /dev/null @@ -1,173 +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.implementation.script; - -import java.io.StringReader; -import java.security.AccessController; -import java.security.PrivilegedAction; - -import javax.script.Invocable; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; - -import org.apache.axiom.om.OMElement; -import org.apache.bsf.xml.XMLHelper; -import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.core.factory.ObjectCreationException; -import org.apache.tuscany.sca.core.factory.ObjectFactory; -import org.apache.tuscany.sca.extension.helper.InvokerFactory; -import org.apache.tuscany.sca.extension.helper.utils.PropertyValueObjectFactory; -import org.apache.tuscany.sca.implementation.script.engines.TuscanyJRubyScriptEngine; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * - * @version $Rev$ $Date$ - */ -public class ScriptInvokerFactory implements InvokerFactory { - - protected ScriptEngine scriptEngine; - protected XMLHelper xmlHelper; - - protected RuntimeComponent rc; - protected ComponentType ct; - protected ScriptImplementation implementation; - protected PropertyValueObjectFactory propertyFactory; - - - /** - * @param rc - * @param ct - * @param implementation - * @param propertyFactory - */ - public ScriptInvokerFactory(RuntimeComponent rc, - ComponentType ct, - ScriptImplementation implementation, - PropertyValueObjectFactory propertyFactory) { - super(); - this.rc = rc; - this.ct = ct; - this.implementation = implementation; - this.propertyFactory = propertyFactory; - } - - public Invoker createInvoker(Operation operation) { - init(rc, ct, implementation, propertyFactory); - return new ScriptInvoker(scriptEngine, xmlHelper, operation); - } - - protected synchronized void init(RuntimeComponent rc, ComponentType ct, ScriptImplementation implementation, PropertyValueObjectFactory propertyFactory) { - if(scriptEngine!=null) { - return; - } - try { - scriptEngine = getScriptEngineByExtension(implementation.getScriptLanguage()); - if (scriptEngine == null) { - throw new ObjectCreationException("no script engine found for language: " + implementation.getScriptLanguage()); - } - if (!(scriptEngine instanceof Invocable)) { - throw new ObjectCreationException("script engine does not support Invocable: " + scriptEngine); - } - - for (Reference reference : ct.getReferences()) { - scriptEngine.put(reference.getName(), createReferenceProxy(reference.getName(), rc)); - } - - for (Property property : ct.getProperties()) { - ObjectFactory<?> propertyValueFactory = propertyFactory.createValueFactory(property); - if ( propertyValueFactory != null) { - scriptEngine.put(property.getName(), propertyValueFactory.getInstance()); - } - } - - scriptEngine.eval(new StringReader(implementation.getScriptSrc())); - - } catch (ScriptException e) { - throw new ObjectCreationException(e); - } - - // set the databinding and XMLHelper for WSDL interfaces - for (Service service : rc.getServices()) { - InterfaceContract ic = service.getInterfaceContract(); - if (ic instanceof WSDLInterfaceContract) { - // Set to use the Axiom data binding - ic.getInterface().resetDataBinding(OMElement.class.getName()); - xmlHelper = XMLHelper.getArgHelper(scriptEngine); - } - } - } - - /** - * TODO: RuntimeComponent should provide a method like this - */ - @SuppressWarnings("unchecked") - protected Object createReferenceProxy(String name, RuntimeComponent component) { - for (ComponentReference reference : component.getReferences()) { - if (reference.getName().equals(name)) { - Class iface = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass(); - return component.getComponentContext().getService(iface, name); - } - } - throw new IllegalArgumentException("reference " + name + " not found on component: " + component); - } - - /** - * Hack for now to work around a problem with the JRuby script engine - */ - protected ScriptEngine getScriptEngineByExtension(String scriptExtn) { - if ("rb".equals(scriptExtn)) { - return new TuscanyJRubyScriptEngine(); - } else { - if ("py".equals(scriptExtn)) { - pythonCachedir(); - } - // Allow privileged access to run access classes. Requires RuntimePermission - // for accessClassInPackage.sun.misc. - ScriptEngineManager scriptEngineManager = - AccessController.doPrivileged(new PrivilegedAction<ScriptEngineManager>() { - public ScriptEngineManager run() { - return new ScriptEngineManager(); - } - }); - return scriptEngineManager.getEngineByExtension(scriptExtn); - } - } - - /** - * If the Python home isn't set then let Tuscany suppress messages other than errors - * See TUSCANY-1950 - */ - protected void pythonCachedir() { - if (System.getProperty("python.home") == null) { - System.setProperty("python.verbose", "error"); - } - } -} diff --git a/branches/sca-equinox/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvokerFactory.java b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java index 9359590424..473b990a79 100644 --- a/branches/sca-equinox/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvokerFactory.java +++ b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProvider.java @@ -17,9 +17,11 @@ * under the License. */ -package org.apache.tuscany.sca.implementation.script; +package org.apache.tuscany.sca.implementation.script.provider; -import java.io.StringReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; @@ -31,108 +33,103 @@ import javax.script.ScriptException; import org.apache.axiom.om.OMElement; import org.apache.bsf.xml.XMLHelper; import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.core.factory.ObjectCreationException; import org.apache.tuscany.sca.core.factory.ObjectFactory; -import org.apache.tuscany.sca.extension.helper.InvokerFactory; -import org.apache.tuscany.sca.extension.helper.utils.PropertyValueObjectFactory; +import org.apache.tuscany.sca.implementation.script.ScriptImplementation; import org.apache.tuscany.sca.implementation.script.engines.TuscanyJRubyScriptEngine; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract; import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; /** + * An ImplementationProvider for Script implementations. * - * @version $Rev$ $Date$ + * @version $Rev: $ $Date: $ */ -public class ScriptInvokerFactory implements InvokerFactory { - - protected ScriptEngine scriptEngine; - protected XMLHelper xmlHelper; +public class ScriptImplementationProvider implements ImplementationProvider { - protected RuntimeComponent rc; - protected ComponentType ct; - protected ScriptImplementation implementation; - protected PropertyValueObjectFactory propertyFactory; - + private RuntimeComponent component; + private ScriptImplementation implementation; + private ScriptPropertyFactory propertyFactory; + private ScriptEngine scriptEngine; + private XMLHelper xmlHelper; - /** - * @param rc - * @param ct - * @param implementation - * @param propertyFactory - */ - public ScriptInvokerFactory(RuntimeComponent rc, - ComponentType ct, - ScriptImplementation implementation, - PropertyValueObjectFactory propertyFactory) { - super(); - this.rc = rc; - this.ct = ct; + public ScriptImplementationProvider(RuntimeComponent component, ScriptImplementation implementation, ScriptPropertyFactory propertyFactory) { + this.component = component; this.implementation = implementation; this.propertyFactory = propertyFactory; - } - public Invoker createInvoker(Operation operation) { - init(rc, ct, implementation, propertyFactory); - return new ScriptInvoker(scriptEngine, xmlHelper, operation); - } - - protected synchronized void init(RuntimeComponent rc, ComponentType ct, ScriptImplementation implementation, PropertyValueObjectFactory propertyFactory) { - if(scriptEngine!=null) { - return; + // Set the databinding and XMLHelper for WSDL interfaces + for (Service service : component.getServices()) { + InterfaceContract ic = service.getInterfaceContract(); + if (ic instanceof WSDLInterfaceContract) { + ic.getInterface().resetDataBinding(OMElement.class.getName()); + xmlHelper = XMLHelper.getArgHelper(scriptEngine); + } } + } + + public void start() { try { - scriptEngine = getScriptEngineByExtension(implementation.getScriptLanguage()); + String language = implementation.getLanguage(); + if (language == null) { + language = implementation.getScript(); + language = language.substring(language.lastIndexOf('.') +1); + } + scriptEngine = scriptEngine(language); if (scriptEngine == null) { - throw new ObjectCreationException("no script engine found for language: " + implementation.getScriptLanguage()); + throw new ObjectCreationException("no script engine found for language: " + implementation.getLanguage()); } if (!(scriptEngine instanceof Invocable)) { throw new ObjectCreationException("script engine does not support Invocable: " + scriptEngine); } - for (Reference reference : ct.getReferences()) { - scriptEngine.put(reference.getName(), createReferenceProxy(reference.getName(), rc)); + for (Reference reference : implementation.getReferences()) { + scriptEngine.put(reference.getName(), getProxy(reference.getName())); } - for (Property property : ct.getProperties()) { - ObjectFactory<?> propertyValueFactory = propertyFactory.createValueFactory(property); - if ( propertyValueFactory != null) { - scriptEngine.put(property.getName(), propertyValueFactory.getInstance()); + for (Property property : implementation.getProperties()) { + ObjectFactory<?> valueFactory = propertyFactory.createValueFactory(property); + if (valueFactory != null) { + scriptEngine.put(property.getName(), valueFactory.getInstance()); } } - - scriptEngine.eval(new StringReader(implementation.getScriptSrc())); + URL url = new URL(implementation.getLocation()); + InputStreamReader reader = new InputStreamReader(url.openStream()); + scriptEngine.eval(reader); + reader.close(); + + } catch (IOException e) { + throw new IllegalArgumentException(e); } catch (ScriptException e) { - throw new ObjectCreationException(e); + throw new IllegalArgumentException(e); } + } - // set the databinding and XMLHelper for WSDL interfaces - for (Service service : rc.getServices()) { - InterfaceContract ic = service.getInterfaceContract(); - if (ic instanceof WSDLInterfaceContract) { - // Set to use the Axiom data binding - ic.getInterface().resetDataBinding(OMElement.class.getName()); - xmlHelper = XMLHelper.getArgHelper(scriptEngine); - } - } + public void stop() { } - /** - * TODO: RuntimeComponent should provide a method like this - */ - @SuppressWarnings("unchecked") - protected Object createReferenceProxy(String name, RuntimeComponent component) { + public boolean supportsOneWayInvocation() { + return false; + } + + public Invoker createInvoker(RuntimeComponentService service, Operation operation) { + return new ScriptInvoker(scriptEngine, xmlHelper, operation); + } + + private Object getProxy(String name) { for (ComponentReference reference : component.getReferences()) { if (reference.getName().equals(name)) { - Class iface = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass(); + Class<?> iface = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass(); return component.getComponentContext().getService(iface, name); } } @@ -140,15 +137,21 @@ public class ScriptInvokerFactory implements InvokerFactory { } /** - * Hack for now to work around a problem with the JRuby script engine + * Returns the script engine for the given language. + * + * @param language + * @return */ - protected ScriptEngine getScriptEngineByExtension(String scriptExtn) { - if ("rb".equals(scriptExtn)) { + private ScriptEngine scriptEngine(String language) { + if ("rb".equals(language)) { + + // Hack for now to work around a problem with the JRuby script engine return new TuscanyJRubyScriptEngine(); } else { - if ("py".equals(scriptExtn)) { + if ("py".equals(language)) { pythonCachedir(); } + // Allow privileged access to run access classes. Requires RuntimePermission // for accessClassInPackage.sun.misc. ScriptEngineManager scriptEngineManager = @@ -157,7 +160,7 @@ public class ScriptInvokerFactory implements InvokerFactory { return new ScriptEngineManager(); } }); - return scriptEngineManager.getEngineByExtension(scriptExtn); + return scriptEngineManager.getEngineByExtension(language); } } @@ -165,9 +168,9 @@ public class ScriptInvokerFactory implements InvokerFactory { * If the Python home isn't set then let Tuscany suppress messages other than errors * See TUSCANY-1950 */ - protected void pythonCachedir() { - if (System.getProperty("python.home") == null) { - System.setProperty("python.verbose", "error"); - } + private static void pythonCachedir() { + if (System.getProperty("python.home") == null) { + System.setProperty("python.verbose", "error"); + } } } diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java new file mode 100644 index 0000000000..f65403c9ed --- /dev/null +++ b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptImplementationProviderFactory.java @@ -0,0 +1,55 @@ +/* + * 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.script.provider; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.databinding.Mediator; +import org.apache.tuscany.sca.databinding.TransformerExtensionPoint; +import org.apache.tuscany.sca.databinding.impl.MediatorImpl; +import org.apache.tuscany.sca.implementation.script.ScriptImplementation; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * An ImplementationProviderFactory for Script implementations. + * + * @version $Rev: $ $Date: $ + */ +public class ScriptImplementationProviderFactory implements ImplementationProviderFactory<ScriptImplementation> { + + private ScriptPropertyFactory propertyFactory; + + public ScriptImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { + Mediator mediator = new MediatorImpl(extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class), + extensionPoints.getExtensionPoint(TransformerExtensionPoint.class)); + propertyFactory = new ScriptPropertyFactory(mediator); + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, ScriptImplementation Implementation) { + return new ScriptImplementationProvider(component, Implementation, propertyFactory); + } + + public Class<ScriptImplementation> getModelType() { + return ScriptImplementation.class; + } + +} diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptInvoker.java index 2ccb414be8..976eb2c0dd 100644 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java +++ b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptInvoker.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tuscany.sca.implementation.script; +package org.apache.tuscany.sca.implementation.script.provider; import javax.script.Invocable; import javax.script.ScriptEngine; @@ -36,9 +36,9 @@ import org.apache.tuscany.sca.invocation.Message; */ public class ScriptInvoker implements Invoker { - protected ScriptEngine scriptEngine; - protected XMLHelper xmlHelper; - protected Operation operation; + private ScriptEngine scriptEngine; + private XMLHelper xmlHelper; + private Operation operation; public ScriptInvoker(ScriptEngine scriptEngine, XMLHelper xmlHelper, Operation operation) { this.scriptEngine = scriptEngine; @@ -46,7 +46,7 @@ public class ScriptInvoker implements Invoker { this.operation = operation; } - protected Object doInvoke(Object[] objects, Operation op) throws ScriptException { + private Object doInvoke(Object[] objects, Operation op) throws ScriptException { if (xmlHelper != null) { objects[0] = xmlHelper.toScriptXML((OMElement)objects[0]); } diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptPropertyFactory.java b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptPropertyFactory.java new file mode 100644 index 0000000000..5833c9f4d5 --- /dev/null +++ b/branches/sca-equinox/modules/implementation-script-runtime/src/main/java/org/apache/tuscany/sca/implementation/script/provider/ScriptPropertyFactory.java @@ -0,0 +1,225 @@ +/* + * 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.script.provider; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.core.factory.ObjectCreationException; +import org.apache.tuscany.sca.core.factory.ObjectFactory; +import org.apache.tuscany.sca.databinding.Mediator; +import org.apache.tuscany.sca.databinding.SimpleTypeMapper; +import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.util.XMLType; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * A property factory for script properties. + * + * @version $Rev$ $Date$ + */ +public class ScriptPropertyFactory { + private Mediator mediator = null; + boolean isSimpleType; + + public ScriptPropertyFactory(Mediator mediator) { + this.mediator = mediator; + } + + public ObjectFactory createValueFactory(Property property) { + isSimpleType = isSimpleType(property); + Document doc = (Document)property.getValue(); + Element rootElement = doc.getDocumentElement(); + + //FIXME : since scripts use dynamic types we need to generate a dynamic java type using the + //XML structure of the property value. Should this be done in the JavaBeansDataBinding... + Class javaType = null; + + if (property.isMany()) { + if (isSimpleType) { + String value = ""; + if (rootElement.getChildNodes().getLength() > 0) { + value = rootElement.getChildNodes().item(0).getTextContent(); + } + List<String> values = + getSimplePropertyValues(value, javaType); + return new ListObjectFactoryImpl(property, + values, + isSimpleType, + javaType); + } else { + return new ListObjectFactoryImpl(property, + getComplexPropertyValues(doc), + isSimpleType, + javaType); + } + } else { + if (isSimpleType) { + String value = ""; + if (rootElement.getChildNodes().getLength() > 0) { + value = rootElement.getChildNodes().item(0).getTextContent(); + } + return new ObjectFactoryImpl(property, + value, + isSimpleType, + javaType); + } else { + Object value = getComplexPropertyValues(doc).get(0); + return new ObjectFactoryImpl(property, + value, + isSimpleType, + javaType); + } + + } + } + + private boolean isSimpleType(Property property) { + if (property.getXSDType() != null) { + return SimpleTypeMapperImpl.isSimpleXSDType(property.getXSDType()); + } else { + if (property instanceof Document) { + Document doc = (Document)property; + Element element = doc.getDocumentElement(); + if (element.getChildNodes().getLength() == 1 && + element.getChildNodes().item(0).getNodeType() == Node.TEXT_NODE) { + return true; + } + } + } + return false; + } + + private List<String> getSimplePropertyValues(String concatenatedValue, Class<?> javaType) { + List<String> propValues = new ArrayList<String>(); + StringTokenizer st = null; + if ( javaType.getName().equals("java.lang.String")) { + st = new StringTokenizer(concatenatedValue, "\""); + } else { + st = new StringTokenizer(concatenatedValue); + } + String aToken = null; + while (st.hasMoreTokens()) { + aToken = st.nextToken(); + if (aToken.trim().length() > 0) { + propValues.add(aToken); + } + } + return propValues; + } + + private List<Node> getComplexPropertyValues(Document document) { + Element rootElement = document.getDocumentElement(); + List<Node> propValues = new ArrayList<Node>(); + for (int count = 0 ; count < rootElement.getChildNodes().getLength() ; ++count) { + if (rootElement.getChildNodes().item(count).getNodeType() == Node.ELEMENT_NODE) { + propValues.add(rootElement.getChildNodes().item(count)); + } + } + return propValues; + } + + public abstract class ObjectFactoryImplBase implements ObjectFactory { + protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl(); + protected Property property; + protected Object propertyValue; + protected Class<?> javaType; + protected DataType<XMLType> sourceDataType; + protected DataType<?> targetDataType; + boolean isSimpleType; + + public ObjectFactoryImplBase(Property property, Object propertyValue, boolean isSimpleType, Class<?> javaType) { + + this.isSimpleType = isSimpleType; + this.property = property; + this.propertyValue = propertyValue; + this.javaType = javaType; + + //FIXME : fix this when we have managed to generate dynamic java types + + /*sourceDataType = + new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, + new XMLType(null, this.property.getXSDType())); + TypeInfo typeInfo = null; + if (this.property.getXSDType() != null) { + if (SimpleTypeMapperExtension.isSimpleXSDType(this.property.getXSDType())) { + typeInfo = new TypeInfo(property.getXSDType(), true, null); + } else { + typeInfo = new TypeInfo(property.getXSDType(), false, null); + } + } else { + typeInfo = new TypeInfo(property.getXSDType(), false, null); + } + + XMLType xmlType = new XMLType(typeInfo); + String dataBinding = null; //(String)property.getExtensions().get(DataBinding.class.getName()); + if (dataBinding != null) { + targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType); + } else { + targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType); + mediator.getDataBindingRegistry().introspectType(targetDataType, null); + }*/ + } + } + + public class ObjectFactoryImpl extends ObjectFactoryImplBase { + public ObjectFactoryImpl(Property property, Object propertyValue, boolean isSimpleType, Class<?> javaType) { + super(property, propertyValue, isSimpleType, javaType); + } + + public Object getInstance() throws ObjectCreationException { + if (isSimpleType) { + return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null); + } else { + return mediator.mediate(propertyValue, sourceDataType, targetDataType, null); + } + } + } + + public class ListObjectFactoryImpl extends ObjectFactoryImplBase { + public ListObjectFactoryImpl(Property property, List<?>propertyValues, boolean isSimpleType, Class<?> javaType) { + super(property, propertyValues, isSimpleType, javaType); + } + + public List<?> getInstance() throws ObjectCreationException { + if (isSimpleType) { + List<Object> values = new ArrayList<Object>(); + for (String aValue : (List<String>)propertyValue) { + values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null)); + } + return values; + } else { + List<Object> instances = new ArrayList<Object>(); + for (Node aValue : (List<Node>)propertyValue) { + instances.add(mediator.mediate(aValue, + sourceDataType, + targetDataType, + null)); + } + return instances; + } + } + } +} diff --git a/branches/sca-equinox/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator b/branches/sca-equinox/modules/implementation-script-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory index c8152b606f..941cfd7fd5 100644 --- a/branches/sca-equinox/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator +++ b/branches/sca-equinox/modules/implementation-script-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -13,6 +13,7 @@ # "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.
-# Implementation class for the ExtensionActivator
-org.apache.tuscany.sca.implementation.script.ScriptImplementationActivator
+# under the License.
+
+# Implementation class for the implementation extension
+org.apache.tuscany.sca.implementation.script.provider.ScriptImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.script.ScriptImplementation
diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/AbstractHelloWorldTestCase.java b/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/AbstractHelloWorldTestCase.java deleted file mode 100644 index 09239cd38f..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/AbstractHelloWorldTestCase.java +++ /dev/null @@ -1,38 +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.implementation.script.itests.dynamic; - -import org.apache.tuscany.sca.implementation.script.itests.AbstractSCATestCase; - -/** - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase<HelloWorld> { - - public void testHello() throws Exception { - assertEquals("Hello petra", service.sayHello("petra")); - } - - @Override - protected Class<HelloWorld> getServiceClass() { - return HelloWorld.class; - } -} diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/HelloWorld.java b/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/HelloWorld.java deleted file mode 100644 index 5781f4f2c9..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/HelloWorld.java +++ /dev/null @@ -1,31 +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.implementation.script.itests.dynamic; - -/** - * - * @version $Rev$ $Date$ - */ -public interface HelloWorld { - - String sayHello(String s); - String sayHelloFrom(String s); - -} diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptDynamicRefTestCase.java b/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptDynamicRefTestCase.java deleted file mode 100644 index e88e44c7c0..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptDynamicRefTestCase.java +++ /dev/null @@ -1,29 +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.implementation.script.itests.dynamic; - - -/** - * - * @version $Rev$ $Date$ - */ -public class JavaScriptDynamicRefTestCase extends AbstractHelloWorldTestCase { - // super class does it all getting composite based on this class name -} diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptHelloWorldTestCase.java b/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptHelloWorldTestCase.java deleted file mode 100644 index 331d5bcfd4..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptHelloWorldTestCase.java +++ /dev/null @@ -1,34 +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.implementation.script.itests.dynamic; - - -/** - * - * @version $Rev$ $Date$ - */ -public class JavaScriptHelloWorldTestCase extends AbstractHelloWorldTestCase { - // super class does it all getting composite based on this class name - - public void testHelloFrom() throws Exception { - System.out.println(service.sayHelloFrom("Venkat")); - assertEquals("Hello petra from Tuscany", service.sayHelloFrom("petra")); - } -} diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScripInlineHelloWorldTestCase.java b/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScripInlineHelloWorldTestCase.java deleted file mode 100644 index 93d1949c50..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScripInlineHelloWorldTestCase.java +++ /dev/null @@ -1,29 +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.implementation.script.itests.helloworld; - - -/** - * - * @version $Rev$ $Date$ - */ -public class JavaScripInlineHelloWorldTestCase extends AbstractHelloWorldTestCase { - // super class does it all getting composite based on this class name -} diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptDynamicRef.composite b/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptDynamicRef.composite deleted file mode 100644 index 77ba095988..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptDynamicRef.composite +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
- name="JavaScriptHelloWorld">
-
- <component name="ClientComponent">
- <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/dynamic/helloworldProxy.js"/>
- <reference name="delegate" target="DelegateComponent">
- <interface.java interface="org.apache.tuscany.sca.implementation.script.itests.dynamic.HelloWorld" />
- </reference>
- </component>
-
- <component name="DelegateComponent">
- <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/dynamic/helloworld.js"/>
- </component>
-
-</composite>
diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptHelloWorld.composite b/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptHelloWorld.composite deleted file mode 100644 index 4e71a4a3e6..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/JavaScriptHelloWorld.composite +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- name="JavaScriptHelloWorld">
-
- <component name="ClientComponent">
- <tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/dynamic/helloworld.js"/>
- <property name="greeter" type="xsd:string">Tuscany</property>
- </component>
-
-</composite>
diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/helloworld.js b/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/helloworld.js deleted file mode 100644 index beee72314d..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/helloworld.js +++ /dev/null @@ -1,26 +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. - */ - -function sayHello(s) { - return "Hello " + s; -} - -function sayHelloFrom(s) { - return "Hello " + s + " from " + greeter; -}
\ No newline at end of file diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/helloworldProxy.js b/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/helloworldProxy.js deleted file mode 100644 index 69a2f2e639..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/dynamic/helloworldProxy.js +++ /dev/null @@ -1,22 +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. - */ - -function sayHello(s) { - return delegate.sayHello(s); -}
\ No newline at end of file diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScripInlineHelloWorld.composite b/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScripInlineHelloWorld.composite deleted file mode 100644 index 7ddf517b96..0000000000 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScripInlineHelloWorld.composite +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
- name="JavaScriptHelloWorld">
-
- <component name="ClientComponent">
- <tuscany:implementation.script language="js">
-
- function sayHello(s) {
- return "Hello " + s;
- }
-
- </tuscany:implementation.script>
- </component>
-
-</composite>
diff --git a/branches/sca-equinox/modules/implementation-script-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator b/branches/sca-equinox/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor index c8152b606f..794fe423b0 100644 --- a/branches/sca-equinox/modules/implementation-script-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator +++ b/branches/sca-equinox/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -1,18 +1,19 @@ -# 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.
-# Implementation class for the ExtensionActivator
-org.apache.tuscany.sca.implementation.script.ScriptImplementationActivator
+# 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. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.implementation.script.ScriptImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#implementation.script,model=org.apache.tuscany.sca.implementation.script.ScriptImplementation
\ No newline at end of file |