diff options
Diffstat (limited to 'collaboration')
6 files changed, 332 insertions, 173 deletions
diff --git a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/pom.xml b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/pom.xml index 72eaccb559..4d28b5793e 100644 --- a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/pom.xml +++ b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/pom.xml @@ -1,170 +1,219 @@ <?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. ---> +<!-- * 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. --> <project> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-modules</artifactId> - <version>2.0-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>tuscany-implementation-scala-runtime</artifactId> - <name>Apache Tuscany SCA Scala Implementation Extension</name> - - <dependencies> - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-sca-api</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-implementation-scala</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-databinding</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.bsf</groupId> - <artifactId>bsf-utils</artifactId> - <version>3.1</version> - <exclusions> - <exclusion> - <groupId>org.apache.bsf</groupId> - <artifactId>bsf-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.bsf</groupId> - <artifactId>bsf-engines</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.ws.commons.axiom</groupId> - <artifactId>axiom-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.ws.commons.axiom</groupId> - <artifactId>axiom-impl</artifactId> - </exclusion> - <exclusion> - <groupId>stax</groupId> - <artifactId>stax-api</artifactId> - </exclusion> - <exclusion> - <groupId>xmlbeans</groupId> - <artifactId>xbean</artifactId> - </exclusion> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.codehaus.woodstox</groupId> - <artifactId>wstx-asl</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-interface-wsdl</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.ws.commons.axiom</groupId> - <artifactId>axiom-api</artifactId> - <exclusions> - <exclusion> - <groupId>xerces</groupId> - <artifactId>xercesImpl</artifactId> - </exclusion> - <exclusion> - <groupId>javax.mail</groupId> - <artifactId>mail</artifactId> - </exclusion> - <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </exclusion> - <exclusion> - <groupId>xml-apis</groupId> - <artifactId>xml-apis</artifactId> - </exclusion> - </exclusions> - <version>1.2.10</version> - </dependency> - - <dependency> - <groupId>org.apache.ws.commons.axiom</groupId> - <artifactId>axiom-impl</artifactId> - <version>1.2.10</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.8.1</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-node-impl</artifactId> - <version>2.0-SNAPSHOT</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-implementation-java-runtime</artifactId> - <version>2.0-SNAPSHOT</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>1.1.1</version> - <exclusions> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - </exclusion> - </exclusions> - </dependency> - - </dependencies> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>tuscany-implementation-scala-runtime</artifactId> + <name>Apache Tuscany SCA Scala Implementation Extension</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-scala</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.bsf</groupId> + <artifactId>bsf-utils</artifactId> + <version>3.1</version> + <exclusions> + <exclusion> + <groupId>org.apache.bsf</groupId> + <artifactId>bsf-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.bsf</groupId> + <artifactId>bsf-engines</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-impl</artifactId> + </exclusion> + <exclusion> + <groupId>stax</groupId> + <artifactId>stax-api</artifactId> + </exclusion> + <exclusion> + <groupId>xmlbeans</groupId> + <artifactId>xbean</artifactId> + </exclusion> + <exclusion> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>wstx-asl</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-wsdl</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-api</artifactId> + <exclusions> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + </exclusion> + <exclusion> + <groupId>javax.mail</groupId> + <artifactId>mail</artifactId> + </exclusion> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>xml-apis</groupId> + <artifactId>xml-apis</artifactId> + </exclusion> + </exclusions> + <version>1.2.10</version> + </dependency> + + <dependency> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-impl</artifactId> + <version>1.2.10</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-impl</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.1.1</version> + <exclusions> + <exclusion> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.scala-lang</groupId> + <artifactId>scala-library</artifactId> + <version>2.8.0</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + + <sourceDirectory>src/main/java</sourceDirectory> + <testSourceDirectory>src/test/java</testSourceDirectory> + + <plugins> + <plugin> + <groupId>org.scala-tools</groupId> + <artifactId>maven-scala-plugin</artifactId> + <version>2.15.0</version> + <executions> + <execution> + <goals> + <goal>compile</goal> + <goal>testCompile</goal> + </goals> + <configuration> + <args> + <arg>-make:transitive</arg> + <arg>-dependencyfile</arg> + <arg>${project.build.directory}/.scala_dependencies</arg> + </args> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>2.0-SNAPSHOT</version> + <dependencies> + <dependency> + <groupId>org.scala-lang</groupId> + <artifactId>scala-library</artifactId> + <version>2.8.0</version> + </dependency> + </dependencies> + </plugin> + </plugins> + + </build> </project> diff --git a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/ScalaException.java b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/ScalaException.java new file mode 100644 index 0000000000..5883a85187 --- /dev/null +++ b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/ScalaException.java @@ -0,0 +1,27 @@ +/* + * 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.scala; + +public class ScalaException extends Exception { + + public ScalaException(Exception e) { + super(e); + } +}
\ No newline at end of file diff --git a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaImplementationProvider.java b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaImplementationProvider.java index 51dd8512b1..f44fe8c91c 100644 --- a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaImplementationProvider.java +++ b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaImplementationProvider.java @@ -19,14 +19,26 @@ package org.apache.tuscany.sca.implementation.scala.provider; +import org.apache.tuscany.sca.implementation.scala.ScalaImplementation; +import org.apache.tuscany.sca.implementation.scala.util.ScalaEngine; import org.apache.tuscany.sca.interfacedef.Operation; 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; public class ScalaImplementationProvider implements ImplementationProvider{ + private RuntimeComponent component; + private ScalaImplementation implementation; + private ScalaEngine scalaEngine; + + public ScalaImplementationProvider (RuntimeComponent component, ScalaImplementation implementation) { + this.component = component; + this.implementation = implementation; + } + @Override public Invoker createInvoker(RuntimeComponentService service, Operation operation) { diff --git a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaImplementationProviderFactory.java b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaImplementationProviderFactory.java index 0bb8d4ac20..956c86c31c 100644 --- a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaImplementationProviderFactory.java +++ b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaImplementationProviderFactory.java @@ -19,24 +19,26 @@ package org.apache.tuscany.sca.implementation.scala.provider; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.implementation.scala.ScalaImplementation; import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.provider.ImplementationProviderFactory; import org.apache.tuscany.sca.runtime.RuntimeComponent; -public class ScalaImplementationProviderFactory implements ImplementationProviderFactory<ScalaImplementation>{ +public class ScalaImplementationProviderFactory implements ImplementationProviderFactory<ScalaImplementation> { + public ScalaImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { + } + @Override public ImplementationProvider createImplementationProvider( - RuntimeComponent component, ScalaImplementation Implementation) { - // TODO Auto-generated method stub - return null; + RuntimeComponent component, ScalaImplementation implementation) { + return new ScalaImplementationProvider(component, implementation); } @Override public Class<ScalaImplementation> getModelType() { - // TODO Auto-generated method stub - return null; + return ScalaImplementation.class; } } diff --git a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaInvoker.java b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaInvoker.java index f9955df818..a4f90257ae 100644 --- a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaInvoker.java +++ b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/provider/ScalaInvoker.java @@ -19,15 +19,43 @@ package org.apache.tuscany.sca.implementation.scala.provider; +import org.apache.tuscany.sca.implementation.scala.util.ScalaEngine; +import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; public class ScalaInvoker implements Invoker { + private Operation operation; + private ScalaEngine scalaEngine; + + public ScalaInvoker(ScalaEngine scalaEngine, Operation operation) { + this.operation = operation; + this.scalaEngine = scalaEngine; + } + + private Object doInvoke(Object[] objects, Operation op) throws Exception { + + Operation oper = operation; // static setting + if (oper.getName() == null) { // if no static setting + oper = op; // use dynamic setting + } + + Object response; + response = scalaEngine.invokeFunction(oper.getName(), objects); + + return response; + } + @Override public Message invoke(Message msg) { - // TODO Auto-generated method stub - return null; + try { + Object resp = doInvoke((Object[])msg.getBody(), msg.getOperation()); + msg.setBody(resp); + } catch (Exception e) { + msg.setFaultBody(e.getCause()); + } + return msg; } } diff --git a/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/util/ScalaEngine.java b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/util/ScalaEngine.java new file mode 100644 index 0000000000..46f5eb088b --- /dev/null +++ b/collaboration/GSoC-2011-Guilherme/modules/implementation-scala-runtime/src/main/java/org/apache/tuscany/sca/implementation/scala/util/ScalaEngine.java @@ -0,0 +1,41 @@ +/* + * 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.scala.util; + +import org.apache.tuscany.sca.implementation.scala.ScalaException; + +public class ScalaEngine { + + private Class scalaClass; + + public ScalaEngine(String className) throws ScalaException { + try { + scalaClass = Class.forName(className); + } catch (ClassNotFoundException e) { + throw new ScalaException(e); + } + } + + public Object invokeFunction(String name, Object[] arguments) { + // TODO Auto-generated method stub + return null; + } + +}
\ No newline at end of file |