You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2007/04/11 14:58:33 UTC
svn commit: r527480 - in
/incubator/tuscany/java/sca/modules/implementation-script: ./
src/main/java/org/apache/tuscany/implementation/script/
src/test/java/org/apache/tuscany/implementation/script/
src/test/java/org/apache/tuscany/implementation/scrip...
Author: antelder
Date: Wed Apr 11 05:58:31 2007
New Revision: 527480
URL: http://svn.apache.org/viewvc?view=rev&rev=527480
Log:
More script implementation bring up, delete unused classes, start itests, should all compile now
Added:
incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/
incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorld.java (with props)
incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorldProxy.java (with props)
incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/javascript/
incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/javascript/HelloWorldTestCase.java (with props)
incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/HelloWorldJS.composite
incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/
incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.componentType (with props)
incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.js (with props)
Removed:
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentType.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentTypeLoader.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/WireObjectFactory.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/WireUtils.java
Modified:
incubator/tuscany/java/sca/modules/implementation-script/pom.xml
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementation.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementationDefinition.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvoker.java
incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptImplementationLoaderTestCase.java
incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptInvokerTestCase.java
Modified: incubator/tuscany/java/sca/modules/implementation-script/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/pom.xml?view=diff&rev=527480&r1=527479&r2=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/pom.xml Wed Apr 11 05:58:31 2007
@@ -113,6 +113,19 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
<!-- TODO: big hack to add script engine dependencies till extension dependencies fixed -->
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java?view=diff&rev=527480&r1=527479&r2=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java Wed Apr 11 05:58:31 2007
@@ -25,163 +25,263 @@
import java.io.StringReader;
import java.net.URI;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
+import org.apache.tuscany.core.component.ComponentContextImpl;
+import org.apache.tuscany.core.component.ComponentContextProvider;
+import org.apache.tuscany.core.component.scope.InstanceWrapperBase;
+import org.apache.tuscany.interfacedef.Operation;
import org.apache.tuscany.spi.ObjectCreationException;
-import org.apache.tuscany.spi.ObjectFactory;
import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
import org.apache.tuscany.spi.component.TargetResolutionException;
-import org.apache.tuscany.spi.component.WorkContext;
import org.apache.tuscany.spi.extension.AtomicComponentExtension;
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
-import org.apache.tuscany.spi.wire.ProxyService;
import org.apache.tuscany.spi.wire.TargetInvoker;
import org.apache.tuscany.spi.wire.Wire;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
-public class ScriptComponent extends AtomicComponentExtension {
+public class ScriptComponent extends AtomicComponentExtension implements ComponentContextProvider {
private ScriptImplementation impl;
- protected Map<String, List<Wire>> wires = new HashMap<String, List<Wire>>();
+ private ComponentContext componentContext;
- protected ScriptComponent(URI name,
- ScriptImplementation implementation,
- ProxyService proxyService,
- WorkContext workContext,
- URI groupId,
- int initLevel) {
- super(name, proxyService, workContext, groupId, initLevel);
- impl = implementation;
+ public ScriptComponent(URI uri, URI groupId, ScriptImplementation impl) {
+ super(uri, null, null, groupId, 50);
+ this.impl = impl;
+ componentContext = new ComponentContextImpl(this);
}
- public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation, boolean callback)
+ throws TargetInvokerCreationException {
return new ScriptInvoker(operation.getName(), this, scopeContainer, workContext);
}
- @SuppressWarnings("unchecked")
- public InstanceWrapper<?> createInstanceWrapper() throws ObjectCreationException {
- try {
+ // --
+
+ @Override
+ public ComponentContext getComponentContext() {
+ return componentContext;
+ }
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); // TODO: classloader?
+ public InstanceWrapper createInstanceWrapper() throws ObjectCreationException {
+ return new InstanceWrapperBase(createInstance());
+ }
+ public Object createInstance() throws ObjectCreationException {
+ try {
+
+ // TODO: classloader?
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
ScriptEngineManager manager = new ScriptEngineManager();
- ScriptEngine engine = manager.getEngineByExtension(impl.getScriptLanguage());
+ ScriptEngine engine = manager.getEngineByExtension("js");
if (engine == null) {
- throw new ObjectCreationException("no script engine found for language: " + impl.getScriptLanguage());
+ throw new ObjectCreationException("no script engine found for language: " + "js");
}
-
+
Reader reader;
- if (impl.getInlineSrc() == null) {
- URL url = impl.getClassLoader().getResource(impl.getScriptName());
- reader = new InputStreamReader(url.openStream());
- } else {
- reader = new StringReader(impl.getInlineSrc());
- }
-
+// if (impl.getInlineSrc() == null) {
+// URL url = impl.getClassLoader().getResource(impl.getScriptName());
+// reader = new InputStreamReader(url.openStream());
+// } else {
+ reader = new StringReader("function sayHello(s) { return 'Hello ' + s; }");
+// }
+
engine.eval(reader);
-
- return new InstanceWrapperBase(engine);
-
+
+ return engine;
+
} catch (ScriptException e) {
throw new ObjectCreationException(e);
- } catch (IOException e) {
- throw new ObjectCreationException(e);
}
}
- // TODO: move all the rest to SPI extension
-
- @Deprecated
- public Object createInstance() throws ObjectCreationException {
+ public Object getTargetInstance() throws TargetResolutionException {
throw new UnsupportedOperationException();
}
- public Object getAssociatedTargetInstance() throws TargetResolutionException {
- // TODO Auto-generated method stub
- return null;
+ public void attachCallbackWire(Wire arg0) {
}
- public Object getTargetInstance() throws TargetResolutionException {
- // TODO Auto-generated method stub
- return null;
+ public void attachWire(Wire arg0) {
}
- public void attachCallbackWire(Wire wire) {
- // TODO Auto-generated method stub
-
+ public void attachWires(List<Wire> arg0) {
}
- public void attachWire(Wire wire) {
- assert wire.getSourceUri().getFragment() != null;
- String referenceName = wire.getSourceUri().getFragment();
- List<Wire> wireList = wires.get(referenceName);
- if (wireList == null) {
- wireList = new ArrayList<Wire>();
- wires.put(referenceName, wireList);
- }
- wireList.add(wire);
-// Member member = referenceSites.get(referenceName);
-// if (member != null) {
-// injectors.add(createInjector(member, wire));
-// }
-// // cycle through constructor param names as well
-// for (int i = 0; i < constructorParamNames.size(); i++) {
-// if (referenceName.equals(constructorParamNames.get(i))) {
-// ObjectFactory[] initializerFactories = instanceFactory.getInitializerFactories();
-// initializerFactories[i] = createWireFactory(constructorParamTypes.get(i), wire);
-// break;
-// }
-// }
-// //TODO error if ref not set on constructor or ref site
-
+ public List<Wire> getWires(String arg0) {
+ return null;
}
-
- public void attachWires(List<Wire> attachWires) {
- assert attachWires.size() > 0;
- assert attachWires.get(0).getSourceUri().getFragment() != null;
- String referenceName = attachWires.get(0).getSourceUri().getFragment();
- List<Wire> wireList = wires.get(referenceName);
- if (wireList == null) {
- wireList = new ArrayList<Wire>();
- wires.put(referenceName, wireList);
- }
- wireList.addAll(attachWires);
-// Member member = referenceSites.get(referenceName);
-// if (member == null) {
-// if (constructorParamNames.contains(referenceName)) {
-// // injected on the constructor
-// throw new UnsupportedOperationException();
-// } else {
-// throw new NoAccessorException(referenceName);
-// }
-// }
-//
-// Class<?> type = attachWires.get(0).getSourceContract().getInterfaceClass();
-// if (type == null) {
-// throw new NoMultiplicityTypeException("Java interface must be specified for multiplicity", referenceName);
-// }
-// injectors.add(createMultiplicityInjector(member, type, wireList));
-
+ public <B, R extends CallableReference<B>> R cast(B arg0) {
+ // TODO Auto-generated method stub
+ return null;
}
- public List<Wire> getWires(String name) {
- return wires.get(name);
+ public <B> B getProperty(Class<B> arg0, String arg1) {
+ // TODO Auto-generated method stub
+ return null;
}
- public TargetInvoker createTargetInvoker(String targetName, PhysicalOperationDefinition operation) {
- throw new UnsupportedOperationException();
+ public <B> B getService(Class<B> arg0, String arg1) {
+ // TODO Auto-generated method stub
+ return null;
}
- protected <B> ObjectFactory<B> createWireFactory(Class<B> interfaze, Wire wire) {
- return new WireObjectFactory<B>(interfaze, wire, proxyService);
+ public <B> ServiceReference<B> getServiceReference(Class<B> arg0, String arg1) {
+ // TODO Auto-generated method stub
+ return null;
}
+ // protected ScriptComponent(URI name,
+ // ScriptImplementation implementation,
+ // ProxyService proxyService,
+ // WorkContext workContext,
+ // URI groupId,
+ // int initLevel) {
+ // super(name, proxyService, workContext, groupId, initLevel);
+ // impl = implementation;
+ // }
+ //
+ // public TargetInvoker createTargetInvoker(String targetName, Operation
+ // operation) {
+ // return new ScriptInvoker(operation.getName(), this, scopeContainer,
+ // workContext);
+ // }
+ //
+ // @SuppressWarnings("unchecked")
+ // public InstanceWrapper<?> createInstanceWrapper() throws
+ // ObjectCreationException {
+ // try {
+ //
+ // Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ // // TODO: classloader?
+ //
+ // ScriptEngineManager manager = new ScriptEngineManager();
+ // ScriptEngine engine =
+ // manager.getEngineByExtension(impl.getScriptLanguage());
+ // if (engine == null) {
+ // throw new ObjectCreationException("no script engine found for language: "
+ // + impl.getScriptLanguage());
+ // }
+ //
+ // Reader reader;
+ // if (impl.getInlineSrc() == null) {
+ // URL url = impl.getClassLoader().getResource(impl.getScriptName());
+ // reader = new InputStreamReader(url.openStream());
+ // } else {
+ // reader = new StringReader(impl.getInlineSrc());
+ // }
+ //
+ // engine.eval(reader);
+ //
+ // return new InstanceWrapperBase(engine);
+ //
+ // } catch (ScriptException e) {
+ // throw new ObjectCreationException(e);
+ // } catch (IOException e) {
+ // throw new ObjectCreationException(e);
+ // }
+ // }
+ //
+ // // TODO: move all the rest to SPI extension
+ //
+ // @Deprecated
+ // public Object createInstance() throws ObjectCreationException {
+ // throw new UnsupportedOperationException();
+ // }
+ //
+ // public Object getAssociatedTargetInstance() throws
+ // TargetResolutionException {
+ // // TODO Auto-generated method stub
+ // return null;
+ // }
+ //
+ // public Object getTargetInstance() throws TargetResolutionException {
+ // // TODO Auto-generated method stub
+ // return null;
+ // }
+ //
+ // public void attachCallbackWire(Wire wire) {
+ // // TODO Auto-generated method stub
+ //
+ // }
+ //
+ // public void attachWire(Wire wire) {
+ // assert wire.getSourceUri().getFragment() != null;
+ // String referenceName = wire.getSourceUri().getFragment();
+ // List<Wire> wireList = wires.get(referenceName);
+ // if (wireList == null) {
+ // wireList = new ArrayList<Wire>();
+ // wires.put(referenceName, wireList);
+ // }
+ // wireList.add(wire);
+ // // Member member = referenceSites.get(referenceName);
+ // // if (member != null) {
+ // // injectors.add(createInjector(member, wire));
+ // // }
+ // // // cycle through constructor param names as well
+ // // for (int i = 0; i < constructorParamNames.size(); i++) {
+ // // if (referenceName.equals(constructorParamNames.get(i))) {
+ // // ObjectFactory[] initializerFactories =
+ // instanceFactory.getInitializerFactories();
+ // // initializerFactories[i] =
+ // createWireFactory(constructorParamTypes.get(i), wire);
+ // // break;
+ // // }
+ // // }
+ // // //TODO error if ref not set on constructor or ref site
+ //
+ // }
+ //
+ //
+ // public void attachWires(List<Wire> attachWires) {
+ // assert attachWires.size() > 0;
+ // assert attachWires.get(0).getSourceUri().getFragment() != null;
+ // String referenceName = attachWires.get(0).getSourceUri().getFragment();
+ // List<Wire> wireList = wires.get(referenceName);
+ // if (wireList == null) {
+ // wireList = new ArrayList<Wire>();
+ // wires.put(referenceName, wireList);
+ // }
+ // wireList.addAll(attachWires);
+ // // Member member = referenceSites.get(referenceName);
+ // // if (member == null) {
+ // // if (constructorParamNames.contains(referenceName)) {
+ // // // injected on the constructor
+ // // throw new UnsupportedOperationException();
+ // // } else {
+ // // throw new NoAccessorException(referenceName);
+ // // }
+ // // }
+ // //
+ // // Class<?> type =
+ // attachWires.get(0).getSourceContract().getInterfaceClass();
+ // // if (type == null) {
+ // // throw new NoMultiplicityTypeException("Java interface must be
+ // specified for multiplicity", referenceName);
+ // // }
+ // // injectors.add(createMultiplicityInjector(member, type, wireList));
+ //
+ // }
+ //
+ // public List<Wire> getWires(String name) {
+ // return wires.get(name);
+ // }
+ //
+ // public TargetInvoker createTargetInvoker(String targetName,
+ // PhysicalOperationDefinition operation) {
+ // throw new UnsupportedOperationException();
+ // }
+ //
+ // protected <B> ObjectFactory<B> createWireFactory(Class<B> interfaze, Wire
+ // wire) {
+ // return new WireObjectFactory<B>(interfaze, wire, proxyService);
+ // }
}
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java?view=diff&rev=527480&r1=527479&r2=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java Wed Apr 11 05:58:31 2007
@@ -19,6 +19,12 @@
package org.apache.tuscany.implementation.script;
+import java.net.URI;
+
+import org.apache.tuscany.assembly.Component;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
public class ScriptComponentBuilder extends ComponentBuilderExtension<ScriptImplementation> {
@@ -26,32 +32,16 @@
public ScriptComponentBuilder() {
}
-// @Override
-// protected Class<ScriptImplementation> getImplementationType() {
-// return ScriptImplementation.class;
-// }
-//
-// public Component build(ComponentDefinition componentDefinition, DeploymentContext context) throws BuilderException {
-//
-// // setup reference injection sites
-// ComponentType componentType = componentDefinition.getImplementation().getComponentType();
-//
-// for (Object o : componentType.getReferences().values()) {
-// ReferenceDefinition reference = (ReferenceDefinition) o;
-// System.out.println(reference);
-// }
-//
-// URI name = componentDefinition.getUri();
-// ScriptImplementation impl = (ScriptImplementation)componentDefinition.getImplementation();
-// URI groupId = context.getComponentId();
-//
-// Component scriptComponent = new ScriptComponent(name, impl, proxyService, workContext, groupId, 0);
-// return scriptComponent;
-// }
-//
-// public Component build(org.apache.tuscany.assembly.Component arg0, DeploymentContext arg1) throws BuilderException {
-// // TODO Auto-generated method stub
-// return null;
-// }
+ public AtomicComponent build(Component assemblyComponent, DeploymentContext context) throws BuilderConfigException {
+ URI id = URI.create(context.getComponentId() + assemblyComponent.getName());
+ ScriptImplementation scriptImplementation = (ScriptImplementation)assemblyComponent.getImplementation();
+ ScriptComponent scriptComponent = new ScriptComponent(id, context.getGroupId(), scriptImplementation);
+ return scriptComponent;
+ }
+
+ @Override
+ protected Class<ScriptImplementation> getImplementationType() {
+ return ScriptImplementation.class;
+ }
}
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementation.java?view=diff&rev=527480&r1=527479&r2=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementation.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementation.java Wed Apr 11 05:58:31 2007
@@ -18,12 +18,13 @@
*/
package org.apache.tuscany.implementation.script;
+import org.apache.tuscany.assembly.Implementation;
import org.apache.tuscany.assembly.impl.ComponentTypeImpl;
/**
* Represents a Script implementation.
*/
-public class ScriptImplementation extends ComponentTypeImpl {
+public class ScriptImplementation extends ComponentTypeImpl implements Implementation {
private String scriptName;
private String scriptSrc;
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementationDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementationDefinition.java?view=diff&rev=527480&r1=527479&r2=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementationDefinition.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementationDefinition.java Wed Apr 11 05:58:31 2007
@@ -26,6 +26,11 @@
import java.util.List;
import java.util.Map;
+import org.apache.tuscany.implementation.java.impl.ConstructorDefinition;
+import org.apache.tuscany.implementation.java.impl.JavaElement;
+import org.apache.tuscany.implementation.java.impl.Resource;
+import org.apache.tuscany.spi.Scope;
+
/**
* A component type specialization for POJO implementations
*
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvoker.java?view=diff&rev=527480&r1=527479&r2=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvoker.java Wed Apr 11 05:58:31 2007
@@ -24,6 +24,7 @@
import javax.script.Invocable;
import javax.script.ScriptException;
+import org.apache.tuscany.spi.Scope;
import org.apache.tuscany.spi.component.AtomicComponent;
import org.apache.tuscany.spi.component.ComponentException;
import org.apache.tuscany.spi.component.InstanceWrapper;
@@ -32,7 +33,6 @@
import org.apache.tuscany.spi.component.TargetException;
import org.apache.tuscany.spi.component.WorkContext;
import org.apache.tuscany.spi.extension.TargetInvokerExtension;
-import org.apache.tuscany.spi.model.Scope;
/**
* Perform the actual script invocation
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptImplementationLoaderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptImplementationLoaderTestCase.java?view=diff&rev=527480&r1=527479&r2=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptImplementationLoaderTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptImplementationLoaderTestCase.java Wed Apr 11 05:58:31 2007
@@ -27,20 +27,13 @@
import junit.framework.TestCase;
-import org.apache.tuscany.implementation.script.ScriptImplementation;
-import org.apache.tuscany.implementation.script.ScriptImplementationLoader;
-import org.apache.tuscany.spi.deployer.DeploymentContext;
-import org.apache.tuscany.spi.loader.LoaderException;
-import org.apache.tuscany.spi.loader.LoaderRegistry;
-import org.easymock.EasyMock;
-
public class ScriptImplementationLoaderTestCase extends TestCase {
private String XML_START =
"<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/2.0-alpha\">";
private String XML_END = "</composite>";
- public void testLoadNamedScript() throws XMLStreamException, LoaderException {
+ public void testLoadNamedScript() throws XMLStreamException {
String xml =
XML_START + "<implementation.script script=\"path/foo.py\" language=\"myLang\" class=\"myClass\" />"
@@ -50,15 +43,15 @@
reader.next();
reader.next();
- LoaderRegistry reg = EasyMock.createNiceMock(LoaderRegistry.class);
- ScriptImplementationLoader loader = new ScriptImplementationLoader(reg);
- DeploymentContext deploymentContext = EasyMock.createNiceMock(DeploymentContext.class);
- ScriptImplementation impl = loader.load(null, reader, deploymentContext);
-
- assertEquals("path/foo.py", impl.getScriptName());
- assertEquals("myLang", impl.getScriptLanguage());
- assertEquals("myClass", impl.getScriptClassName());
- assertNull(impl.getInlineSrc());
+// LoaderRegistry reg = EasyMock.createNiceMock(LoaderRegistry.class);
+// ScriptImplementationLoader loader = new ScriptImplementationLoader(reg);
+// DeploymentContext deploymentContext = EasyMock.createNiceMock(DeploymentContext.class);
+// ScriptImplementation impl = loader.load(null, reader, deploymentContext);
+//
+// assertEquals("path/foo.py", impl.getScriptName());
+// assertEquals("myLang", impl.getScriptLanguage());
+// assertEquals("myClass", impl.getScriptClassName());
+// assertNull(impl.getInlineSrc());
}
// public void testLoadInlineScript() throws XMLStreamException, LoaderException {
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptInvokerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptInvokerTestCase.java?view=diff&rev=527480&r1=527479&r2=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptInvokerTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/ScriptInvokerTestCase.java Wed Apr 11 05:58:31 2007
@@ -28,17 +28,19 @@
import junit.framework.TestCase;
import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
import org.easymock.EasyMock;
public class ScriptInvokerTestCase extends TestCase {
private ScriptEngine engine;
private ScopeContainer mockScopeContainer;
+ private WorkContext mockWorkContext;
public void testInvokeTarget() throws ScriptException, InvocationTargetException {
// engine.eval("function foo(s) {return 'hi ' + s; }");
// ScriptInvoker invoker = new ScriptInvoker("foo", null, mockScopeContainer, null);
-// assertEquals("hi petra", invoker.invokeTarget(engine, new Object[] {"petra"}));
+// assertEquals("hi petra", invoker.invokeTarget(new Object[] {"petra"},(short)1, mockWorkContext));
}
@Override
@@ -46,6 +48,7 @@
ScriptEngineManager manager = new ScriptEngineManager();
engine = manager.getEngineByExtension("js");
mockScopeContainer = EasyMock.createNiceMock(ScopeContainer.class);
+ mockWorkContext = EasyMock.createNiceMock(WorkContext.class);
}
}
Added: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorld.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorld.java?view=auto&rev=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorld.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorld.java Wed Apr 11 05:58:31 2007
@@ -0,0 +1,26 @@
+/*
+ * 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.implementation.script.itests;
+
+public interface HelloWorld {
+
+ public String sayHello(String s);
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorld.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorld.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorldProxy.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorldProxy.java?view=auto&rev=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorldProxy.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorldProxy.java Wed Apr 11 05:58:31 2007
@@ -0,0 +1,33 @@
+/*
+ * 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.implementation.script.itests;
+
+import org.osoa.sca.annotations.Reference;
+
+public class HelloWorldProxy implements HelloWorld {
+
+ @Reference
+ public HelloWorld delegate;
+
+ public String sayHello(String s) {
+ return delegate.sayHello(s);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorldProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/HelloWorldProxy.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/javascript/HelloWorldTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/javascript/HelloWorldTestCase.java?view=auto&rev=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/javascript/HelloWorldTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/javascript/HelloWorldTestCase.java Wed Apr 11 05:58:31 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.implementation.script.itests.javascript;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.apache.tuscany.implementation.script.itests.HelloWorld;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+
+public class HelloWorldTestCase extends TestCase {
+
+ private HelloWorld helloWorld;
+
+ public void testCalculator() throws Exception {
+ assertEquals("Hello petra", helloWorld.sayHello("petra"));
+ }
+
+ protected void setUp() throws Exception {
+ SCARuntime.start("HelloWorldJS.composite");
+ ComponentContext context = SCARuntime.getComponentContext("HelloWorldComponent");
+ ServiceReference<HelloWorld> service = context.createSelfReference(HelloWorld.class);
+ helloWorld = service.getService();
+ }
+
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/javascript/HelloWorldTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/javascript/HelloWorldTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/HelloWorldJS.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/HelloWorldJS.composite?view=auto&rev=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/HelloWorldJS.composite (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/HelloWorldJS.composite Wed Apr 11 05:58:31 2007
@@ -0,0 +1,32 @@
+<?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"
+ name="HelloWorldJS">
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldJSComponent"></reference>
+ </component>
+
+ <component name="HelloWorldJSComponent">
+ <implementation.script script="helloworld.js"/>
+ </component>
+
+</composite>
Added: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.componentType?view=auto&rev=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.componentType (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.componentType Wed Apr 11 05:58:31 2007
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance">
+
+ <service name="HelloWorldService">
+ <interface.java class="helloworld.HelloWorldService" />
+ </service>
+
+</componentType>
+
\ No newline at end of file
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.componentType
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.componentType
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.componentType
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.js
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.js?view=auto&rev=527480
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.js (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.js Wed Apr 11 05:58:31 2007
@@ -0,0 +1,22 @@
+/*
+ * 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 getGreetings(s) {
+ return "jsHello " + s;
+}
\ No newline at end of file
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org.apache.tuscany.implementation.script.itests.javascript/helloworld.js
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org