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/19 17:22:40 UTC
svn commit: r530454 - in
/incubator/tuscany/java/sca/modules/implementation-script/src:
main/java/org/apache/tuscany/implementation/script/
test/java/org/apache/tuscany/implementation/script/itests/helloworld/
test/resources/org/apache/tuscany/implemen...
Author: antelder
Date: Thu Apr 19 08:22:28 2007
New Revision: 530454
URL: http://svn.apache.org/viewvc?view=rev&rev=530454
Log:
Script implementation, add a python helloworld test and get all the helloworld itests running
Added:
incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java (with props)
incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorld.composite
incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py (with props)
Modified:
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java
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/ScriptImplementation.java
incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js
incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.rb
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java?view=diff&rev=530454&r1=530453&r2=530454
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java Thu Apr 19 08:22:28 2007
@@ -45,6 +45,7 @@
public class ScriptArtifactProcessor implements StAXArtifactProcessorExtension<ScriptImplementation> {
private static final String SCRIPT = "script";
+ private static final String LANGUAGE = "language";
private static final String IMPLEMENTATION_SCRIPT = "implementation.script";
private static final QName IMPLEMENTATION_SCRIPT_QNAME = new QName(Constants.SCA10_NS, IMPLEMENTATION_SCRIPT);
@@ -56,7 +57,12 @@
try {
String scriptName = reader.getAttributeValue(null, SCRIPT);
- ScriptImplementation scriptImplementation = new ScriptImplementation(scriptName);
+ String scriptLanguage = reader.getAttributeValue(null, LANGUAGE);
+ if (scriptLanguage == null || scriptLanguage.length() < 1) {
+ int i = scriptName.lastIndexOf('.');
+ scriptLanguage = scriptName.substring(i+1);
+ }
+ ScriptImplementation scriptImplementation = new ScriptImplementation(scriptName, scriptLanguage);
// Skip to end element
while (reader.hasNext()) {
@@ -77,7 +83,7 @@
private void processComponentType(ScriptImplementation scriptImplementation) {
// Form the URI of the expected .componentType file;
- String ctName = scriptImplementation.getName();
+ String ctName = scriptImplementation.getScriptName();
int lastDot = ctName.lastIndexOf('.');
ctName = ctName.substring(0, lastDot) + ".componentType";
@@ -94,8 +100,8 @@
try {
writer.writeStartElement(Constants.SCA10_NS, IMPLEMENTATION_SCRIPT);
- if (scriptImplementation.getName() != null) {
- writer.writeAttribute(SCRIPT, scriptImplementation.getName());
+ if (scriptImplementation.getScriptName() != null) {
+ writer.writeAttribute(SCRIPT, scriptImplementation.getScriptName());
}
writer.writeEndElement();
@@ -106,10 +112,10 @@
public void resolve(ScriptImplementation scriptImplementation, ArtifactResolver resolver) throws ContributionResolveException {
- scriptImplementation.setScriptSrc(readScript(scriptImplementation.getName()));
+ scriptImplementation.setScriptSrc(readScript(scriptImplementation.getScriptName()));
ClassLoader cl = Thread.currentThread().getContextClassLoader();
- String scriptURI = cl.getResource(scriptImplementation.getName()).toString();
+ String scriptURI = cl.getResource(scriptImplementation.getScriptName()).toString();
int lastDot = scriptURI.lastIndexOf('.');
String ctURI = scriptURI.substring(0, lastDot) + ".componentType";
ComponentType ct = scriptImplementation.getComponentType();
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=530454&r1=530453&r2=530454
==============================================================================
--- 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 Thu Apr 19 08:22:28 2007
@@ -81,17 +81,17 @@
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
ScriptEngineManager manager = new ScriptEngineManager();
- ScriptEngine engine = manager.getEngineByExtension("js");
+ ScriptEngine engine = manager.getEngineByExtension(impl.getScriptLanguage());
if (engine == null) {
- throw new ObjectCreationException("no script engine found for language: " + "js");
+ 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());
+// URL url = impl.getClassLoader().getResource(impl.getScriptName());
+// reader = new InputStreamReader(url.openStream());
// } else {
- reader = new StringReader("function sayHello(s) { return 'Hello ' + s; }");
+ reader = new StringReader(impl.getScriptSrc());
// }
engine.eval(reader);
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=530454&r1=530453&r2=530454
==============================================================================
--- 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 Thu Apr 19 08:22:28 2007
@@ -32,15 +32,21 @@
private String scriptName;
private String scriptSrc;
+ private String scriptLanguage;
private ComponentType componentType;
- public ScriptImplementation(String scriptName) {
+ public ScriptImplementation(String scriptName, String scriptLanguage) {
this.scriptName = scriptName;
+ this.scriptLanguage = scriptLanguage;
setUnresolved(true);
}
- public String getName() {
+ public String getScriptName() {
return scriptName;
+ }
+
+ public String getScriptLanguage() {
+ return scriptLanguage;
}
public String getScriptSrc() {
Added: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java?view=auto&rev=530454
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java Thu Apr 19 08:22:28 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.helloworld;
+
+
+public class JythonHelloWorldTestCase extends AbstractHelloWorldTestCase {
+ // super class does it all getting composite based on this class name
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorld.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorld.composite?view=auto&rev=530454
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorld.composite (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorld.composite Thu Apr 19 08:22:28 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="JythonHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py"/>
+ </component>
+
+</composite>
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js?view=diff&rev=530454&r1=530453&r2=530454
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js Thu Apr 19 08:22:28 2007
@@ -17,6 +17,6 @@
* under the License.
*/
-function getGreetings(s) {
+function sayHello(s) {
return "Hello " + s;
}
Added: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py?view=auto&rev=530454
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py Thu Apr 19 08:22:28 2007
@@ -0,0 +1,20 @@
+# 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.
+#
+
+def sayHello(s):
+ return 'Hello ' + s
\ No newline at end of file
Propchange: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.rb
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.rb?view=diff&rev=530454&r1=530453&r2=530454
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.rb (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.rb Thu Apr 19 08:22:28 2007
@@ -1,22 +1,21 @@
-/*
- * 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.
- */
+# 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.
+#
-def getGreetings(s)
- return \"Hello \" + s
+def sayHello(s)
+ return "Hello " + s
end
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org