summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/samples/sca-features
diff options
context:
space:
mode:
authorkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2010-09-16 15:27:07 +0000
committerkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2010-09-16 15:27:07 +0000
commitbd4c82405f5b1928d0e6071fdecc7a36be57f696 (patch)
treee21ffadd53b85651543a7050f651f304bad0284f /sca-java-2.x/trunk/samples/sca-features
parentc1edd74392bb1e8cd4cb103664b3e9f7e95fcff8 (diff)
TUSCANY-3677 all implementation.* samples are part of sca-features samples set
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@997789 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/samples/sca-features')
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/README8
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/pom.xml79
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/Java.java34
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/WSDL.java34
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/WSDLReference.java28
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/EmbedUtil.java311
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/ImplUtil.java148
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleImplementation.java41
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleImplementationProcessor.java174
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleJavaInvoker.java52
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleProvider.java91
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleProviderFactory.java48
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleWSDLInvoker.java56
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleWSDLProxy.java57
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema18
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/sample/impl/sample.xsd38
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Client.java35
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/ClientTest.java65
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Hello.java33
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/JelloTest.java40
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Upper.java33
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/UpperTest.java37
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/WelloTest.java59
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Xutil.java225
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java151
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/ReadWriteTestCase.java84
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/RunTestCase.java75
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/RunWSTestCase.java120
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/TestUtil.java31
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/Hello.wsdl62
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/Upper.wsdl62
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/test.composite60
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/README1
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/README25
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/build.xml56
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/pom.xml58
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/AddService.java28
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorClient.java62
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorService.java37
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java70
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/Calculator.composite49
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/CalculatorClient.composite30
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java49
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-java/pom.xml43
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/README1
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/README26
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/build.xml57
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/pom.xml58
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/AddService.java28
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorClient.java52
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorService.java37
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java72
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/Calculator.composite50
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/CalculatorClient.composite30
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.componentType30
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.js22
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.componentType30
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.groovy22
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.componentType30
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.py20
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.componentType30
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.rb21
-rw-r--r--sca-java-2.x/trunk/samples/sca-features/implementation-script/pom.xml43
77 files changed, 3952 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/README b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/README
new file mode 100644
index 0000000000..3c3ef5e3d5
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/README
@@ -0,0 +1,8 @@
+Sample Implementation Extension
+===============================
+This sample demonstrates how to develop a new component implementation type
+for Apache Tuscany SCA.
+
+The README in the samples directory (the directory above this) provides
+instructions about building and running the samples. Take a look there.
+
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/pom.xml b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/pom.xml
new file mode 100644
index 0000000000..47aff7e941
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/pom.xml
@@ -0,0 +1,79 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-implementation-extension</artifactId>
+ <name>Apache Tuscany SCA Sample Implementation Extension</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-web20</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/Java.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/Java.java
new file mode 100644
index 0000000000..6c9240005f
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/Java.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample.api;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target( {TYPE, FIELD})
+@Retention(RUNTIME)
+public @interface Java {
+
+ Class<?> value();
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/WSDL.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/WSDL.java
new file mode 100644
index 0000000000..655770ec32
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/WSDL.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample.api;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target( {TYPE, FIELD})
+@Retention(RUNTIME)
+public @interface WSDL {
+
+ String value();
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/WSDLReference.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/WSDLReference.java
new file mode 100644
index 0000000000..cad8478a2a
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/api/WSDLReference.java
@@ -0,0 +1,28 @@
+/*
+ * 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 sample.api;
+
+import org.w3c.dom.Element;
+
+public interface WSDLReference {
+
+ Element call(String op, Element e);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/EmbedUtil.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/EmbedUtil.java
new file mode 100644
index 0000000000..0ccbcc9e36
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/EmbedUtil.java
@@ -0,0 +1,311 @@
+/*
+ * 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 sample.impl;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+
+/**
+ * A few utility functions to help embed a Tuscany runtime, and a simple DSL
+ * to help assemble and run SCDL.
+ */
+public class EmbedUtil {
+
+ /**
+ * A runtime embedder context, which conveniently initializes a Node factory
+ * and gets the various registries, factories and extension points we need.
+ */
+ static class Context {
+ final NodeFactory nf;
+ final ExtensionPointRegistry epr;
+ final FactoryExtensionPoint fep;
+ final ContributionFactory cf;
+ final AssemblyFactory af;
+ final JavaInterfaceFactory jif;
+ final WSDLFactory wif;
+ final URLArtifactProcessorExtensionPoint apep;
+ final ExtensibleURLArtifactProcessor aproc;
+ final ModelResolverExtensionPoint mrep;
+ final ProviderFactoryExtensionPoint pfep;
+
+ Context(final NodeFactory nf) {
+ this.nf = nf;
+ epr = nf.getExtensionPointRegistry();
+ fep = epr.getExtensionPoint(FactoryExtensionPoint.class);
+ cf = fep.getFactory(ContributionFactory.class);
+ af = fep.getFactory(AssemblyFactory.class);
+ jif = fep.getFactory(JavaInterfaceFactory.class);
+ wif = fep.getFactory(WSDLFactory.class);
+ apep = epr.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ aproc = new ExtensibleURLArtifactProcessor(apep);
+ mrep = epr.getExtensionPoint(ModelResolverExtensionPoint.class);
+ pfep = epr.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ }
+ }
+
+ static Context embedContext(NodeFactory nf) {
+ return new Context(nf);
+ }
+
+ /**
+ * A mini DSL to help build and assemble contributions and SCDL composites.
+ */
+ interface Builder<T> {
+ T build(Context ec);
+ }
+
+ static <T> T build(final Builder<T> builder, final Context ec) {
+ return builder.build(ec);
+ }
+
+ /**
+ * Return a contribution builder.
+ */
+ static Builder<Contribution> contrib(final String uri, final String loc, final Builder<Artifact>... artifacts) {
+ return new Builder<Contribution>() {
+ public Contribution build(final Context ec) {
+ final Contribution c = ec.cf.createContribution();
+ c.setURI(uri);
+ c.setLocation(loc);
+ c.setModelResolver(new ExtensibleModelResolver(c, ec.mrep, ec.fep));
+ for(Builder<Artifact> a: artifacts)
+ c.getArtifacts().add(a.build(ec));
+ return c;
+ }
+ };
+ }
+
+ /**
+ * Return an artifact builder.
+ */
+ static Builder<Artifact> artifact(final String uri, final Object model) {
+ return new Builder<Artifact>() {
+ public Artifact build(final Context ec) {
+ final Artifact a = ec.cf.createArtifact();
+ a.setURI(uri);
+ a.setModel(model);
+ return a;
+ }
+ };
+ }
+
+ /**
+ * Return a composite builder.
+ */
+ static Builder<Composite> composite(final String ns, final String name, final Builder<Component>... components) {
+ return new Builder<Composite>() {
+ public Composite build(final Context ec) {
+ final Composite compos = ec.af.createComposite();
+ compos.setName(new QName(ns, name));
+ for(final Builder<Component> c: components)
+ compos.getComponents().add(c.build(ec));
+ return compos;
+ }
+ };
+ }
+
+ /**
+ * Return a component builder.
+ */
+ static Builder<Component> component(final String name, final Builder<Implementation> impl, final Builder<ComponentReference>... references) {
+ return new Builder<Component>() {
+ public Component build(final Context ec) {
+ final Component c = ec.af.createComponent();
+ c.setName(name);
+ c.setImplementation(impl.build(ec));
+ for(Builder<ComponentReference> r: references)
+ c.getReferences().add(r.build(ec));
+ return c;
+ }
+ };
+ }
+
+ /**
+ * Return an implementation builder.
+ */
+ static Builder<Implementation> implementation(final Class<?> clazz, final Builder<Contract>... contracts) {
+ return new Builder<Implementation>() {
+ public SampleImplementation build(final Context ec) {
+ final SampleImplementation impl = ImplUtil.implementation(clazz.getName());
+ impl.clazz = clazz;
+ impl.setUnresolved(false);
+ for(final Builder<Contract> b: contracts) {
+ Contract c = b.build(ec);
+ if(c instanceof Service)
+ impl.getServices().add((Service)c);
+ else
+ impl.getReferences().add((Reference)c);
+ }
+ return impl;
+ }
+ };
+ }
+
+ /**
+ * Return a reference builder.
+ */
+ static Builder<Contract> reference(final String name, final Class<?> c) {
+ return new Builder<Contract>() {
+ public Reference build(final Context ec) {
+ try {
+ return ImplUtil.reference(name, c, ec.jif, ec.af);
+ } catch(InvalidInterfaceException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ }
+
+ static Builder<Contract> reference(final String name, final WSDLInterface c) {
+ return new Builder<Contract>() {
+ public Reference build(final Context ec) {
+ return ImplUtil.reference(name, c, ec.wif, ec.af);
+ }
+ };
+ }
+
+ static Builder<ComponentReference> reference(final String name, final String target) {
+ return new Builder<ComponentReference>() {
+ public ComponentReference build(final Context ec) {
+ final ComponentReference r = ec.af.createComponentReference();
+ r.setName(name);
+ final ComponentService s = ec.af.createComponentService();
+ s.setUnresolved(true);
+ s.setName(target);
+ r.getTargets().add(s);
+ return r;
+ }
+ };
+ }
+
+ /**
+ * Return a service builder.
+ */
+ static Builder<Contract> service(final Class<?> c) {
+ return new Builder<Contract>() {
+ public Service build(final Context ec) {
+ try {
+ return ImplUtil.service(c, ec.jif, ec.af);
+ } catch(InvalidInterfaceException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ }
+
+ static Builder<Contract> service(final WSDLInterface c) {
+ return new Builder<Contract>() {
+ public Service build(final Context ec) {
+ return ImplUtil.service(c, ec.wif, ec.af);
+ }
+ };
+ }
+
+ /**
+ * Return a WSDLInterface builder which loads a WSDL into a contribution.
+ */
+ static Builder<WSDLInterface> wsdli(final String uri, final String ns, final String name, final Contribution c) {
+ return new Builder<WSDLInterface>() {
+ public WSDLInterface build(final Context ec) {
+ try {
+ final ProcessorContext ctx = new ProcessorContext();
+ final WSDLDefinition wd = ec.aproc.read(null, new URI(uri), new URL(new URL(c.getLocation()), uri), ctx, WSDLDefinition.class);
+ c.getModelResolver().addModel(wd, ctx);
+ c.getModelResolver().resolveModel(WSDLDefinition.class, wd, ctx);
+ final WSDLObject<PortType> pt = wd.getWSDLObject(PortType.class, new QName(ns, name));
+ if(pt == null)
+ throw new ContributionResolveException("Couldn't find " + name);
+ final WSDLInterface nwi = ec.wif.createWSDLInterface(pt.getElement(), wd, c.getModelResolver(), null);
+ nwi.setWsdlDefinition(wd);
+ nwi.resetDataBinding(DOMDataBinding.NAME);
+ return nwi;
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ }
+
+ /**
+ * Return the extension point registry used by our nodes.
+ */
+ static ExtensionPointRegistry extensionPoints(final Context ec) {
+ return ec.epr;
+ }
+
+ /**
+ * Return the provider factory extension point used by our nodes.
+ */
+ static ProviderFactoryExtensionPoint providerFactories(final Context ec) {
+ return ec.pfep;
+ }
+
+ /**
+ * Add a deployable composite to a contribution.
+ */
+ static Contribution deploy(final Contribution contrib, final Composite... comps) {
+ for(Composite c: comps)
+ contrib.getDeployables().add(c);
+ return contrib;
+ }
+
+ /**
+ * Configure a node with a list of contributions.
+ */
+ static Node node(final NodeFactory nf, final Contribution... contributions) {
+ return nf.createNode(Arrays.asList(contributions));
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/ImplUtil.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/ImplUtil.java
new file mode 100644
index 0000000000..abd4cd7ab0
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/ImplUtil.java
@@ -0,0 +1,148 @@
+/*
+ * 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 sample.impl;
+
+import java.lang.annotation.Annotation;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+
+import sample.api.Java;
+import sample.api.WSDL;
+
+/**
+ * Utility functions to help develop a component implementation extension.
+ */
+class ImplUtil {
+
+ /**
+ * Return a Sample implementation with the given name.
+ */
+ static SampleImplementation implementation(String name) {
+ final SampleImplementation impl = new SampleImplementation(name);
+ impl.setUnresolved(true);
+ return impl;
+ }
+
+ /**
+ * Return the Java class configured on an annotation.
+ */
+ static Class<?> clazz(final Annotation a) {
+ return ((Java)a).value();
+ }
+
+ /**
+ * Return the WSDL QName configured on an annotation.
+ */
+ static QName qname(final Annotation a) {
+ final String uri = ((WSDL)a).value();
+ final int h = uri.indexOf('#');
+ return new QName(uri.substring(0, h), uri.substring(h + 1));
+ }
+
+ /**
+ * Convert a Java class to an interface contract.
+ */
+ static JavaInterfaceContract contract(final Class<?> c, final JavaInterfaceFactory jif) throws InvalidInterfaceException {
+ final JavaInterfaceContract ic = jif.createJavaInterfaceContract();
+ ic.setInterface(jif.createJavaInterface(c));
+ return ic;
+ }
+
+ /**
+ * Convert a WSDL interface to an interface contract.
+ */
+ static WSDLInterfaceContract contract(final WSDLInterface wi, final WSDLFactory wf) {
+ final WSDLInterfaceContract ic = wf.createWSDLInterfaceContract();
+ ic.setInterface(wi);
+ return ic;
+ }
+
+ /**
+ * Convert a Java class to a service.
+ */
+ static Service service(final Class<?> c, final JavaInterfaceFactory jif, final AssemblyFactory af) throws InvalidInterfaceException {
+ Service s = af.createService();
+ s.setName(c.getSimpleName());
+ s.setInterfaceContract(contract(c, jif));
+ return s;
+ }
+
+ /**
+ * Convert a WSDL interface to a service.
+ */
+ static Service service(final WSDLInterface wi, final WSDLFactory wf, final AssemblyFactory af) {
+ Service s = af.createService();
+ s.setName(wi.getName().getLocalPart());
+ s.setInterfaceContract(contract(wi, wf));
+ return s;
+ }
+
+ /**
+ * Convert a name and Java class to a reference.
+ */
+ static Reference reference(final String name, final Class<?> c, final JavaInterfaceFactory jif, final AssemblyFactory af) throws InvalidInterfaceException {
+ final Reference r = af.createReference();
+ r.setName(name);
+ r.setInterfaceContract(contract(c, jif));
+ return r;
+ }
+
+ /**
+ * Convert a name and WSDL interface to a reference.
+ */
+ static Reference reference(final String name, final WSDLInterface wi, final WSDLFactory wf, final AssemblyFactory af) {
+ final Reference r = af.createReference();
+ r.setName(name);
+ r.setInterfaceContract(contract(wi, wf));
+ return r;
+ }
+
+ /**
+ * Convert a WSDL qname to a WSDL interface.
+ */
+ static WSDLInterface interfaze(final QName name, final WSDLFactory wif) {
+ final WSDLInterface wir = wif.createWSDLInterface();
+ wir.setUnresolved(true);
+ wir.setName(name);
+ return wir;
+ }
+
+ /**
+ * Convert a WSDL qname to a WSDL definition.
+ */
+ static WSDLDefinition definition(final QName name, final WSDLFactory wif) {
+ final WSDLDefinition wdr = wif.createWSDLDefinition();
+ wdr.setUnresolved(true);
+ wdr.setNamespace(name.getNamespaceURI());
+ wdr.setNameOfPortTypeToResolve(name);
+ return wdr;
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleImplementation.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleImplementation.java
new file mode 100644
index 0000000000..41ce71a732
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleImplementation.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 sample.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+
+/**
+ * Model representing a Sample implementation in an SCA assembly.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SampleImplementation extends ImplementationImpl {
+ static final QName QN = new QName(SCA11_TUSCANY_NS, "implementation.sample");
+
+ final String name;
+ Class<?> clazz;
+
+ SampleImplementation(final String name) {
+ super(QN);
+ this.name = name;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleImplementationProcessor.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleImplementationProcessor.java
new file mode 100644
index 0000000000..6017030d35
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleImplementationProcessor.java
@@ -0,0 +1,174 @@
+/*
+ * 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 sample.impl;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static sample.impl.SampleImplementation.QN;
+import static sample.impl.ImplUtil.clazz;
+import static sample.impl.ImplUtil.definition;
+import static sample.impl.ImplUtil.implementation;
+import static sample.impl.ImplUtil.interfaze;
+import static sample.impl.ImplUtil.qname;
+import static sample.impl.ImplUtil.reference;
+import static sample.impl.ImplUtil.service;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject;
+
+import sample.api.Java;
+import sample.api.WSDL;
+
+/**
+ * StAX artifact processor for Sample implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SampleImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<SampleImplementation> {
+ final AssemblyFactory af;
+ final JavaInterfaceFactory jif;
+ final WSDLFactory wf;
+
+ public SampleImplementationProcessor(final ExtensionPointRegistry ep) {
+ final FactoryExtensionPoint fep = ep.getExtensionPoint(FactoryExtensionPoint.class);
+ this.af = fep.getFactory(AssemblyFactory.class);
+ this.jif = fep.getFactory(JavaInterfaceFactory.class);
+ this.wf = fep.getFactory(WSDLFactory.class);
+ }
+
+ public QName getArtifactType() {
+ return QN;
+ }
+
+ public Class<SampleImplementation> getModelType() {
+ return SampleImplementation.class;
+ }
+
+ public SampleImplementation read(final XMLStreamReader r, final ProcessorContext ctx) throws ContributionReadException, XMLStreamException {
+ // Read the component implementation element
+ final SampleImplementation impl = implementation(r.getAttributeValue(null, "class"));
+ while(r.hasNext() && !(r.next() == END_ELEMENT && QN.equals(r.getName())))
+ ;
+ return impl;
+ }
+
+ public void resolve(final SampleImplementation impl, final ModelResolver res, final ProcessorContext ctx) throws ContributionResolveException {
+ try {
+ // Resolve and introspect the implementation class
+ impl.clazz = resolve(impl.name, res, ctx);
+
+ for(final Annotation a: impl.clazz.getAnnotations()) {
+ if(a instanceof Java)
+ impl.getServices().add(service(clazz(a), jif, af));
+ else if(a instanceof WSDL)
+ impl.getServices().add(service(resolve(qname(a), res, ctx, wf), wf, af));
+ }
+
+ for(Field f: impl.clazz.getDeclaredFields()) {
+ for(final Annotation a: f.getAnnotations()) {
+ if(a instanceof Java)
+ impl.getReferences().add(reference(f.getName(), clazz(a), jif, af));
+ else if(a instanceof WSDL)
+ impl.getReferences().add(reference(f.getName(), resolve(qname(a), res, ctx, wf), wf, af));
+ }
+ }
+
+ impl.setUnresolved(false);
+ } catch(InvalidInterfaceException e) {
+ throw new ContributionResolveException(e);
+ }
+ }
+
+ public void write(final SampleImplementation impl, final XMLStreamWriter w, final ProcessorContext ctx) throws ContributionWriteException, XMLStreamException {
+ writeStart(w, QN.getNamespaceURI(), QN.getLocalPart(), new XAttr("class", impl.name));
+ writeEnd(w);
+ }
+
+ /**
+ * Resolve a Java class.
+ */
+ static Class<?> resolve(final String name, final ModelResolver res, final ProcessorContext ctx) throws ContributionResolveException {
+ final ClassReference cr = res.resolveModel(ClassReference.class, new ClassReference(name), ctx);
+ if(cr.getJavaClass() != null)
+ return cr.getJavaClass();
+ throw new ContributionResolveException(new ClassNotFoundException(name));
+ }
+
+ /**
+ * Resolve a WSDL interface.
+ */
+ static WSDLInterface resolve(final QName name, final ModelResolver res, final ProcessorContext ctx, final WSDLFactory wif) throws ContributionResolveException {
+ final WSDLInterface wi = res.resolveModel(WSDLInterface.class, interfaze(name, wif), ctx);
+ if(!wi.isUnresolved())
+ return domBound(wi);
+
+ final WSDLDefinition wd = res.resolveModel(WSDLDefinition.class, definition(wi.getName(), wif), ctx);
+ if(wd.isUnresolved())
+ throw new ContributionResolveException("Couldn't find " + name.getNamespaceURI());
+
+ WSDLObject<PortType> pt = wd.getWSDLObject(PortType.class, name);
+ if(pt == null)
+ throw new ContributionResolveException("Couldn't find " + name);
+ try {
+ final WSDLInterface nwi = wif.createWSDLInterface(pt.getElement(), wd, res, ctx.getMonitor());
+ nwi.setWsdlDefinition(wd);
+ res.addModel(nwi, ctx);
+ return domBound(nwi);
+ } catch(InvalidInterfaceException e) {
+ throw new ContributionResolveException(e);
+ }
+ }
+
+ /**
+ * Return a WSDL interface configured to use a DOM databinding.
+ */
+ static WSDLInterface domBound(WSDLInterface wi) throws ContributionResolveException {
+ try {
+ final WSDLInterface domwi = (WSDLInterface)wi.clone();
+ domwi.resetDataBinding(DOMDataBinding.NAME);
+ return domwi;
+ } catch(CloneNotSupportedException e) {
+ throw new ContributionResolveException(e);
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleJavaInvoker.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleJavaInvoker.java
new file mode 100644
index 0000000000..244251c4c9
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleJavaInvoker.java
@@ -0,0 +1,52 @@
+/*
+ * 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 sample.impl;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Invoker for Sample components that implement a Java interface.
+ *
+ * @version $Rev$ $Date$
+ */
+class SampleJavaInvoker implements Invoker {
+ final Object instance;
+ final Method method;
+
+ SampleJavaInvoker(final JavaOperation op, final Class<?> clazz, final Object instance) throws SecurityException, NoSuchMethodException {
+ this.instance = instance;
+ this.method = clazz.getMethod(op.getJavaMethod().getName(), op.getJavaMethod().getParameterTypes());
+ }
+
+ public Message invoke(final Message msg) {
+ try {
+ // Call the method that implements the operation
+ msg.setBody(method.invoke(instance, (Object[])msg.getBody()));
+ } catch(Exception e) {
+ e.printStackTrace();
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleProvider.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleProvider.java
new file mode 100644
index 0000000000..5d946b037b
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleProvider.java
@@ -0,0 +1,91 @@
+/*
+ * 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 sample.impl;
+
+import java.lang.reflect.Field;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
+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;
+
+/**
+ * Implementation provider for Sample component implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+class SampleProvider implements ImplementationProvider {
+ final RuntimeComponent comp;
+ final SampleImplementation impl;
+ final ProxyFactory pxf;
+ Object instance;
+
+ SampleProvider(final RuntimeComponent comp, final SampleImplementation impl, ProxyFactory pf) {
+ this.comp = comp;
+ this.impl = impl;
+ this.pxf = pf;
+ }
+
+ public void start() {
+ // Construct implementation instance and inject reference proxies
+ try {
+ instance = impl.clazz.newInstance();
+
+ for(ComponentReference r: comp.getReferences()) {
+ final Field f = impl.clazz.getDeclaredField(r.getName());
+ f.setAccessible(true);
+ // Inject a Java or WSDLReference proxy
+ final Interface i = r.getInterfaceContract().getInterface();
+ if(i instanceof JavaInterface)
+ f.set(instance, pxf.createProxy(comp.getComponentContext().getServiceReference(f.getType(), r.getName())));
+ else
+ f.set(instance, new SampleWSDLProxy(r.getEndpointReferences().get(0), i));
+ }
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stop() {
+ instance = null;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public Invoker createInvoker(final RuntimeComponentService s, final Operation op) {
+ try {
+ // Creating an invoker for a Java or WSDL-typed implementation
+ if(op instanceof JavaOperation)
+ return new SampleJavaInvoker((JavaOperation)op, impl.clazz, instance);
+ return new SampleWSDLInvoker((WSDLOperation)op, impl.clazz, instance);
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleProviderFactory.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleProviderFactory.java
new file mode 100644
index 0000000000..4ad24d33ff
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleProviderFactory.java
@@ -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 sample.impl;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Factory for Sample implementation providers.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SampleProviderFactory implements ImplementationProviderFactory<SampleImplementation> {
+ final ProxyFactory pxf;
+
+ public SampleProviderFactory(final ExtensionPointRegistry ep) {
+ pxf = ExtensibleProxyFactory.getInstance(ep);
+ }
+
+ public ImplementationProvider createImplementationProvider(final RuntimeComponent comp, final SampleImplementation impl) {
+ return new SampleProvider(comp, impl, pxf);
+ }
+
+ public Class<SampleImplementation> getModelType() {
+ return SampleImplementation.class;
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleWSDLInvoker.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleWSDLInvoker.java
new file mode 100644
index 0000000000..6c5317274f
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleWSDLInvoker.java
@@ -0,0 +1,56 @@
+/*
+ * 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 sample.impl;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.w3c.dom.Element;
+
+/**
+ * Invoker for Sample components that implement a WSDL interface using a generic
+ * call method.
+ *
+ * @version $Rev$ $Date$
+ */
+class SampleWSDLInvoker implements Invoker {
+ final String name;
+ final Object instance;
+ final Method method;
+
+ SampleWSDLInvoker(final WSDLOperation op, final Class<?> clazz, final Object instance) throws SecurityException, NoSuchMethodException {
+ this.name = op.getName();
+ this.instance = instance;
+ this.method = clazz.getMethod("call", String.class, Element.class);
+ }
+
+ public Message invoke(final Message msg) {
+ try {
+ // Invoke the generic call method
+ msg.setBody(method.invoke(instance, name, ((Object[])msg.getBody())[0]));
+ } catch(Exception e) {
+ e.printStackTrace();
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleWSDLProxy.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleWSDLProxy.java
new file mode 100644
index 0000000000..a6882a0103
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/java/sample/impl/SampleWSDLProxy.java
@@ -0,0 +1,57 @@
+/*
+ * 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 sample.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.w3c.dom.Element;
+
+import sample.api.WSDLReference;
+
+/**
+ * Proxy used to call operations on WSDL references.
+ */
+class SampleWSDLProxy implements WSDLReference {
+ final RuntimeEndpointReference repr;
+ final Map<String, Operation> ops;
+
+ SampleWSDLProxy(EndpointReference epr, Interface wi) {
+ repr = (RuntimeEndpointReference)epr;
+ ops = new HashMap<String, Operation>();
+ for(Operation o: wi.getOperations())
+ ops.put(o.getName(), o);
+ }
+
+ @Override
+ public Element call(String op, Element e) {
+ try {
+ // Invoke the named operation on the endpoint reference
+ return (Element)repr.invoke(ops.get(op), new Object[] {e});
+ } catch(InvocationTargetException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..908ac95a2e
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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.
+
+# Implementation class for the artifact processor extension
+sample.impl.SampleImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementation.sample,model=sample.impl.SampleImplementation
+
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..85aff44074
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
@@ -0,0 +1,18 @@
+# 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.
+#
+sample/impl/sample.xsd
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..32a7efcaf9
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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.
+
+# Implementation provider for Sample components
+sample.impl.SampleProviderFactory;model=sample.impl.SampleImplementation
+
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/sample/impl/sample.xsd b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/sample/impl/sample.xsd
new file mode 100644
index 0000000000..c057aef1c1
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/main/resources/sample/impl/sample.xsd
@@ -0,0 +1,38 @@
+<?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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"/>
+
+ <element name="implementation.sample" type="t:SampleImplementation" substitutionGroup="sca:implementation"/>
+
+ <complexType name="SampleImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <attribute name="class" type="string" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Client.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Client.java
new file mode 100644
index 0000000000..1b7e11c786
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Client.java
@@ -0,0 +1,35 @@
+/*
+ * 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 sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Sample service interface.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Client {
+
+ String jello(String s);
+
+ String wello(String s);
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/ClientTest.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/ClientTest.java
new file mode 100644
index 0000000000..92291c98a1
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/ClientTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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 sample;
+
+import static java.lang.System.out;
+import static sample.Xutil.elem;
+import static sample.Xutil.elems;
+import static sample.Xutil.print;
+import static sample.Xutil.select;
+import static sample.Xutil.text;
+import static sample.Xutil.xdom;
+import static sample.Xutil.xfilter;
+import static sample.Xutil.xreduce;
+
+import org.w3c.dom.Element;
+
+import sample.api.Java;
+import sample.api.WSDL;
+import sample.api.WSDLReference;
+
+/**
+ * Sample component implementation that uses a mix of Java and WSDL interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+@Java(Client.class)
+public class ClientTest {
+
+ @Java(Hello.class)
+ Hello jello;
+
+ @WSDL("http://sample/hello#Hello")
+ WSDLReference wello;
+
+ public String jello(String s) {
+ out.println("ClientTest.jello(" + s + ")");
+ return jello.hello(s);
+ }
+
+ public String wello(String s) {
+ out.println("ClientTest.wello(" + s + ")");
+ final Element hreq = xdom("http://sample/hello", "hello", elem("name", text(s)));
+
+ final Element hres = wello.call("hello", hreq);
+
+ return xreduce(print, "", xfilter(select("result"), elems(hres)));
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Hello.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Hello.java
new file mode 100644
index 0000000000..247fc8aa78
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Hello.java
@@ -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 sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Sample service interface.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Hello {
+
+ String hello(String s);
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/JelloTest.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/JelloTest.java
new file mode 100644
index 0000000000..5c999a6c80
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/JelloTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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 sample;
+
+import static java.lang.System.out;
+import sample.api.Java;
+
+/**
+ * Sample component implementation that uses Java interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+@Java(Hello.class)
+public class JelloTest {
+
+ @Java(Upper.class)
+ Upper upper;
+
+ public String hello(String s) {
+ out.println("JelloTest.hello(" + s + ")");
+ return upper.upper("Hello " + s);
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Upper.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Upper.java
new file mode 100644
index 0000000000..9c772b3487
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Upper.java
@@ -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 sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Sample service interface.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Upper {
+
+ String upper(String s);
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/UpperTest.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/UpperTest.java
new file mode 100644
index 0000000000..5399e4410d
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/UpperTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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 sample;
+
+import static java.lang.System.out;
+import sample.api.Java;
+
+/**
+ * Sample component implementation that uses Java interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+@Java(Upper.class)
+public class UpperTest {
+
+ public String upper(String s) {
+ out.println("UpperTest.upper(" + s + ")");
+ return s.toUpperCase();
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/WelloTest.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/WelloTest.java
new file mode 100644
index 0000000000..1bb9fc11ce
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/WelloTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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 sample;
+
+import static java.lang.System.out;
+import static sample.Xutil.elem;
+import static sample.Xutil.elems;
+import static sample.Xutil.print;
+import static sample.Xutil.select;
+import static sample.Xutil.text;
+import static sample.Xutil.xdom;
+import static sample.Xutil.xfilter;
+import static sample.Xutil.xml;
+import static sample.Xutil.xreduce;
+
+import org.w3c.dom.Element;
+
+import sample.api.WSDL;
+import sample.api.WSDLReference;
+
+/**
+ * Sample component implementation that uses WSDL interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+@WSDL("http://sample/hello#Hello")
+public class WelloTest {
+
+ @WSDL("http://sample/upper#Upper")
+ WSDLReference upper;
+
+ public Element call(String op, Element e) {
+ out.println("WelloTest." + op + "(" + xml(e) + ")");
+ final String name = xreduce(print, "", xfilter(select("name"), elems(e)));
+
+ final Element ureq = xdom("http://sample/upper", "upper", elem("s", text("Hello " + name)));
+ final Element ures = upper.call("upper", ureq);
+
+ final String s = xreduce(print, "", xfilter(select("result"), elems(ures)));
+ return xdom("http://sample/hello", "helloResponse", elem("result", text(s)));
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Xutil.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Xutil.java
new file mode 100644
index 0000000000..ce89f9dd8c
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/Xutil.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 sample;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Just for fun, a little bit of magic code and utility functions to help work with XML DOM.
+ */
+class Xutil {
+ interface NodeBuilder {
+ Node build(Document doc);
+ }
+
+ /**
+ * Convert a name and a list of children to a document element.
+ */
+ static Element xdom(String ns, String name, final NodeBuilder... nodes) {
+ return (Element)elem(ns, name, nodes).build(db.newDocument());
+ }
+
+ /**
+ * Convert a name and children to an element.
+ */
+ static NodeBuilder elem(final String uri, final String n, final NodeBuilder... nodes) {
+ return new NodeBuilder() {
+ public Node build(Document doc) {
+ final Element e = doc.createElementNS(uri, n);
+ for(final NodeBuilder n: nodes)
+ e.appendChild(n.build(doc));
+ return e;
+ }
+ };
+ }
+
+ static NodeBuilder elem(final String n, final NodeBuilder... nodes) {
+ return elem(null, n, nodes);
+ }
+
+ /**
+ * Convert a string to a text element.
+ */
+ static NodeBuilder text(final String t) {
+ return new NodeBuilder() {
+ public Node build(final Document doc) {
+ return doc.createTextNode(t);
+ }
+ };
+ }
+
+ private final static DocumentBuilder db = db();
+
+ private static DocumentBuilder db() {
+ try {
+ return DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ } catch(ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Convert an element to XML.
+ */
+ static TransformerFactory trf = TransformerFactory.newInstance();
+
+ static String xml(final Node node) {
+ try {
+ final StreamResult r = new StreamResult(new StringWriter());
+ trf.newTransformer().transform(new DOMSource(node), r);
+ return r.getWriter().toString();
+ } catch(TransformerException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Evaluate an xpath expression.
+ */
+ private static XPathFactory xpf = XPathFactory.newInstance();
+
+ static String xpath(final String expr, final Node node) {
+ final XPath xp = xpf.newXPath();
+ try {
+ return (String)xp.evaluate(expr, node, XPathConstants.STRING);
+ } catch(XPathExpressionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * A pure Java FP-style alternative to xpath for DOM.
+ */
+ interface Mapper<T> {
+ T map(final Element e);
+ }
+
+ static Mapper<Element> identity = new Mapper<Element>() {
+ public Element map(Element e) {
+ return e;
+ };
+ };
+
+ interface Reducer<T> {
+ T reduce(final T accum, final Element e);
+ }
+
+ static Reducer<String> print = new Reducer<String>() {
+ public String reduce(String accum, Element e) {
+ return accum + e.getTextContent();
+ }
+ };
+
+ /**
+ * Apply a mapper to a list of elements.
+ */
+ static <T> List<T> xmap(final Mapper<T> f, final Iterable<Element> l) {
+ final List<T> v = new ArrayList<T>();
+ for(Element e: l)
+ v.add(f.map(e));
+ return v;
+ }
+
+ /**
+ * Apply a filter to a list of elements.
+ */
+ static List<Element> xfilter(final Mapper<Boolean> f, final Iterable<Element> l) {
+ final List<Element> v = new ArrayList<Element>();
+ for(Element e: l)
+ if(f.map(e))
+ v.add(e);
+ return v;
+ }
+
+ /**
+ * Perform a reduction over a list of elements.
+ */
+ static <T> T xreduce(final Reducer<T> f, final T initial, final Iterable<Element> l) {
+ T accum = initial;
+ for(Element e: l)
+ accum = f.reduce(accum, e);
+ return accum;
+ }
+
+ /**
+ * Return a filter that selects elements by name.
+ */
+ static Mapper<Boolean> select(final String name) {
+ return new Mapper<Boolean>() {
+ public Boolean map(Element e) {
+ return name.equals(e.getLocalName());
+ }
+ };
+ }
+
+ /**
+ * Return the child elements of a node.
+ */
+ static Iterable<Element> elems(final Node parent) {
+ final List<Element> l = new ArrayList<Element>();
+ for (Node n: children(parent))
+ if (n instanceof Element)
+ l.add((Element)n);
+ return l;
+ }
+
+ /**
+ * An iterable over the children of a node.
+ */
+ private static Iterable<Node> children(Node parent) {
+ final NodeList l = parent.getChildNodes();
+ final int n = l.getLength();
+ return new Iterable<Node>() {
+ public Iterator<Node> iterator() {
+ return new Iterator<Node>() {
+ int i = 0;
+ public boolean hasNext() {
+ return i < n;
+ }
+ public Node next() {
+ return l.item(i++);
+ }
+ public void remove() {
+ }
+ };
+ }
+ };
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java
new file mode 100644
index 0000000000..406dbabee0
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java
@@ -0,0 +1,151 @@
+/*
+ * 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 sample.impl;
+
+import static java.lang.System.out;
+import static org.junit.Assert.assertEquals;
+import static sample.impl.EmbedUtil.build;
+import static sample.impl.EmbedUtil.component;
+import static sample.impl.EmbedUtil.composite;
+import static sample.impl.EmbedUtil.contrib;
+import static sample.impl.EmbedUtil.deploy;
+import static sample.impl.EmbedUtil.embedContext;
+import static sample.impl.EmbedUtil.extensionPoints;
+import static sample.impl.EmbedUtil.implementation;
+import static sample.impl.EmbedUtil.node;
+import static sample.impl.EmbedUtil.providerFactories;
+import static sample.impl.EmbedUtil.reference;
+import static sample.impl.EmbedUtil.service;
+import static sample.impl.EmbedUtil.wsdli;
+import static sample.impl.TestUtil.here;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import sample.Client;
+import sample.ClientTest;
+import sample.Hello;
+import sample.JelloTest;
+import sample.Upper;
+import sample.UpperTest;
+import sample.WelloTest;
+
+/**
+ * Test how to assemble a contribution, a SCDL composite and run it on an embedded
+ * Tuscany runtime node. Also shows how pass in a ProviderFactory instead of having
+ * it loaded and constructed by the runtime node.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EmbedTestCase {
+ static NodeFactory nf;
+ static EmbedUtil.Context ec;
+ static Node node;
+
+ @SuppressWarnings("unchecked")
+ @BeforeClass
+ public static void setUp() throws Exception {
+ nf = NodeFactory.newInstance();
+ ec = embedContext(nf);
+
+ // Load the test WSDL definitions (could also construct the WSDL
+ // and XSD models in code but that'd be quite painful, so just
+ // load them from XML for now)
+ final Contribution contrib = build(contrib("test", here()), ec);
+ WSDLInterface Hello_wsdl = build(wsdli("Hello.wsdl", "http://sample/hello", "Hello", contrib), ec);
+ WSDLInterface Upper_wsdl = build(wsdli("Upper.wsdl", "http://sample/upper", "Upper", contrib), ec);
+
+ // Assemble a test composite model (see EmbedUtil
+ // for the little DSL used here, much more concise
+ // than using the assembly model interfaces)
+ final Composite comp =
+ build(composite("http://sample", "test",
+ component("client-test",
+ implementation(ClientTest.class,
+ service(Client.class),
+ reference("jello", Hello.class),
+ reference("wello", Hello_wsdl)),
+ reference("jello", "jello-test"),
+ reference("wello", "wello-test")),
+ component("wello-test",
+ implementation(WelloTest.class,
+ service(Hello_wsdl),
+ reference("upper", Upper_wsdl)),
+ reference("upper", "upper-test")),
+ component("jello-test",
+ implementation(JelloTest.class,
+ service(Hello.class),
+ reference("upper", Upper.class)),
+ reference("upper", "upper-test")),
+ component("upper-test",
+ implementation(UpperTest.class,
+ service(Upper.class)))), ec);
+
+ // Register a test instance of our sample implementation ProviderFactory
+ providerFactories(ec).addProviderFactory(testProviderFactory());
+
+ // Run with it
+ node = node(nf, deploy(contrib, comp));
+ node.start();
+ }
+
+ static ProviderFactory<SampleImplementation> testProviderFactory() {
+ // This shows how to get called when a provider is created
+ return new SampleProviderFactory(extensionPoints(ec)) {
+ public ImplementationProvider createImplementationProvider(RuntimeComponent comp, SampleImplementation impl) {
+ out.println("Creating a provider for component " + comp.getName());
+ return super.createImplementationProvider(comp, impl);
+ }};
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void jello() {
+ out.println("RunTestCase.jello");
+ final String r = client().jello("Java");
+ out.println(r);
+ assertEquals("HELLO JAVA", r);
+ }
+
+ @Test
+ public void wello() {
+ out.println("RunTestCase.wello");
+ final String r = client().wello("WSDL");
+ out.println(r);
+ assertEquals("HELLO WSDL", r);
+ }
+
+ static Client client() {
+ return node.getService(Client.class, "client-test/Client");
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/ReadWriteTestCase.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/ReadWriteTestCase.java
new file mode 100644
index 0000000000..8a4768cd9e
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/ReadWriteTestCase.java
@@ -0,0 +1,84 @@
+/*
+ * 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 sample.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static sample.impl.TestUtil.here;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DefaultContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test read/write Sample SCDL implementation elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadWriteTestCase {
+ static XMLInputFactory xif;
+ static XMLOutputFactory xof;
+ static StAXArtifactProcessor<Object> xproc;
+ static ProcessorContext ctx;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final DefaultExtensionPointRegistry ep = new DefaultExtensionPointRegistry();
+ final Contribution contrib = new DefaultContributionFactory().createContribution();
+ contrib.setLocation(here());
+ ctx = new ProcessorContext(contrib, null);
+ xif = XMLInputFactory.newInstance();
+ xof = XMLOutputFactory.newInstance();
+ final StAXArtifactProcessorExtensionPoint xpep = new DefaultStAXArtifactProcessorExtensionPoint(ep);
+ xproc = new ExtensibleStAXArtifactProcessor(xpep, xif, xof);
+ }
+
+ @Test
+ public void testRead() throws Exception {
+ final InputStream is = getClass().getClassLoader().getResourceAsStream("test.composite");
+ final Composite c = (Composite)xproc.read(xif.createXMLStreamReader(is), ctx);
+ assertNotNull(c);
+ assertEquals("sample.ClientTest", ((SampleImplementation)c.getComponents().get(0).getImplementation()).name);
+ }
+
+ @Test
+ public void testReadWrite() throws Exception {
+ final InputStream is = getClass().getClassLoader().getResourceAsStream("test.composite");
+ final Composite c = (Composite)xproc.read(xif.createXMLStreamReader(is), ctx);
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ xproc.write(c, xof.createXMLStreamWriter(bos), ctx);
+ assertTrue(bos.toString().contains("class=\"sample.WelloTest\""));
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/RunTestCase.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/RunTestCase.java
new file mode 100644
index 0000000000..29bf02d26b
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/RunTestCase.java
@@ -0,0 +1,75 @@
+/*
+ * 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 sample.impl;
+
+import static java.lang.System.out;
+import static org.junit.Assert.assertEquals;
+import static sample.impl.TestUtil.here;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import sample.Client;
+
+/**
+ * Test how to run an SCA contribution containing a test composite on a
+ * Tuscany runtime node.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RunTestCase {
+ static Node node;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final NodeFactory nf = NodeFactory.newInstance();
+ node = nf.createNode(new Contribution("test", here()));
+ node.start();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void jello() {
+ out.println("RunTestCase.jello");
+ final String r = client().jello("Java");
+ out.println(r);
+ assertEquals("HELLO JAVA", r);
+ }
+
+ @Test
+ public void wello() {
+ out.println("RunTestCase.wello");
+ final String r = client().wello("WSDL");
+ out.println(r);
+ assertEquals("HELLO WSDL", r);
+ }
+
+ static Client client() {
+ return node.getService(Client.class, "client-test/Client");
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/RunWSTestCase.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/RunWSTestCase.java
new file mode 100644
index 0000000000..61133d0fbf
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/RunWSTestCase.java
@@ -0,0 +1,120 @@
+/*
+ * 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 sample.impl;
+
+import static java.lang.System.out;
+import static org.junit.Assert.assertTrue;
+import static sample.impl.TestUtil.here;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.Socket;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.http.jetty.JettyServer;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test a component that provides and consumes SOAP Web services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RunWSTestCase {
+ static Node node;
+ static JettyServer jetty;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ // Start test composite on a Tuscany node
+ final NodeFactory nf = NodeFactory.newInstance();
+ node = nf.createNode(new Contribution("test", here()));
+ node.start();
+
+ // Mock up a test Web service on http://localhost:8086/wsupper
+ jetty = new JettyServer((ExtensionPointRegistry)nf.getExtensionPointRegistry());
+ jetty.start();
+ jetty.addServletMapping("http://localhost:8086/wsupper", new HttpServlet() {
+ private static final long serialVersionUID = 1L;
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ assertTrue(read(req.getInputStream()).contains("Hello SOAP"));
+ final String soapresp =
+ "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+ "<soapenv:Body><upperResponse xmlns=\"http://sample/upper\">" +
+ "<result xmlns=\"\">HELLO SOAP</result>" +
+ "</upperResponse></soapenv:Body></soapenv:Envelope>";
+
+ write(soapresp, resp.getOutputStream());
+ }
+ });
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ jetty.stop();
+ node.stop();
+ }
+
+ @Test
+ public void wsello() throws Exception {
+ out.println("RunWSTestCase.wsello");
+ // Send a SOAP request to the Web service provided by SCA component wsello-test
+ // on http://localhost:8085/wsello
+ final Socket s = new Socket("localhost", 8085);
+ final String soapreq =
+ "POST /wsello HTTP/1.0\r\n" +
+ "Content-Type: text/xml; charset=UTF-8\r\n" +
+ "Content-length: 231\r\n\r\n" +
+ "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+ "<soapenv:Body><hello xmlns=\"http://sample/hello\">" +
+ "<name xmlns=\"\">SOAP</name>" +
+ "</hello></soapenv:Body></soapenv:Envelope>";
+ write(soapreq, s.getOutputStream());
+ assertTrue(read(s.getInputStream()).contains("HELLO SOAP"));
+ }
+
+ static void write(final String s, final OutputStream o) throws IOException {
+ final OutputStreamWriter w = new OutputStreamWriter(o);
+ w.write(s);
+ w.flush();
+ }
+
+ static String read(final InputStream i) throws IOException {
+ return read(new BufferedReader(new InputStreamReader(i)));
+ }
+
+ static String read(final BufferedReader r) throws IOException {
+ final String s = r.readLine();
+ return s == null? "" : s + read(r);
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/TestUtil.java b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/TestUtil.java
new file mode 100644
index 0000000000..6dcfb33912
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/java/sample/impl/TestUtil.java
@@ -0,0 +1,31 @@
+/*
+ * 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 sample.impl;
+
+/**
+ * A hack to determine the test contribution location.
+ */
+public class TestUtil {
+
+ static String here() {
+ return TestUtil.class.getProtectionDomain().getCodeSource().getLocation().toString();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/Hello.wsdl b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/Hello.wsdl
new file mode 100644
index 0000000000..360cea5ff3
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/Hello.wsdl
@@ -0,0 +1,62 @@
+<?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.
+-->
+<wsdl:definitions targetNamespace="http://sample/hello" xmlns:tns="http://sample/hello"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="Hello">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://sample/hello"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="hello">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="helloResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="helloRequest">
+ <wsdl:part element="tns:hello" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="helloResponse">
+ <wsdl:part element="tns:helloResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Hello">
+ <wsdl:operation name="hello">
+ <wsdl:input message="tns:helloRequest" name="helloRequest" />
+ <wsdl:output message="tns:helloResponse" name="helloResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/Upper.wsdl b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/Upper.wsdl
new file mode 100644
index 0000000000..8a148bb5e8
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/Upper.wsdl
@@ -0,0 +1,62 @@
+<?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.
+-->
+<wsdl:definitions targetNamespace="http://sample/upper" xmlns:tns="http://sample/upper"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="Upper">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://sample/upper"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="upper">
+ <complexType>
+ <sequence>
+ <element name="s" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="upperResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="upperRequest">
+ <wsdl:part element="tns:upper" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="upperResponse">
+ <wsdl:part element="tns:upperResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Upper">
+ <wsdl:operation name="upper">
+ <wsdl:input message="tns:upperRequest" name="upperRequest" />
+ <wsdl:output message="tns:upperResponse" name="upperResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/test.composite b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/test.composite
new file mode 100644
index 0000000000..43a75f50a7
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-extension/src/test/resources/test.composite
@@ -0,0 +1,60 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://test"
+ name="wstest">
+
+ <!-- Client test component used by the JUnit tests -->
+ <component name="client-test">
+ <t:implementation.sample class="sample.ClientTest"/>
+ <reference name="wello" target="wello-test"/>
+ <reference name="jello" target="jello-test"/>
+ </component>
+
+ <!-- HelloWorld test component that uses WSDL interfaces -->
+ <component name="wello-test">
+ <t:implementation.sample class="sample.WelloTest"/>
+ <reference name="upper" target="upper-test"/>
+ </component>
+
+ <!-- HelloWorld test component that uses Java interfaces -->
+ <component name="jello-test">
+ <t:implementation.sample class="sample.JelloTest"/>
+ <reference name="upper" target="upper-test"/>
+ </component>
+
+ <!-- HelloWorld test component that uses WSDL interfaces and SOAP Web Services -->
+ <component name="Wsello-test">
+ <t:implementation.sample class="sample.WelloTest"/>
+ <service name="Hello">
+ <binding.ws uri="http://localhost:8085/wsello"/>
+ </service>
+ <reference name="upper">
+ <binding.ws uri="http://localhost:8086/wsupper"/>
+ </reference>
+ </component>
+
+ <!-- Test component converts a string to uppercase -->
+ <component name="upper-test">
+ <t:implementation.sample class="sample.UpperTest"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/README b/sca-java-2.x/trunk/samples/sca-features/implementation-java/README
new file mode 100644
index 0000000000..18ba62d494
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/README
@@ -0,0 +1 @@
+Please look at the README files in the subdirectories of this directory for descriptions of the sample contributions.
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/README b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/README
new file mode 100644
index 0000000000..9e1ff828ee
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/README
@@ -0,0 +1,25 @@
+Calculator Sample Contribution
+==============================
+
+This sample implements a simple calculator using SCA components.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive) Take a look there for instructions on how to launch
+this sample contribution.
+
+Sample Overview
+---------------
+The sample provides a single calculator service with a default SCA (java)
+binding. The CalculatorClient exercises this interface by calling add,
+subtract, multiply and divide operations. This results in messages passing to
+the appropriate components in the composite across the local wires.
+
+You should see the following output from the run target.
+
+run:
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/build.xml b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/build.xml
new file mode 100644
index 0000000000..8ec250d009
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/build.xml
@@ -0,0 +1,56 @@
+<!--
+ * 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 name="implementation-java-calculator" default="compile">
+
+ <property name="tuscany.home" value="../../.."/>
+ <property name="jar.name" value="contribution-implementation-java-calculator.jar" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-sca-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+</project>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/pom.xml b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/pom.xml
new file mode 100644
index 0000000000..c3e4ba4208
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/pom.xml
@@ -0,0 +1,58 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-implementation-java-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution Implementation Java Calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/AddService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..5a1e7a638a
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/AddService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The Add service interface
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/AddServiceImpl.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..caf4d358df
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/AddServiceImpl.java
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorClient.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..2b791a8e1f
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorClient.java
@@ -0,0 +1,62 @@
+/*
+ * 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 calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE") @EagerInit
+public class CalculatorClient {
+
+ private CalculatorService calculatorService;
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+ @Init
+ public void calculate() {
+
+ // Calculate
+ System.out.println("SCA API ClassLoader: " + print(Reference.class.getClassLoader()));
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+ }
+
+ private static String print(ClassLoader cl) {
+ StringBuffer buf = new StringBuffer();
+ for (; cl != null;) {
+ buf.append(cl.toString());
+ buf.append(' ');
+ cl = cl.getParent();
+ }
+ return buf.toString();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..78eea39c71
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,37 @@
+/*
+ * 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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..d3fa7a8f41
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,70 @@
+/*
+ * 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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/DivideService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..ef6a8b375b
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/DivideService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..cd91935f08
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/DivideServiceImpl.java
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..db568cc762
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..c85357fcd8
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/MultiplyServiceImpl.java
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/SubtractService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..56ee372fc4
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/SubtractService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..1b669084d9
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/java/calculator/SubtractServiceImpl.java
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/Calculator.composite b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..370e1cf315
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/Calculator.composite
@@ -0,0 +1,49 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/CalculatorClient.composite b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/CalculatorClient.composite
new file mode 100644
index 0000000000..dfd32761be
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/CalculatorClient.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="CalculatorClient">
+
+ <component name="CalculatorClient">
+ <implementation.java class="calculator.CalculatorClient"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..70aab0e051
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+ <deployable composite="sample:CalculatorClient"/>
+</contribution> \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..c1cd131f40
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/contribution-calculator/src/test/java/calculator/CalculatorTestCase.java
@@ -0,0 +1,49 @@
+/*
+ * 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 calculator;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator composition.
+ */
+public class CalculatorTestCase {
+
+ @Test
+ public void testCalculator() throws Exception {
+ AddService add = new AddServiceImpl();
+ SubtractService subtract = new SubtractServiceImpl();
+ MultiplyService multiply = new MultiplyServiceImpl();
+ DivideService divide = new DivideServiceImpl();
+
+ CalculatorServiceImpl calculator = new CalculatorServiceImpl();
+
+ calculator.setAddService(add);
+ calculator.setSubtractService(subtract);
+ calculator.setMultiplyService(multiply);
+ calculator.setDivideService(divide);
+
+ assertEquals(calculator.add(3, 2), 5.0, 0);
+ assertEquals(calculator.subtract(3, 2), 1.0, 0);
+ assertEquals(calculator.multiply(3, 2), 6.0, 0);
+ assertEquals(calculator.divide(3, 2), 1.5, 0);
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-java/pom.xml b/sca-java-2.x/trunk/samples/sca-features/implementation-java/pom.xml
new file mode 100644
index 0000000000..96fece7481
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-java/pom.xml
@@ -0,0 +1,43 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-implementation-java</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample implementation.java</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>contribution-calculator</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/README b/sca-java-2.x/trunk/samples/sca-features/implementation-script/README
new file mode 100644
index 0000000000..18ba62d494
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/README
@@ -0,0 +1 @@
+Please look at the README files in the subdirectories of this directory for descriptions of the sample contributions.
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/README b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/README
new file mode 100644
index 0000000000..1e5bc9c584
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/README
@@ -0,0 +1,26 @@
+Calculator Sample Contribution
+==============================
+
+This sample contribution implements a simple calculator using SCA components.
+
+The README in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running samples. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive) Take a look there for instructions on how to launch
+this sample contribution.
+
+Sample Overview
+---------------
+The sample provides a single calculator service with a default SCA (java)
+binding. The CalculatorClient exercises this interface by calling add,
+subtract, multiply and divide operations. This results in messages passing to
+the appropriate components in the composite across the local wires.
+
+Amongst the other output created by the launcher/contribution combination, you should see the following output ...
+
+run:
+ [java] 3 + 2=5.0
+ [java] 3 - 2=1.0
+ [java] 3 * 2=6.0
+ [java] 3 / 2=1.5
+
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/build.xml b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/build.xml
new file mode 100644
index 0000000000..91285fdbca
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/build.xml
@@ -0,0 +1,57 @@
+<!--
+ * 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 name="calculator" default="compile">
+ <property name="tuscany.home" value="../../.."/>
+ <property name="jar.name" value="sample-contribution-implementation-script-calculator.jar" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-sca-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+</project>
+
+
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/pom.xml b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/pom.xml
new file mode 100644
index 0000000000..61c864a4f0
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/pom.xml
@@ -0,0 +1,58 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-contribution-implementation-script-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Contribution implementation-script Calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/AddService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..5a1e7a638a
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/AddService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The Add service interface
+ */
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorClient.java b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..1df1f31c48
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorClient.java
@@ -0,0 +1,52 @@
+/*
+ * 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 calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public class CalculatorClient {
+
+ private CalculatorService calculatorService;
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+ @Init
+ public void calculate() {
+ // Calculate
+ System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader());
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..78eea39c71
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,37 @@
+/*
+ * 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 calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..8e4b082d14
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,72 @@
+/*
+ * 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 calculator;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Service(CalculatorService.class)
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/DivideService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..ef6a8b375b
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/DivideService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/MultiplyService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..db568cc762
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/MultiplyService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/SubtractService.java b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..56ee372fc4
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/java/calculator/SubtractService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/Calculator.composite b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..d441aa0aea
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/Calculator.composite
@@ -0,0 +1,50 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <tuscany:implementation.script script="calculator/AddServiceImpl.js"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <tuscany:implementation.script script="calculator/SubtractServiceImpl.rb"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <tuscany:implementation.script script="calculator/MultiplyServiceImpl.py"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <tuscany:implementation.script script="calculator/DivideServiceImpl.groovy"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/CalculatorClient.composite b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/CalculatorClient.composite
new file mode 100644
index 0000000000..dfd32761be
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/CalculatorClient.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="CalculatorClient">
+
+ <component name="CalculatorClient">
+ <implementation.java class="calculator.CalculatorClient"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..70aab0e051
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+ <deployable composite="sample:CalculatorClient"/>
+</contribution> \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.componentType b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.componentType
new file mode 100644
index 0000000000..5f6d88454c
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.componentType
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="AddService">
+ <interface.java interface="calculator.AddService" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.js b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.js
new file mode 100644
index 0000000000..6f11106ddd
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/AddServiceImpl.js
@@ -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 add(n1, n2) {
+ return n1 + n2;
+} \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.componentType b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.componentType
new file mode 100644
index 0000000000..f4bb4e3471
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.componentType
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="DivideService">
+ <interface.java interface="calculator.DivideService" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.groovy b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.groovy
new file mode 100644
index 0000000000..c31c1e8fd6
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/DivideServiceImpl.groovy
@@ -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.
+ */
+
+def divide(n1, n2) {
+ return n1 / n2
+} \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.componentType b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.componentType
new file mode 100644
index 0000000000..35dc5721b2
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.componentType
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="MultiplyService">
+ <interface.java interface="calculator.MultiplyService" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.py b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.py
new file mode 100644
index 0000000000..cce0b5b3ec
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/MultiplyServiceImpl.py
@@ -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 multiply(n1, n2):
+ return n1 * n2 \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.componentType b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.componentType
new file mode 100644
index 0000000000..ee768f73f2
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.componentType
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="SubtractService">
+ <interface.java interface="calculator.SubtractService" />
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.rb b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.rb
new file mode 100644
index 0000000000..132a1d13b0
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/contribution-calculator/src/main/resources/calculator/SubtractServiceImpl.rb
@@ -0,0 +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.
+#
+
+def subtract(n1, n2)
+ return n1 - n2
+end \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/sca-features/implementation-script/pom.xml b/sca-java-2.x/trunk/samples/sca-features/implementation-script/pom.xml
new file mode 100644
index 0000000000..cf719a7918
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/sca-features/implementation-script/pom.xml
@@ -0,0 +1,43 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-sample-implementation-script</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Sample implementation.script</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>contribution-calculator</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>