diff options
Diffstat (limited to 'sca-java-2.x/branches/2.0-Beta3/unreleased')
111 files changed, 6486 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/distribution/osgi/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/distribution/osgi/pom.xml new file mode 100644 index 0000000000..0b0f619eac --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/distribution/osgi/pom.xml @@ -0,0 +1,428 @@ +<?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-distribution</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>tuscany-distribution-osgi</artifactId>
+ <name>Apache Tuscany SCA OSGI Distribution</name>
+<!--
+ <packaging>pom</packaging>
+-->
+
+ <repositories>
+ <repository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </repository>
+ <repository>
+ <id>intalio.org</id>
+ <url>http://www.intalio.org/public/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>openejb-repository</id>
+ <name>OpenEJB Repository</name>
+ <url>http://svn.apache.org/repos/asf/openejb/repo</url>
+ <layout>default</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+ <dependencies>
+
+ <!-- module jars for modules directory -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-all</artifactId>
+ <type>pom</type>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </dependency>
+
+ <!-- needed for the unit test which produces the feature repository.xml files -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.api</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.management</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.modeller</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.resolver.obr</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Pax Exam test runtime -->
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>1.2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <version>1.2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <version>1.2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-api</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-service</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-mvn</artifactId>
+ <version>1.2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- extra bundles that will be loaded -->
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.bundlerepository</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.proxy</groupId>
+ <artifactId>org.apache.aries.proxy</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.runtime</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.default.local.platform</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.runtime.itest.interfaces</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-all</artifactId>
+ <version>3.3.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.2.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.2.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.0.7</version>
+ <executions>
+ <!-- generate the which-jars files -->
+ <execution>
+ <id>extensions-build</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>generate-meta-data</goal>
+ </goals>
+ <configuration>
+ <generateModules>false</generateModules>
+ <useDistributionName>false</useDistributionName>
+ <generateManifestJar>true</generateManifestJar>
+ <generateConfig>false</generateConfig>
+ <generateAntScript>true</generateAntScript>
+ <generateTargetPlatform>false</generateTargetPlatform>
+ <generateAggregatedBundle>false</generateAggregatedBundle>
+ <featuresName>features</featuresName>
+ <features>
+ <feature>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime-pom</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </feature>
+ </features>
+ <extensions>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-atom-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-commet-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-corba-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ejb-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-hazelcase-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rest-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rss-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-jaxes-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-python-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-widget-runtime</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+
+ <extension>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </extension>
+ </extensions>
+ <artifactManifests>
+ <!--
+ <artifactManifest>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.10</version>
+ <manifestFile>${basedir}/manifests/axiom-api-1.2.10.MF</manifestFile>
+ </artifactManifest>
+ -->
+ <artifactManifest>
+ <groupId>org.apache.woden</groupId>
+ <artifactId>woden-impl-dom</artifactId>
+ <version>1.0M8</version>
+ <manifestFile>${basedir}/manifests/woden-impl-dom-1.0M8.MF</manifestFile>
+ </artifactManifest>
+ <artifactManifest>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>1.5.3</version>
+ <manifestFile>${basedir}/manifests/axis2-kernel-1.5.3.MF</manifestFile>
+ </artifactManifest>
+ <artifactManifest>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-transport-http</artifactId>
+ <version>1.5.3</version>
+ <manifestFile>${basedir}/manifests/axis2-transport-http-1.5.3.MF</manifestFile>
+ </artifactManifest>
+ <artifactManifest>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>*</artifactId>
+ <version>*</version>
+ </artifactManifest>
+ </artifactManifests>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.3.0-v20070530</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>generate-depends-file</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ <configuration>
+ <outputFile>${project.build.directory}/test-classes/META-INF/maven/dependencies.properties</outputFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/distribution/osgi/src/test/java/sample/GenerateFeatureReposTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/distribution/osgi/src/test/java/sample/GenerateFeatureReposTestCase.java new file mode 100644 index 0000000000..a5c852b7f5 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/distribution/osgi/src/test/java/sample/GenerateFeatureReposTestCase.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 org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+
+@RunWith( JUnit4TestRunner.class )
+public class GenerateFeatureReposTestCase extends TestBaseClass{
+
+ @Test
+ public void generateBaseRepositoryXML() {
+ generateRepositoryXML("tuscany-base-runtime-pom");
+ generateRepositoryXML("tuscany-binding-ws-runtime-axis2");
+ }
+}
+
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/distribution/osgi/src/test/java/sample/TestBaseClass.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/distribution/osgi/src/test/java/sample/TestBaseClass.java new file mode 100644 index 0000000000..e1a684c50d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/distribution/osgi/src/test/java/sample/TestBaseClass.java @@ -0,0 +1,205 @@ +/*
+ * 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 org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
+
+import org.apache.aries.application.filesystem.IDirectory;
+import org.apache.aries.application.management.spi.repository.RepositoryGenerator;
+import org.apache.aries.application.modelling.ModelledResourceManager;
+import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.container.def.options.WorkingDirectoryOption;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.util.tracker.ServiceTracker;
+
+/* For debugging, uncomment the next two lines and add these imports:
+ */
+import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+
+
+/**
+ * Note that much of the technical detail/instruction comes from...
+ *
+ * http://svn.apache.org/repos/asf/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java
+ *
+ */
+
+//@RunWith( JUnit4TestRunner.class )
+public class TestBaseClass {
+
+ public static final long DEFAULT_TIMEOUT = 30000;
+
+ @Inject
+ protected BundleContext bundleContext;
+
+ @Configuration
+ public static Option[] configuration() {
+ Option[] options = options(
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+ mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+ mavenBundle("asm", "asm-all"),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
+
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform"),
+ mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
+ mavenBundle("org.osgi", "org.osgi.compendium"),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+
+ mavenBundle("org.apache.tuscany.sca", "tuscany-sca-api"),
+
+ //mavenBundle("org.apache.tuscany.sca", "bundle"),
+
+ /* For debugging, uncomment the next two lines
+ vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"),
+ waitForFrameworkStartup(),
+ */
+
+ workingDirectory("D://sca-java-2.x//unreleased//distribution//osgi//target"),
+
+ equinox().version("3.5.0"));
+
+ return options;
+ }
+
+ public void generateRepositoryXML(String featureName) {
+ System.out.println("generateRepositoryXML - start");
+ System.out.println("test dir = " + System.getProperty("user.dir"));
+ System.out.println("current dir = " + this.getClass().getProtectionDomain().getCodeSource().getLocation());
+
+ // get the OBR repository admin service
+ RepositoryAdmin respositoryAdminService = getOsgiService(RepositoryAdmin.class);
+
+ // get the repository generator service
+ System.out.println("get RepositoryGenerator service =");
+ RepositoryGenerator repositoryGenerator = getOsgiService(RepositoryGenerator.class);
+ System.out.println(repositoryGenerator);
+
+ System.out.println("get ModelledResourceManager service =");
+ ModelledResourceManager modelledResourceManager = getOsgiService(ModelledResourceManager.class);
+ System.out.println(modelledResourceManager);
+
+ Set<ModelledResource> mrs = new HashSet<ModelledResource>();
+
+ try {
+ // create mrs based on base runtime
+ // directories relative to working directory
+ populateMRS(modelledResourceManager,
+ mrs,
+ "../../../../distribution/all/target/features/" + featureName + "/which-jars",
+ "../../../../distribution/all/target/modules");
+ FileOutputStream fout = new FileOutputStream("./features/" +featureName + "/repository.xml");
+ repositoryGenerator.generateRepository(featureName + " repository", mrs, fout);
+ fout.close();
+
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ }
+
+ System.out.println("generateRepositoryXML - end");
+ }
+
+ public void populateMRS(ModelledResourceManager modelledResourceManager,
+ Set<ModelledResource> mrs,
+ String whichJars,
+ String modules){
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(whichJars));
+ String line;
+ while ((line = in.readLine()) != null) {
+ if (line.endsWith(".jar")){
+ int dirSeparatorIndex = line.indexOf("/");
+ if (dirSeparatorIndex > 0){
+ line = line.substring(0, dirSeparatorIndex);
+ }
+ System.out.println("Processing - " + line);
+ File bundleFile = new File(modules + "\\" + line);
+ IDirectory jarDir = FileSystem.getFSRoot(bundleFile);
+ mrs.add(modelledResourceManager.getModelledResource(bundleFile.toURI().toString(), jarDir));
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public <T> T getOsgiService(Class<T> type) {
+ try {
+ String filterString = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
+ Filter osgiFilter = FrameworkUtil.createFilter(filterString);
+ ServiceTracker tracker = new ServiceTracker(bundleContext, osgiFilter, null);
+ tracker.open();
+ Object tmp = tracker.waitForService(DEFAULT_TIMEOUT);
+ return type.cast(tmp);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId) {
+ return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId).versionAsInProject();
+ }
+}
+
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/README new file mode 100644 index 0000000000..15736845da --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/README @@ -0,0 +1,154 @@ +The Apache Tuscany SCA Samples +============================== + +Welcome to the Apache Tuscany SCA Java runtime. You can find more general +documentation about the runtime at: + +http://tuscany.apache.org/documentation-2x/ + +Here we give a short overview of what you can find in the samples directory. +More detail on the individual sample contributions can be found at: + +http://tuscany.apache.org/documentation-2x/20-beta-samples-documentation.html + +There are several samples subdirectories in the distribution; + +getting-started +=============== + +This is a good place to start if you've not tried Tuscany SCA Java before. This +directory contains a number of simple "SCA Contributions" that can be run using +the Tuscany SCA runtime. An SCA Contribution is the way that SCA composite +applications are packaged so they can be run. For general information on SCA +see http://tuscany.apache.org/documentation-2x/sca-introduction.html + +learning-more +============= + +This directory contains many more SCA Contributions that you can try with +the Tuscany SCA Java runtime. Some demonstrate particular features of the +runtime, or example, the contributions under the async directory demonstrate +the asynchronous programming model that the runtime supports. + +SCA is extensible. You can plug in extensions to support many different types +of technology. The Tuscany SCA Java runtime comes with lots of extensions +and the majority of contributions here demonstrate these extensions. They are +organized under directories following the name of the extension, for example, +contributions that demonstrate the web services binding in operation can +be found in the binding-ws directory. When you want to use the web service +binding with an SCA service a reference it appears in the composite XML in +the following way: + +<service> + <binding.ws/> +</service> + +Hence it should be easy to map between extensions, as they appear in +composite files and other samples that demonstrate various features of the +extension. + +The contributions here can be run with using the approach that you find +most convenient from the running-tuscany directory. + +running-tuscany +=============== + +The Tuscany SCA Java runtime can be used directly from the command line. It can +also be embedded in other programs. As such there are many different ways that +you can start the Tuscany SCA runtime and deploy contributions to it. Each +directory here describes a different way of running Tuscany. In most cases these +different approaches can be used to run any of the contributions from the +getting-started or learning-more directories. + +applications +============ + +The contributions here demonstrate more fully formed applications when +compared to the contributions found the getting-started or learning-more +directories. + +extending-tuscany +================= + +Once you're familiar with Tuscany and SCA you're likely to find that to +implement you're application you need particular bindings, implementation +types, policies or databindings. The examples in this directory show you +how to extend the Tuscany runtime to include the technologies you need to use. + +Running samples +--------------- + +Running a samples contribution involves 3 basic steps + +1) build the contribution + +Using ant, maven or eclipse (see below) + +2) launch the contribution + +Using one of the approaches described in the running-tuscany directory + +3) send a test message to the a component service + +When you want to exercise an SCA composite application you have to send a +message to a component service. There are several ways of doing this depending +on how the sample contribution has been configured. For example, you could +send a SOAP message using the Web Services explorer in Eclipse, you could +use a separate client program that uses the SCA client API, the sample +contribution itself may even include initialization code that sends a test +message when the contribution is started. The documentation for each sample +describes what to do to send a test message. + +Building the sample contributions using Ant +-------------------------------------------- +Most sample contributions are provided with a build.xml file. When you see one +you can build it using Ant. + +These build.xml files are designed to work with the Tuscany SCA Java binary +distribution and build a classpath that, by various means, refers to the +jars that are shipped in the modules directory. For them to work properly +they should be run from the directory in which you find the build.xml file. + +cd <sampledir> +ant + +The result of this process will be the built contribution (a jar file) in the +target subdirectory of the sample contribution directory. + +Once the sample is built you have the option of running the sample in whatever +way best suits you. + +Building SCA Samples Using Maven +-------------------------------- +All sample contributions are provided with a pom.xml Maven build file. The +Maven build process will work from both source and binary distributions. + +cd <sampledir> +mvn + +This will take a little while to complete. Experience with Maven tells us that +sometimes there are problems downloading the dependencies that Apache Tuscany +SCA requires. If Maven reports that it cannot download required dependencies +try running the Maven build again. + +When using Maven the samples are unit tested using JUnit test cases and so you +will sometimes see test output during the build process. + +The result of this process will be the built contribution (a jar file) in the +target subdirectory of the sample contribution directory. + +Once the sample is built you have the option of running the sample in whatever +way best suits you. + +Building Samples In An IDE +--------------------------- + +The easiest way to use the samples in an IDE is to use Maven to generate all +of the IDE project files for you automatically. You don't have to do this +though and can use a series of manual steps in order to import the Tuscany +samples into an IDE. + +Both approaches to importing SCA contribution projects into Eclipse are +documented at: + +http://tuscany.apache.org/import-existing-tuscany-sca-projects-into-eclipse.html diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/pom.xml new file mode 100644 index 0000000000..cec83d0b39 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/pom.xml @@ -0,0 +1,36 @@ +<?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-Beta3-SNAPSHOT</version> + </parent> + + <artifactId>tuscany-samples-applications</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <packaging>pom</packaging> + <name>Apache Tuscany Sample Applications</name> + + <modules> + <module>store</module> + </modules> +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/README new file mode 100644 index 0000000000..d31e4c59b7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/README @@ -0,0 +1,28 @@ +Store Sample +====================================== + +This is a sample store scenario that is used as a getting started guide +for Tuscany SCA. For detailed information, please see: + +http://tuscany.apache.org/getting-started-with-tuscany.html + +or + +http://tuscany.apache.org/getting-started-with-tuscany-using-tuscany-eclipse-plugin.html + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as follows: + +cd store +ant compile + +and then, to run: + +ant run + +Once the store application is running use your browser to visit the following +URL: + +http://localhost:8080/store diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/build.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/build.xml new file mode 100644 index 0000000000..e28e7c87be --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/build.xml @@ -0,0 +1,82 @@ +<!-- + * 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="store" default="compile"> + <property name="tuscany.home" value="../../.."/> + <property name="test.class" value="launch.Launch" /> + <property name="test.jar" value="sample-store.jar" /> + + <import file="${tuscany.home}/features/tuscany-base-runtime-pom/build-path.xml"/> + + <target name="init"> + <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"> + <classpath> + <fileset dir="${tuscany.home}/lib"> + <include name="tuscany-base-*.jar"/> + </fileset> + </classpath> + </javac> + <copy todir="target/classes"> + <fileset dir="src/main/resources"/> + </copy> + <jar destfile="target/${test.jar}" basedir="target/classes"> + <manifest> + <attribute name="Main-Class" value="${test.class}" /> + </manifest> + </jar> + </target> + + <target name="run-classes"> + <java classname="${test.class}" + fork="true"> + <classpath> + <pathelement path="target/classes"/> + <fileset dir="${tuscany.home}/features"> + <include name="tuscany-sca-manifest.jar"/> + </fileset> + </classpath> + </java> + </target> + + <target name="run"> + <java classname="${test.class}" + fork="true"> + <classpath> + <pathelement path="target/${test.jar}"/> + <fileset dir="${tuscany.home}/features"> + <include name="tuscany-sca-manifest.jar"/> + </fileset> + </classpath> + </java> + </target> + + <target name="clean"> + <delete quiet="true" includeemptydirs="true"> + <fileset dir="target"/> + </delete> + </target> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/pom.xml new file mode 100644 index 0000000000..f6b3799d61 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/pom.xml @@ -0,0 +1,114 @@ +<?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-Beta3-SNAPSHOT</version> + </parent> + <artifactId>sample-store</artifactId> + <name>Apache Tuscany SCA Sample Getting Started Online Store</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime-pom</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <type>pom</type> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-data-api</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-atom-runtime</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-http-runtime</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-jsonrpc-runtime</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-widget-runtime</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-widget-runtime-dojo</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-web-javascript-dojo</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty</artifactId> + <version>6.1.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>net.sourceforge.htmlunit</groupId> + <artifactId>htmlunit</artifactId> + <version>2.6</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <finalName>${project.artifactId}</finalName> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.1.1</version> + <executions> + <execution> + <goals> + <goal>java</goal> + </goals> + </execution> + </executions> + <configuration> + <classpathScope>test</classpathScope> + <mainClass>store.StoreTestCase</mainClass> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/launch/Launch.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/launch/Launch.java new file mode 100644 index 0000000000..8e4b5839e4 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/launch/Launch.java @@ -0,0 +1,39 @@ +/* + * 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 launch; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +public class Launch { + public static void main(String[] args) throws Exception { + System.out.println("Starting ..."); + String contribution = ContributionLocationHelper.getContributionLocation(Launch.class); + Node node = NodeFactory.newInstance().createNode("store.composite", new Contribution("test", contribution)); + node.start(); + System.out.println("store.composite ready for big business !!!"); + System.in.read(); + System.out.println("Stopping ..."); + node.stop(); + System.out.println(); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Cart.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Cart.java new file mode 100644 index 0000000000..3fb5439bc3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Cart.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 services; + +import org.apache.tuscany.sca.data.collection.Collection; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Cart extends Collection<String, Item> { + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Catalog.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Catalog.java new file mode 100644 index 0000000000..b5e504fe11 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Catalog.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Catalog { + Item[] get(); +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/CurrencyConverter.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/CurrencyConverter.java new file mode 100644 index 0000000000..a064f3dd69 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/CurrencyConverter.java @@ -0,0 +1,29 @@ +/* + * 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 services; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface CurrencyConverter { + public double getConversion(String fromCurrenycCode, String toCurrencyCode, double amount); + + public String getCurrencySymbol(String currencyCode); +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/CurrencyConverterImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/CurrencyConverterImpl.java new file mode 100644 index 0000000000..c354aed447 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/CurrencyConverterImpl.java @@ -0,0 +1,38 @@ +/* + * 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 services; + +public class CurrencyConverterImpl implements CurrencyConverter { + public double getConversion(String fromCurrencyCode, String toCurrencyCode, double amount) { + if (toCurrencyCode.equals("USD")) + return amount; + else if (toCurrencyCode.equals("EUR")) + return ((double)Math.round(amount * 0.7256 * 100)) /100; + return 0; + } + + public String getCurrencySymbol(String currencyCode) { + if (currencyCode.equals("USD")) + return "$"; + else if (currencyCode.equals("EUR")) + return "E"; //"€"; + return "?"; + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/FruitsCatalogImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/FruitsCatalogImpl.java new file mode 100644 index 0000000000..d132a24b00 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/FruitsCatalogImpl.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 services; + +import java.util.ArrayList; +import java.util.List; + +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; + +public class FruitsCatalogImpl implements Catalog { + + @Property + public String currencyCode = "USD"; + + @Reference + public CurrencyConverter currencyConverter; + + private List<Item> catalog = new ArrayList<Item>(); + + @Init + public void init() { + String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode); + catalog.add(new Item("Apple", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99))); + catalog.add(new Item("Orange", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55))); + catalog.add(new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55))); + } + + public Item[] get() { + Item[] catalogArray = new Item[catalog.size()]; + catalog.toArray(catalogArray); + return catalogArray; + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Item.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Item.java new file mode 100644 index 0000000000..0a9dcb2ffc --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Item.java @@ -0,0 +1,54 @@ +/* + * 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 services; + +public class Item { + private String name; + private String price; + + public Item() { + } + + public Item(String name, String price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + + public String toString() { + return "Item name: " + name + ", price: " + price; + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/ShoppingCartImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/ShoppingCartImpl.java new file mode 100644 index 0000000000..698614212d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/ShoppingCartImpl.java @@ -0,0 +1,112 @@ +/* + * 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 services; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Scope; + +@Scope("COMPOSITE") +public class ShoppingCartImpl implements Cart, Total { + + private Map<String, Item> cart; + + @Init + public void init() { + cart = new HashMap<String, Item>(); + } + + public Entry<String, Item>[] getAll() { + Entry<String, Item>[] entries = new Entry[cart.size()]; + int i = 0; + for (Map.Entry<String, Item> e: cart.entrySet()) { + entries[i++] = new Entry<String, Item>(e.getKey(), e.getValue()); + } + return entries; + } + + public Item get(String key) throws NotFoundException { + Item item = cart.get(key); + if (item == null) { + throw new NotFoundException(key); + } else { + return item; + } + } + + public String post(String key, Item item) { + if (key == null) { + key ="cart-" + UUID.randomUUID().toString(); + } + cart.put(key, item); + return key; + } + + public void put(String key, Item item) throws NotFoundException { + if (!cart.containsKey(key)) { + throw new NotFoundException(key); + } + cart.put(key, item); + } + + public void delete(String key) throws NotFoundException { + if (key == null || key.equals("")) { + cart.clear(); + } else { + Item item = cart.remove(key); + if (item == null) + throw new NotFoundException(key); + } + } + + public Entry<String, Item>[] query(String queryString) { + List<Entry<String, Item>> entries = new ArrayList<Entry<String,Item>>(); + if (queryString.startsWith("name=")) { + String name = queryString.substring(5); + for (Map.Entry<String, Item> e: cart.entrySet()) { + Item item = e.getValue(); + if (item.getName().equals(name)) { + entries.add(new Entry<String, Item>(e.getKey(), e.getValue())); + } + } + } + return entries.toArray(new Entry[entries.size()]); + } + + public String getTotal() { + double total = 0; + String currencySymbol = ""; + if (!cart.isEmpty()) { + Item item = cart.values().iterator().next(); + currencySymbol = item.getPrice().substring(0, 1); + } + for (Item item : cart.values()) { + total += Double.valueOf(item.getPrice().substring(1)); + } + return currencySymbol + String.valueOf(total); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Total.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Total.java new file mode 100644 index 0000000000..b77cc1c7ac --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/java/services/Total.java @@ -0,0 +1,29 @@ +/* + * 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 services; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Total { + + String getTotal(); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/resources/store.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/resources/store.composite new file mode 100644 index 0000000000..9c3b79c508 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/resources/store.composite @@ -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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://store" + name="store"> + + <component name="Store"> + <tuscany:implementation.widget location="uiservices/store.html"/> + <service name="Widget"> + <tuscany:binding.http uri="/store"/> + </service> + <reference name="catalog" target="Catalog"/> + <reference name="shoppingCart" target="ShoppingCart/Cart"/> + <reference name="shoppingTotal" target="ShoppingCart/Total"/> + </component> + + <component name="Catalog"> + <implementation.java class="services.FruitsCatalogImpl"/> + <property name="currencyCode">USD</property> + <service name="Catalog"> + <tuscany:binding.jsonrpc uri="/Catalog"/> + </service> + <reference name="currencyConverter" target="CurrencyConverter"/> + </component> + + <component name="ShoppingCart"> + <implementation.java class="services.ShoppingCartImpl"/> + <service name="Cart"> + <tuscany:binding.atom uri="/ShoppingCart/Cart"/> + </service> + <service name="Total"> + <tuscany:binding.jsonrpc uri="/ShoppingCart/Total"/> + </service> + </component> + + <component name="CurrencyConverter"> + <implementation.java class="services.CurrencyConverterImpl"/> + </component> + +</composite> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/resources/uiservices/store.html b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/resources/uiservices/store.html new file mode 100644 index 0000000000..be3efea327 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/main/resources/uiservices/store.html @@ -0,0 +1,162 @@ +<!-- + * 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. +--> +<html> +<head> +<title>Store</title> + +<script type="text/javascript" src="../dojo/dojo.js"></script> +<script type="text/javascript" src="store.js"></script> + +<script language="JavaScript"> + + //@Reference + var catalog = new tuscany.sca.Reference("catalog"); + + //@Reference + var shoppingCart = new tuscany.sca.Reference("shoppingCart"); + + //@Reference + var shoppingTotal = new tuscany.sca.Reference("shoppingTotal"); + + var catalogItems; + + function catalog_getResponse(items,exception) { + if(exception){ + alert(exception.message); + return; + } + var catalog = ""; + + for (var i=0; i<items.length; i++) { + var item = items[i].name + ' - ' + items[i].price; + catalog += '<input name="items" type="checkbox" value="' + + item + '">' + item + ' <br>'; + } + document.getElementById('catalog').innerHTML=catalog; + catalogItems = items; + } + + function shoppingCart_getResponse(feed) { + if (feed != null) { + var entries = feed.getElementsByTagName("entry"); + var list = ""; + for (var i=0; i<entries.length; i++) { + var content = entries[i].getElementsByTagName("content")[0]; + var name = content.getElementsByTagName("name")[0].firstChild.nodeValue; + var price = content.getElementsByTagName("price")[0].firstChild.nodeValue; + list += name + ' - ' + price + ' <br>'; + } + document.getElementById("shoppingCart").innerHTML = list; + + if (entries.length != 0) { + try { + shoppingTotal.getTotal().addCallback(shoppingTotal_getTotalResponse); + } + catch(e){ + alert(e); + } + } + } + } + + function shoppingTotal_getTotalResponse(total,exception) { + if(exception) { + alert(exception.message); + return; + } + document.getElementById('total').innerHTML = total; + } + + function shoppingCart_postResponse(entry) { + shoppingCart.get("").addCallback(shoppingCart_getResponse); + } + + function addToCart() { + var items = document.catalogForm.items; + var j = 0; + for (var i=0; i<items.length; i++) { + if (items[i].checked) { + var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title>item</title><content type="text/xml">' + + '<Item xmlns="http://services/">' + + '<name xmlns="">' + catalogItems[i].name + '</name>' + '<price xmlns="">' + catalogItems[i].price + '</price>' + + '</Item>' + '</content></entry>'; + shoppingCart.post(entry).addCallback(shoppingCart_postResponse); + items[i].checked = false; + } + } + } + function checkoutCart() { + document.getElementById('store').innerHTML='<h2>' + + 'Thanks for Shopping With Us!</h2>'+ + '<h2>Your Order</h2>'+ + '<form name="orderForm">'+ + document.getElementById('shoppingCart').innerHTML+ + '<br>'+ + document.getElementById('total').innerHTML+ + '<br>'+ + '<br>'+ + '<input type="submit" value="Continue Shopping">'+ + '</form>'; + shoppingCart.del(""); + } + function deleteCart() { + shoppingCart.del(""); + document.getElementById('shoppingCart').innerHTML = ""; + document.getElementById('total').innerHTML = ""; + } + + function init() { + try { + catalog.get().addCallback(catalog_getResponse); + shoppingCart.get("").addCallback(shoppingCart_getResponse); + } + catch(e){ + alert(e); + } + } + +</script> + +</head> + +<body onload="init()"> +<h1>Store</h1> + <div id="store"> + <h2>Catalog</h2> + <form name="catalogForm"> + <div id="catalog" ></div> + <br> + <input type="button" onClick="addToCart()" value="Add to Cart"> + </form> + + <br> + + <h2>Your Shopping Cart</h2> + <form name="shoppingCartForm"> + <div id="shoppingCart"></div> + <br> + <div id="total"></div> + <br> + <input type="button" onClick="checkoutCart()" value="Checkout"> + <input type="button" onClick="deleteCart()" value="Empty"> + <a href="../ShoppingCart/Cart/">(feed)</a> + </form> + </div> +</body> +</html> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/java/client/Shopper.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/java/client/Shopper.java new file mode 100644 index 0000000000..4e2fa63493 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/java/client/Shopper.java @@ -0,0 +1,29 @@ +/* + * 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 client; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Shopper { + + String shop(String itemName, int quantity); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/java/client/ShopperImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/java/client/ShopperImpl.java new file mode 100644 index 0000000000..05b1800d4f --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/java/client/ShopperImpl.java @@ -0,0 +1,64 @@ +/* + * 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 client; + +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.oasisopen.sca.annotation.Reference; + +import services.Cart; +import services.Catalog; +import services.Item; +import services.Total; + +public class ShopperImpl implements Shopper { + + @Reference + public Catalog catalog; + + @Reference + public Cart shoppingCart; + + @Reference + public Total shoppingTotal; + + public String shop(String itemName, int quantity) { + + Item[] items = catalog.get(); + for (Item item: items) { + if (item.getName().startsWith(itemName)) { + + try { + shoppingCart.delete(""); + } catch (NotFoundException e) { + // ignore + } + + for (int i = 0; i < quantity; i++) { + shoppingCart.post("item" + i, item); + } + + return shoppingTotal.getTotal(); + } + } + + return ""; + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/java/store/StoreTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/java/store/StoreTestCase.java new file mode 100644 index 0000000000..7fa866d1c6 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/java/store/StoreTestCase.java @@ -0,0 +1,121 @@ +/* + * 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 store; + +import java.io.IOException; +import java.net.MalformedURLException; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +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.Ignore; +import org.junit.Test; + +import client.Shopper; + +import com.gargoylesoftware.htmlunit.BrowserVersion; +import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; +import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController; +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput; +import com.gargoylesoftware.htmlunit.html.HtmlForm; +import com.gargoylesoftware.htmlunit.html.HtmlPage; + + +/** + * Test the store-merger. + * + * @version $Rev$ $Date$ + */ +public class StoreTestCase { + private static Node nodeStore; + + public static void main(String[] args) throws Exception { + setUp(); + testWaitForInput(); + tearDown(); + } + + @BeforeClass + public static void setUp() throws Exception { + String storeLocation = ContributionLocationHelper.getContributionLocation("store.composite"); + String storeClientLocation = ContributionLocationHelper.getContributionLocation("store-client.composite"); + + nodeStore = NodeFactory.newInstance().createNode(new Contribution("store", storeLocation), new Contribution("storeClient", storeClientLocation)); + nodeStore.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + nodeStore.stop(); + } + + public static void testWaitForInput() { + try { + System.out.println("press enter to continue)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void testShop() { + Shopper shopper = nodeStore.getService(Shopper.class, "StoreClient"); + + String total = shopper.shop("Orange", 5); + System.out.println("Total: " + total); + + Assert.assertEquals("$17.75", total); + + } + + @Test + public void testStoreWidget() throws FailingHttpStatusCodeException, MalformedURLException, IOException { + WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3); + webClient.setRedirectEnabled(true); + webClient.setThrowExceptionOnScriptError(false); + //webClient.waitForBackgroundJavaScript(100000); + //webClient.waitForBackgroundJavaScriptStartingBefore(100000); + webClient.setAjaxController(new NicelyResynchronizingAjaxController()); + + HtmlPage page = (HtmlPage) webClient.getPage("http://localhost:8080/store/store.html"); + + HtmlForm form = (HtmlForm) page.getFormByName("catalogForm"); + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + + HtmlCheckBoxInput catalogItems = (HtmlCheckBoxInput) form.getInputByName("items"); + + System.out.println(">>>" + catalogItems.getAttribute("value")); + Assert.assertEquals("Apple - $2.99", catalogItems.getAttribute("value")); + + webClient.closeAllWindows(); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/resources/store-client.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/resources/store-client.composite new file mode 100644 index 0000000000..c9abe8e996 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/src/test/resources/store-client.composite @@ -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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://store" + name="store-client"> + + <component name="StoreClient"> + <implementation.java class="client.ShopperImpl"/> + <reference name="catalog"> + <tuscany:binding.jsonrpc uri="http://localhost:8080/Catalog"/> + </reference> + <reference name="shoppingCart"> + <tuscany:binding.atom uri="http://localhost:8080/ShoppingCart/Cart"/> + </reference> + <reference name="shoppingTotal"> + <tuscany:binding.jsonrpc uri="http://localhost:8080/ShoppingCart/Total"/> + </reference> + </component> + +</composite> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/store.png b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/store.png Binary files differnew file mode 100644 index 0000000000..da413edeee --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/store.png diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/store.svg b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/store.svg new file mode 100644 index 0000000000..74f8ecd36d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/applications/store/store.svg @@ -0,0 +1,304 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- + * 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. +--> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="1052.3622" + height="744.09448" + id="svg2" + sodipodi:version="0.32" + inkscape:version="0.45.1" + sodipodi:docbase="C:\simon\tuscany\java-head\sca\samples\store" + sodipodi:docname="store.svg" + version="1.0" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + inkscape:export-filename="C:\simon\tuscany\java-head\sca\samples\store\store.png" + inkscape:export-xdpi="52.84" + inkscape:export-ydpi="52.84"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + gridtolerance="10000" + guidetolerance="10" + objecttolerance="10" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="1.4" + inkscape:cx="538.06165" + inkscape:cy="341.69129" + inkscape:document-units="px" + inkscape:current-layer="g2997" + inkscape:window-width="1466" + inkscape:window-height="831" + inkscape:window-x="117" + inkscape:window-y="80" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <g + id="g2997"> + <rect + rx="14.335117" + ry="17.743465" + y="197.1973" + x="447.35422" + height="419.39099" + width="464.23727" + id="rect2067" + style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:2.28840661;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <flowRoot + id="flowRoot2954" + xml:space="preserve" + transform="translate(189.90868,1.0101522)"><flowRegion + id="flowRegion2956"><rect + y="212.66591" + x="281.42856" + height="61.42857" + width="170" + id="rect2958" /></flowRegion><flowPara + id="flowPara2171">store</flowPara></flowRoot> <rect + style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.30182266;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect2175" + width="118.21779" + height="111.27543" + x="491.60019" + y="247.75989" + rx="7.1507306" + ry="9.2311935" /> + <flowRoot + xml:space="preserve" + id="flowRoot2177" + transform="translate(223.8585,41.670449)"><flowRegion + id="flowRegion2179"><rect + id="rect2181" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" /></flowRegion><flowPara + id="flowPara2183">ufs</flowPara></flowRoot> <path + style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 474.29877,279.45598 L 507.63381,279.45598 L 513.69472,292.58796 L 506.62366,304.7098 L 474.29877,304.7098 L 481.87492,292.58796 L 474.29877,279.45598 z " + id="path2187" /> + <rect + style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect2191" + width="115.66247" + height="85.862968" + x="493.07068" + y="503.27759" + rx="6.9961648" + ry="7.1230249" /> + <flowRoot + xml:space="preserve" + id="flowRoot2193" + transform="translate(225.47992,297.33908)"><flowRegion + id="flowRegion2195"><rect + id="rect2197" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" /></flowRegion><flowPara + id="flowPara2199">ShoppingCart</flowPara></flowRoot> <path + style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 475.92019,535.12461 L 509.25523,535.12461 L 515.31614,548.25659 L 508.24508,560.37843 L 475.92019,560.37843 L 483.49634,548.25659 L 475.92019,535.12461 z " + id="path2203" /> + <rect + style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect2207" + width="115.66247" + height="85.862968" + x="761.44415" + y="391.31604" + rx="6.9961648" + ry="7.1230249" /> + <flowRoot + xml:space="preserve" + id="flowRoot2209" + transform="translate(487.8534,185.37751)"><flowRegion + id="flowRegion2211"><rect + id="rect2213" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" /></flowRegion><flowPara + id="flowPara2215">CurrencyConverter</flowPara></flowRoot> <path + style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 744.29367,423.16304 L 777.62871,423.16304 L 783.68962,436.29502 L 776.61856,448.41686 L 744.29367,448.41686 L 751.86982,436.29502 L 744.29367,423.16304 z " + id="path2219" /> + <rect + style="opacity:1;fill:#0064ff;fill-opacity:1;stroke:#000000;stroke-width:0.9612025;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect2223" + width="104.08451" + height="113.17588" + x="138.37151" + y="350.1156" + rx="0" + ry="0.048917599" /> + <path + style="fill:#1a73fe;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1" + d="M 138.21429,462.66591 L 115.35714,479.80877 L 267.85714,479.80877 L 241.78571,463.02305 L 138.21429,462.66591 z " + id="path3197" /> + <rect + style="opacity:1;fill:#f1f4f8;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect3199" + width="92.5" + height="97.14286" + x="143.57143" + y="358.38019" + ry="3.6203461" + rx="3.9285715" /> + <image + y="366.6889" + x="156.24066" + id="image3323" + height="78.571434" + width="58.57143" + sodipodi:absref="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png" + xlink:href="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png" /> + <image + y="270.52304" + x="526.42859" + id="image3342" + height="78.571434" + width="58.57143" + sodipodi:absref="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png" + xlink:href="C:\simon\tuscany\evangelism\whitepapers\shoppingcart.png" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 242.85714,374.80877 C 245.71429,374.80877 345.71429,374.80877 345.71429,374.80877 L 345.71429,291.95162 L 481.42858,291.95162" + id="path3348" + sodipodi:nodetypes="cccc" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 210.71429,406.95163 L 345,406.95163 L 345,437.66591 L 481.42857,437.66591" + id="path3350" + sodipodi:nodetypes="cccc" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 210.71429,439.09448 L 325.71429,439.09448 L 325.71429,548.3802 L 482.85714,548.3802" + id="path3352" + sodipodi:nodetypes="cccc" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 626.42857,436.23734 C 750,437.66591 752.14286,436.23734 752.14286,436.23734" + id="path3354" + sodipodi:nodetypes="cc" /> + <flowRoot + xml:space="preserve" + id="flowRoot3356" + transform="translate(-94.285714,25)"><flowRegion + id="flowRegion3358"><rect + id="rect3360" + width="142.14285" + height="21.428572" + x="655" + y="349.80878" /></flowRegion><flowPara + id="flowPara3362">CurrenyCode</flowPara></flowRoot> <flowRoot + xml:space="preserve" + id="flowRoot3364" + transform="translate(-250.76562,-76.210859)"><flowRegion + id="flowRegion3366"><rect + id="rect3368" + width="142.14285" + height="21.428572" + x="655" + y="349.80878" /></flowRegion><flowPara + id="flowPara3370">HTTP</flowPara></flowRoot> <flowRoot + xml:space="preserve" + id="flowRoot3372" + transform="translate(-273.62277,70.931998)"><flowRegion + id="flowRegion3374"><rect + id="rect3376" + width="142.14285" + height="21.428572" + x="655" + y="349.80878" /></flowRegion><flowPara + id="flowPara3378">JSONRPC</flowPara></flowRoot> <flowRoot + xml:space="preserve" + id="flowRoot3380" + transform="translate(-243.62277,183.07485)"><flowRegion + id="flowRegion3382"><rect + id="rect3384" + width="142.14285" + height="21.428572" + x="655" + y="349.80878" /></flowRegion><flowPara + id="flowPara3386">Atom</flowPara></flowRoot> </g> + <rect + style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect2988" + width="115.66247" + height="85.862968" + x="491.56897" + y="392.70135" + rx="6.9961648" + ry="7.1230249" /> + <flowRoot + xml:space="preserve" + id="flowRoot2966" + transform="translate(223.97819,186.76283)"><flowRegion + id="flowRegion2968"><rect + id="rect2970" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" /></flowRegion><flowPara + id="flowPara2972">Catalog</flowPara></flowRoot> <rect + style="opacity:1;fill:#fff62c;fill-opacity:1;stroke:#060000;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect3006" + width="21.718224" + height="20.708065" + x="537.53094" + y="377.04398" + rx="10.859112" + ry="0" /> + <path + style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 474.41846,424.54836 L 507.7535,424.54836 L 513.81441,437.68034 L 506.74335,449.80218 L 474.41846,449.80218 L 481.99461,437.68034 L 474.41846,424.54836 z " + id="path3017" /> + <path + style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 587.6709,422.71008 L 621.00594,422.71008 L 627.06685,435.84206 L 619.99579,447.9639 L 587.6709,447.9639 L 595.24705,435.84206 L 587.6709,422.71008 z " + id="path3019" /> + </g> +</svg> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/binding.ws.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/binding.ws.composite new file mode 100644 index 0000000000..a53a68f5bc --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/binding.ws.composite @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="binding.ws">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ <service name="Helloworld">
+ <binding.ws />
+ </service>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/README new file mode 100644 index 0000000000..0cfd8df590 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/README @@ -0,0 +1,28 @@ +Tuscany - Getting Started - Helloworld SCAClient Sample
+-------------------------------------------------------
+
+This sample demonstrates using the OASIS SCAClient API to invoke a service in a remote SCA domain.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project has a Java class with a main method which uses the SCAClient API to invoke a Helloworld
+service in a remote SCA domain.
+
+Before running this sample you must have a helloworld service running in a SCA domain somewhere,
+for example, you can do that by using a separate command prompt to run the Tuscany
+"Getting Started - Helloworld Sample" with the command
+
+ mvn tuscany:run -DdomainURI=uri:default
+
+(including that domainURI parameter activates the Tuscany distributed domain)
+
+You can then run this SCAClient sample with the Maven command:
+
+ mvn tuscany:run
+
+You should see the following oputput:
+
+ HelloworldSCAClient, using domainURI uri:default
+ Calling HelloworldComponent.sayHello("world")
+ Hello world
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/pom.xml new file mode 100644 index 0000000000..45f2df8c1b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/pom.xml @@ -0,0 +1,87 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <relativePath/> + </parent> + + <artifactId>helloworld-scaclient</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + + <name>Apache Tuscany SCA Samples Helloworld SCAClient</name> + + <properties> + <tuscany.version>${project.version}</tuscany.version> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>${tuscany.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-domain-hazelcast</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + + <plugins> + + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>${tuscany.version}</version> + <configuration> + <mainClass>sample.HelloworldSCAClient</mainClass> + </configuration> + </plugin> + + </plugins> + </build> +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..1eeb8be9fd --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/src/main/java/sample/Helloworld.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; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Helloworld { + + String sayHello(String name); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/src/main/java/sample/HelloworldSCAClient.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/src/main/java/sample/HelloworldSCAClient.java new file mode 100644 index 0000000000..9954179e74 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/src/main/java/sample/HelloworldSCAClient.java @@ -0,0 +1,46 @@ +/* + * 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.net.URI; + +import org.oasisopen.sca.NoSuchDomainException; +import org.oasisopen.sca.NoSuchServiceException; +import org.oasisopen.sca.client.SCAClientFactory; + +public class HelloworldSCAClient { + + public static void main(String[] args) throws NoSuchDomainException, NoSuchServiceException { + + String domainURI = System.getProperties().getProperty("domainURI"); + if (domainURI == null || domainURI.length() < 1) { + domainURI = "uri:default"; + } + System.out.println("HelloworldSCAClient, using domainURI " + domainURI); + + String name = args.length < 1 ? "world" : args[0]; + + SCAClientFactory factory = SCAClientFactory.newInstance(URI.create(domainURI)); + Helloworld service = factory.getService(Helloworld.class, "HelloworldComponent"); + + System.out.println("Calling HelloworldComponent.sayHello(\"" + name + "\")"); + System.out.println(service.sayHello(name)); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..d0ebf5be19 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-scaclient/src/test/java/sample/HelloworldTestCase.java @@ -0,0 +1,54 @@ +/* + * 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.apache.tuscany.sca.Node; +import org.apache.tuscany.sca.TuscanyRuntime; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.monitor.ValidationException; +import org.apache.tuscany.sca.runtime.ActivationException; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.oasisopen.sca.NoSuchDomainException; +import org.oasisopen.sca.NoSuchServiceException; + +public class HelloworldTestCase { + + static Node node; + + @Test + public void testSayHello() throws NoSuchDomainException, NoSuchServiceException { + HelloworldSCAClient.main(new String[0]); + } + + @BeforeClass + public static void start() throws ContributionReadException, ActivationException, ValidationException { + node = TuscanyRuntime.newInstance().createNode("uri:default"); + node.installContribution(null, "../helloworld/target/classes", null, null, true); + } + + @AfterClass + public static void stop() { + if (node != null) { + node.stop(); + } + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/README new file mode 100644 index 0000000000..29b67787b7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/README @@ -0,0 +1,30 @@ +Tuscany - Getting Started - Helloworld WebApp Sample
+----------------------------------------------------
+
+This sample demonstrates how to use SCA contributions with Web Applications
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This sample project creates a .war web application which includes Tuscany. The SCA contribution
+from the helloworld sample is included within the war and its SCA composite started by the webapp,
+and there is a JSP page which shows how to invoke SCA services by using the SCA taglib.
+
+As this sample creates a web application .war archive there is a manual step to deploy the WAR file
+to your web application server. The archive is the helloworld-webapp-<version>.war in the target folder.
+Alternatively, you can run it by using the Tuscany Maven plugin by using the following command:
+
+ mvn tuscany:run
+
+(or if you prefer using Jetty then mvn jetty:run, or with the Tomcat plugin mvn tomcat:run)
+
+Once the web app is running use your browser to visit the following URL;
+
+http://localhost:8080/helloworld-webapp
+
+(The port and hostname will of course vary depending on your local installation)
+
+You should then see the web page return the following:
+
+ Calling HelloworldService sayHello("world") returns:
+
+ Hello world
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/pom.xml new file mode 100644 index 0000000000..d2bd2eb6e6 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/pom.xml @@ -0,0 +1,147 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <relativePath/> + </parent> + + <artifactId>helloworld-webapp</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + + <name>Apache Tuscany SCA Samples Helloworld WebApp</name> + <packaging>war</packaging> + + <properties> + <tuscany.version>${project.version}</tuscany.version> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>${tuscany.version}</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>net.sourceforge.htmlunit</groupId> + <artifactId>htmlunit</artifactId> + <version>2.6</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + + <!-- this copies the SCA contribution from the helloworld sample into this webapp --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy</id> + <phase>compile</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>helloworld</artifactId> + <version>${project.version}</version> + <!-- should really go in the target folder but i can't get jetty:run or tomcat:run to work using that --> + <outputDirectory>src/main/webapp/WEB-INF/sca-contributions</outputDirectory> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + + <!-- to support running thw webapp with mvn tuscany:run --> + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>${tuscany.version}</version> + </plugin> + + <!-- to support using mvn jetty:run and also to run the webapp for the integration test --> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>maven-jetty-plugin</artifactId> + <version>6.1.26</version> + <configuration> + <contextPath>helloworld-webapp</contextPath> + <stopKey>foo</stopKey> + <stopPort>9999</stopPort> + </configuration> + <executions> + <execution> + <id>start-jetty</id> + <phase>process-test-classes</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <scanIntervalSeconds>0</scanIntervalSeconds> + <daemon>true</daemon> + <connectors> + <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> + <port>8085</port> + </connector> + </connectors> + </configuration> + </execution> + <execution> + <id>stop-jetty</id> + <phase>prepare-package</phase> + <goals> + <goal>stop</goal> + </goals> + </execution> + </executions> + </plugin> + + <!-- to support using mvn tomcat:run --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>tomcat-maven-plugin</artifactId> + <version>1.1</version> + </plugin> + + </plugins> + </build> +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..1eeb8be9fd --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/java/sample/Helloworld.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; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Helloworld { + + String sayHello(String name); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..0c03826f99 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.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"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="foo">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="HelloworldComponent"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..b83a9c3417 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ +<?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. +--> +<web-app version="2.4" + xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > + + <display-name>Apache Tuscany Helloworld Sample</display-name> + + <filter> + <filter-name>tuscany</filter-name> + <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>tuscany</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <welcome-file-list id="WelcomeFileList"> + <welcome-file>hello.jsp</welcome-file> + </welcome-file-list> + +</web-app> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/webapp/hello.jsp b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..57abb08ca2 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/main/webapp/hello.jsp @@ -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.
+-->
+
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
+
+<sca:reference name="service" type="sample.Helloworld" />
+
+<html>
+ <body >
+
+ <h2>Apache Tuscany Helloworld JSP Sample</h2>
+
+ Calling HelloworldService sayHello("world") returns:
+
+ <p>
+
+ <%= service.sayHello("world") %>
+
+ </body>
+</html>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/test/java/itest/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/test/java/itest/HelloworldTestCase.java new file mode 100644 index 0000000000..40da70b98d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/test/java/itest/HelloworldTestCase.java @@ -0,0 +1,53 @@ +/* + * 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 itest; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.Iterator; + +import org.junit.Test; + +import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlElement; +import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.gargoylesoftware.htmlunit.html.HtmlParagraph; + +/** + */ +public class HelloworldTestCase { + + @Test + public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException { + HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-webapp"); + Iterator<?> ss = page.getAllHtmlChildElements().iterator(); + while(ss.hasNext()) { + HtmlElement htmlElement = (HtmlElement) ss.next(); + if( htmlElement instanceof HtmlParagraph) { + assertEquals("Hello world", htmlElement.asText()); + break; + } + } + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/test/resources/test-web.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/test/resources/test-web.xml new file mode 100644 index 0000000000..4ca1c962a0 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld-webapp/src/test/resources/test-web.xml @@ -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. +--> +<web-app version="2.4" + xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > + + <context-param> + <param-name>org.apache.tuscany.sca.config</param-name> + <param-value>uri:default?bind=127.0.0.1:54321</param-value> + </context-param> + +</web-app> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/README new file mode 100644 index 0000000000..fc306caa34 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/README @@ -0,0 +1,43 @@ +Tuscany - Getting Started - Helloworld Sample
+---------------------------------------------
+
+This sample demonstrates a simple helloworld style SCA application and how to run that with Tuscany.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project creates an SCA contribution with a deployable composite named helloworld.composite.
+The composite defines an SCA component, HelloworldComponent, which provides a Helloworld service,
+the component is implemented by a Java class.
+
+You can use the contribution by starting the composite in the Tuscany Shell. To do that run the
+following command in the helloworld folder:
+
+ mvn tuscany:run
+
+Alternatively, the Tuscany Shell can be started with the scripts in the Tuscany binary distribution
+bin folder. To do that run the following command at the root of a Tuscany binary distribution:
+
+ bin\tuscany.bat samples\getting-started\helloworld
+
+Once the Shell has been started with one of those methods you can use Shell commands to explore
+the SCA domain, for example, use the "installed" command to get the status of installed contributions,
+"services" to see the available component services, and you may test calling the helloworld service by
+using the "invoke" command:
+
+ invoke HelloworldComponent sayHello yourName
+
+---
+
+This sample was created by the Tuscany contribution-jar Maven archetype. You can use that archetype to
+create your own SCA contribution projects by running the following Maven command:
+
+ mvn archetype:generate -DarchetypeCatalog=http://tuscany.apache.org
+
+then at the prompt select 1 to choose the contribution-jar archetype and then answer the questions.
+This project used the following answers:
+
+ Define value for property 'groupId': : org.apache.tuscany.sca.samples
+ Define value for property 'artifactId': : helloworld-contribution
+ Define value for property 'version': 1.0-SNAPSHOT: 2.0-SNAPSHOT
+ Define value for property 'package': org.apache.tuscany.sca.samples: sample
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/pom.xml new file mode 100644 index 0000000000..8181502961 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/pom.xml @@ -0,0 +1,77 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <artifactId>helloworld</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+
+ <name>Apache Tuscany SCA Samples Helloworld</name>
+
+ <properties>
+ <tuscany.version>${project.version}</tuscany.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>${tuscany.version}</version>
+ </plugin>
+ </plugins>
+
+ </build>
+
+</project>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..f4e8c50448 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/java/sample/Helloworld.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;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..089b1a4290 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/java/sample/HelloworldImpl.java @@ -0,0 +1,27 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+public class HelloworldImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..95c32fb5bf --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?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:helloworld-contribution" />
+
+</contribution>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/resources/helloworld.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..e0206cd6e8 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/main/resources/helloworld.composite @@ -0,0 +1,29 @@ +<?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"
+ name="helloworld-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..be27aa68ef --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/helloworld/src/test/java/sample/HelloworldTestCase.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;
+
+import org.junit.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class HelloworldTestCase {
+
+ @Test
+ public void testSayHello() throws NoSuchServiceException {
+
+ // Run the SCA composite in a Tuscany runtime
+ Node node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes");
+ try {
+
+ // Get the Helloworld service proxy
+ Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent");
+
+ // test that it works as expected
+ Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia"));
+
+ } finally {
+ // Stop the Tuscany runtime Node
+ node.stop();
+ }
+ }
+}
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/pom.xml new file mode 100644 index 0000000000..1316eebe47 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/getting-started/pom.xml @@ -0,0 +1,39 @@ +<?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.samples</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </parent> + + <artifactId>tuscany-samples-getting-started</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <packaging>pom</packaging> + <name>Apache Tuscany SCA Samples Getting Started</name> + + <modules> + <module>helloworld</module> + <module>helloworld-webapp</module> + <module>helloworld-scaclient</module> + </modules> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/README new file mode 100644 index 0000000000..4abff8df36 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/README @@ -0,0 +1,24 @@ +Tuscany - Getting Started - Helloworld Sample
+---------------------------------------------
+
+This sample demonstrates a simple helloworld style SCA application.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project creates an SCA contribution with a deployable composite named helloworld.comosite.
+The composite defines an SCA component, HelloworldComponent, which provides a Helloworld service,
+the component is implemented by a Java class.
+
+You can use the contribution by starting the composite in the Tuscany Shell. To do that run the
+the Tuscany Shell which can be started with the scripts in the Tuscany binary distribution
+bin folder. To do that run the following command at the root of a Tuscany binary distribution:
+
+ bin\tuscany.bat samples\getting-started\helloworld-contribution
+
+Once the Shell has been started you may use Shell commands to explore
+the SCA domain, for example, use the "installed" command to get the status of installed contributions,
+"services" to see the available component services, and you may test calling the helloworld service by
+using the "invoke" command:
+
+ invoke HelloworldComponent sayHello yourName
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/pom.xml new file mode 100644 index 0000000000..2eee538e97 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </parent> + + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>helloworld-contribution2</artifactId> + + <name>Tuscany Sample Helloworld Contribution2</name> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <defaultGoal>install</defaultGoal> + <finalName>helloworld-contribution</finalName> + </build> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..1eeb8be9fd --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/java/sample/Helloworld.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; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Helloworld { + + String sayHello(String name); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..c2c851324b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/java/sample/HelloworldImpl.java @@ -0,0 +1,36 @@ +/* + * 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.Init; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.EagerInit; + +@Scope("COMPOSITE") @EagerInit +public class HelloworldImpl implements Helloworld { + + public String sayHello(String name) { + return "Hello " + name; + } + + @Init + public void init() { + System.out.println(sayHello("world")); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..e82c54d3a7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?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:helloworld-contribution" /> + +</contribution> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/resources/helloworld.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..e0206cd6e8 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/main/resources/helloworld.composite @@ -0,0 +1,29 @@ +<?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"
+ name="helloworld-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..d3b858053a --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-contribution2/src/test/java/sample/HelloworldTestCase.java @@ -0,0 +1,36 @@ +/* + * 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.junit.Assert; +import org.junit.Test; +import org.oasisopen.sca.NoSuchServiceException; + +public class HelloworldTestCase { + + @Test + public void testSayHello() throws NoSuchServiceException { + + // Get the Helloworld service proxy + Helloworld helloworld = new HelloworldImpl(); + + // test that it works as expected + Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia")); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/README new file mode 100644 index 0000000000..83e2302ac1 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/README @@ -0,0 +1,43 @@ +Tuscany - Getting Started - Helloworld Sample
+---------------------------------------------
+
+This sample demonstrates a simple helloworld style SCA application and how to run that with Tuscany.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project creates an SCA contribution with a deployable composite named helloworld.comosite.
+The composite defines an SCA component, HelloworldComponent, which provides a Helloworld service,
+the component is implemented by a Java class.
+
+You can use the contribution by starting the composite in the Tuscany Shell. To do that run the
+following command in the helloworld-contribution folder:
+
+ mvn tuscany:run
+
+Alternatively, the Tuscany Shell can be started with the scripts in the Tuscany binary distribution
+bin folder. To do that run the following command at the root of a Tuscany binary distribution:
+
+ bin\tuscany.bat samples\getting-started\helloworld-contribution
+
+Once the Shell has been started with one of those methods you can use Shell commands to explore
+the SCA domain, for example, use the "installed" command to get the status of installed contributions,
+"services" to see the available component services, and you may test calling the helloworld service by
+using the "invoke" command:
+
+ invoke HelloworldComponent sayHello yourName
+
+---
+
+This sample was created by the Tuscany contribution-jar Maven archetype. You can use that archetype to
+create your own SCA contribution projects by running the following Maven command:
+
+ mvn archetype:generate -DarchetypeCatalog=http://tuscany.apache.org
+
+then at the prompt select 1 to choose the contribution-jar archetype and then answer the questions.
+This project used the following answers:
+
+ Define value for property 'groupId': : org.apache.tuscany.sca.samples
+ Define value for property 'artifactId': : helloworld-contribution
+ Define value for property 'version': 1.0-SNAPSHOT: 2.0-SNAPSHOT
+ Define value for property 'package': org.apache.tuscany.sca.samples: sample
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/pom.xml new file mode 100644 index 0000000000..5b9708997f --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/pom.xml @@ -0,0 +1,114 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>helloworld-http-contribution</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>Tuscany Sample Helloworld Rest Contribution</name> + + <properties> + <tuscany.version>2.0-Beta3-SNAPSHOT</tuscany.version> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>${tuscany.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-http-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-json</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty</artifactId> + <version>6.1.19</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <defaultGoal>install</defaultGoal> + <finalName>helloworld-contribution</finalName> + + <plugins> + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>${tuscany.version}</version> + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-http-runtime</artifactId> + <version>${tuscany.version}</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-json</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + </dependency> + </dependencies> + </plugin> + </plugins> + + </build> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..1eeb8be9fd --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/java/sample/Helloworld.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; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Helloworld { + + String sayHello(String name); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..95e97b6afb --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/java/sample/HelloworldImpl.java @@ -0,0 +1,36 @@ +/* + * 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.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Scope; + +@Scope("COMPOSITE") @EagerInit +public class HelloworldImpl implements Helloworld { + + public String sayHello(String name) { + return "Hello " + name; + } + + @Init + public void init() { + System.out.println(sayHello("world")); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/resources/META-INF/helloworld.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/resources/META-INF/helloworld.composite new file mode 100644 index 0000000000..fbfe29eb3e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/resources/META-INF/helloworld.composite @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ <service name="Helloworld">
+ <tuscany:binding.http/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..e82c54d3a7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?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:helloworld-contribution" /> + +</contribution> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..3cda2eec2a --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-http-contribution/src/test/java/sample/HelloworldTestCase.java @@ -0,0 +1,68 @@ +/* + * 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.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; + +import org.apache.tuscany.sca.Node; +import org.apache.tuscany.sca.TuscanyRuntime; +import org.junit.Assert; +import org.junit.Test; +import org.oasisopen.sca.NoSuchServiceException; + +public class HelloworldTestCase { + + @Test + public void testSayHello() throws NoSuchServiceException, IOException { + + // Run the SCA composite in a Tuscany runtime + Node node = TuscanyRuntime.runComposite(null, "target/classes"); + try { + + // test that has exposed an HTTP endpoint that works as expected + URL url = new URL("http://localhost:8080/HelloworldComponent/Helloworld/sayHello?name=Amelia"); + Assert.assertEquals("\"Hello Amelia\"", read(url.openStream())); + + } finally { + // Stop the Tuscany runtime Node + node.stop(); + } + } + + private static String read(InputStream is) throws IOException { + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(is)); + StringBuffer sb = new StringBuffer(); + String str; + while ((str = reader.readLine()) != null) { + sb.append(str); + } + return sb.toString(); + } finally { + if (reader != null) { + reader.close(); + } + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/README new file mode 100644 index 0000000000..83e2302ac1 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/README @@ -0,0 +1,43 @@ +Tuscany - Getting Started - Helloworld Sample
+---------------------------------------------
+
+This sample demonstrates a simple helloworld style SCA application and how to run that with Tuscany.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project creates an SCA contribution with a deployable composite named helloworld.comosite.
+The composite defines an SCA component, HelloworldComponent, which provides a Helloworld service,
+the component is implemented by a Java class.
+
+You can use the contribution by starting the composite in the Tuscany Shell. To do that run the
+following command in the helloworld-contribution folder:
+
+ mvn tuscany:run
+
+Alternatively, the Tuscany Shell can be started with the scripts in the Tuscany binary distribution
+bin folder. To do that run the following command at the root of a Tuscany binary distribution:
+
+ bin\tuscany.bat samples\getting-started\helloworld-contribution
+
+Once the Shell has been started with one of those methods you can use Shell commands to explore
+the SCA domain, for example, use the "installed" command to get the status of installed contributions,
+"services" to see the available component services, and you may test calling the helloworld service by
+using the "invoke" command:
+
+ invoke HelloworldComponent sayHello yourName
+
+---
+
+This sample was created by the Tuscany contribution-jar Maven archetype. You can use that archetype to
+create your own SCA contribution projects by running the following Maven command:
+
+ mvn archetype:generate -DarchetypeCatalog=http://tuscany.apache.org
+
+then at the prompt select 1 to choose the contribution-jar archetype and then answer the questions.
+This project used the following answers:
+
+ Define value for property 'groupId': : org.apache.tuscany.sca.samples
+ Define value for property 'artifactId': : helloworld-contribution
+ Define value for property 'version': 1.0-SNAPSHOT: 2.0-SNAPSHOT
+ Define value for property 'package': org.apache.tuscany.sca.samples: sample
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/pom.xml new file mode 100644 index 0000000000..418091cb5d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/pom.xml @@ -0,0 +1,109 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>helloworld-rest-contribution</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>Tuscany Sample Helloworld Rest Contribution</name> + + <properties> + <tuscany.version>2.0-Beta3-SNAPSHOT</tuscany.version> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>${tuscany.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + <version>1.1.1</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-rest-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty</artifactId> + <version>6.1.19</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <defaultGoal>install</defaultGoal> + <finalName>helloworld-contribution</finalName> + + <plugins> + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>${tuscany.version}</version> + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-rest-runtime</artifactId> + <version>${tuscany.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + + </build> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..2faf096c33 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/java/sample/Helloworld.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; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Helloworld { + + @GET + @Path("sayHello") + String sayHello(@QueryParam("name")String name); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..95e97b6afb --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/java/sample/HelloworldImpl.java @@ -0,0 +1,36 @@ +/* + * 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.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Scope; + +@Scope("COMPOSITE") @EagerInit +public class HelloworldImpl implements Helloworld { + + public String sayHello(String name) { + return "Hello " + name; + } + + @Init + public void init() { + System.out.println(sayHello("world")); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/resources/META-INF/helloworld.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/resources/META-INF/helloworld.composite new file mode 100644 index 0000000000..7378f22b49 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/resources/META-INF/helloworld.composite @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ <service name="Helloworld">
+ <tuscany:binding.rest />
+ </service>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..e82c54d3a7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?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:helloworld-contribution" /> + +</contribution> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..8926c6803d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution/src/test/java/sample/HelloworldTestCase.java @@ -0,0 +1,68 @@ +/* + * 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.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; + +import org.apache.tuscany.sca.Node; +import org.apache.tuscany.sca.TuscanyRuntime; +import org.junit.Assert; +import org.junit.Test; +import org.oasisopen.sca.NoSuchServiceException; + +public class HelloworldTestCase { + + @Test + public void testSayHello() throws NoSuchServiceException, IOException { + + // Run the SCA composite in a Tuscany runtime + Node node = TuscanyRuntime.runComposite(null, "target/classes"); + try { + + // test that has exposed an HTTP endpoint that works as expected + URL url = new URL("http://localhost:8080/HelloworldComponent/Helloworld/sayHello?name=Amelia"); + Assert.assertEquals("Hello Amelia", read(url.openStream())); + + } finally { + // Stop the Tuscany runtime Node + node.stop(); + } + } + + private static String read(InputStream is) throws IOException { + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(is)); + StringBuffer sb = new StringBuffer(); + String str; + while ((str = reader.readLine()) != null) { + sb.append(str); + } + return sb.toString(); + } finally { + if (reader != null) { + reader.close(); + } + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/README new file mode 100644 index 0000000000..83e2302ac1 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/README @@ -0,0 +1,43 @@ +Tuscany - Getting Started - Helloworld Sample
+---------------------------------------------
+
+This sample demonstrates a simple helloworld style SCA application and how to run that with Tuscany.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project creates an SCA contribution with a deployable composite named helloworld.comosite.
+The composite defines an SCA component, HelloworldComponent, which provides a Helloworld service,
+the component is implemented by a Java class.
+
+You can use the contribution by starting the composite in the Tuscany Shell. To do that run the
+following command in the helloworld-contribution folder:
+
+ mvn tuscany:run
+
+Alternatively, the Tuscany Shell can be started with the scripts in the Tuscany binary distribution
+bin folder. To do that run the following command at the root of a Tuscany binary distribution:
+
+ bin\tuscany.bat samples\getting-started\helloworld-contribution
+
+Once the Shell has been started with one of those methods you can use Shell commands to explore
+the SCA domain, for example, use the "installed" command to get the status of installed contributions,
+"services" to see the available component services, and you may test calling the helloworld service by
+using the "invoke" command:
+
+ invoke HelloworldComponent sayHello yourName
+
+---
+
+This sample was created by the Tuscany contribution-jar Maven archetype. You can use that archetype to
+create your own SCA contribution projects by running the following Maven command:
+
+ mvn archetype:generate -DarchetypeCatalog=http://tuscany.apache.org
+
+then at the prompt select 1 to choose the contribution-jar archetype and then answer the questions.
+This project used the following answers:
+
+ Define value for property 'groupId': : org.apache.tuscany.sca.samples
+ Define value for property 'artifactId': : helloworld-contribution
+ Define value for property 'version': 1.0-SNAPSHOT: 2.0-SNAPSHOT
+ Define value for property 'package': org.apache.tuscany.sca.samples: sample
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/helloworld-metadata.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/helloworld-metadata.xml new file mode 100644 index 0000000000..97f3fd9f10 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/helloworld-metadata.xml @@ -0,0 +1,25 @@ +<?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"> + + <export.java package="sample" /> + +</contribution> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/nodeConfig.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/nodeConfig.xml new file mode 100644 index 0000000000..64ffd9c40c --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/nodeConfig.xml @@ -0,0 +1,28 @@ +<?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. +--> +<node xmlns="http://tuscany.apache.org/xmlns/sca/1.1"> + + <contribution location="../helloworld-contribution/target/helloworld-contribution.jar" + metaDataURL="helloworld-metadata.xml" /> + + <contribution location="target/classes" + startDeployables="true" /> + +</node>
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/pom.xml new file mode 100644 index 0000000000..df3207aa31 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/pom.xml @@ -0,0 +1,109 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>helloworld-rest-contribution2</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>Tuscany Sample Helloworld Rest Contribution2</name> + + <properties> + <tuscany.version>2.0-Beta3-SNAPSHOT</tuscany.version> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>${tuscany.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + <version>1.1.1</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-rest-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty</artifactId> + <version>6.1.19</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <defaultGoal>install</defaultGoal> + <finalName>helloworld-contribution</finalName> + + <plugins> + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>${tuscany.version}</version> + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-rest-runtime</artifactId> + <version>${tuscany.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + + </build> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/main/java/sample/JaxrsHelloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/main/java/sample/JaxrsHelloworld.java new file mode 100644 index 0000000000..aa0918bbb1 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/main/java/sample/JaxrsHelloworld.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; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface JaxrsHelloworld { + + @GET + @Path("sayHello") + String sayHello(@QueryParam("name") String name); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/main/resources/META-INF/helloworld.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/main/resources/META-INF/helloworld.composite new file mode 100644 index 0000000000..88df3636c3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/main/resources/META-INF/helloworld.composite @@ -0,0 +1,33 @@ +<?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"
+ name="helloworld-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ <service name="Helloworld">
+ <interface.java interface="sample.JaxrsHelloworld"/>
+ <tuscany:binding.rest/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..7d237ea63e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ +<?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:helloworld-contribution" /> + <import.java package="sample" /> + +</contribution> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..4749a2eb29 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-rest-contribution2/src/test/java/sample/HelloworldTestCase.java @@ -0,0 +1,71 @@ +/* + * 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.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; + +import org.apache.tuscany.sca.Node; +import org.apache.tuscany.sca.TuscanyRuntime; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.monitor.ValidationException; +import org.apache.tuscany.sca.runtime.ActivationException; +import org.junit.Assert; +import org.junit.Test; +import org.oasisopen.sca.NoSuchServiceException; + +public class HelloworldTestCase { + + @Test + public void testSayHello() throws NoSuchServiceException, IOException, ContributionReadException, ActivationException, ValidationException { + + // Run the SCA composite in a Tuscany runtime + Node node = TuscanyRuntime.newInstance().createNodeFromXML("nodeConfig.xml"); + try { + + // test that has exposed an HTTP endpoint that works as expected + URL url = new URL("http://localhost:8080/HelloworldComponent/Helloworld/sayHello?name=Amelia"); + Assert.assertEquals("Hello Amelia", read(url.openStream())); + + } finally { + // Stop the Tuscany runtime Node + node.stop(); + } + } + + private static String read(InputStream is) throws IOException { + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(is)); + StringBuffer sb = new StringBuffer(); + String str; + while ((str = reader.readLine()) != null) { + sb.append(str); + } + return sb.toString(); + } finally { + if (reader != null) { + reader.close(); + } + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/pom.xml new file mode 100644 index 0000000000..52080adf3d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/pom.xml @@ -0,0 +1,119 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>2.0-Beta2</version> + </parent> + + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>helloworld-scala-contribution</artifactId> + <version>2.0-Beta2</version> + + <name>Tuscany Sample Helloworld Scala Contribution</name> + + <properties> + <tuscany.version>2.0-Beta2</tuscany.version> + <scala.version>2.8.0</scala.version> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>${tuscany.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.scala-lang</groupId> + <artifactId>scala-library</artifactId> + <version>${scala.version}</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <defaultGoal>install</defaultGoal> + <finalName>helloworld-scala-contribution</finalName> + + <sourceDirectory>src/main/scala</sourceDirectory> + <testSourceDirectory>src/test/scala</testSourceDirectory> + + <plugins> + + <plugin> + <groupId>org.scala-tools</groupId> + <artifactId>maven-scala-plugin</artifactId> + <version>2.15.0</version> + <executions> + <execution> + <goals> + <goal>compile</goal> + <goal>testCompile</goal> + </goals> + <configuration> + <args> + <arg>-make:transitive</arg> + <arg>-dependencyfile</arg> + <arg>${project.build.directory}/.scala_dependencies</arg> + </args> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>${tuscany.version}</version> + <dependencies> + <dependency> + <groupId>org.scala-lang</groupId> + <artifactId>scala-library</artifactId> + <version>${scala.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + + </build> + +</project>
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..e82c54d3a7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?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:helloworld-contribution" /> + +</contribution> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/resources/helloworld.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..e0206cd6e8 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/resources/helloworld.composite @@ -0,0 +1,29 @@ +<?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"
+ name="helloworld-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/scala/sample/Helloworld.scala b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/scala/sample/Helloworld.scala new file mode 100644 index 0000000000..9f24220a09 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/scala/sample/Helloworld.scala @@ -0,0 +1,8 @@ +package sample
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+trait Helloworld {
+ def sayHello(name : String):String
+}
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/scala/sample/HelloworldImpl.scala b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/scala/sample/HelloworldImpl.scala new file mode 100644 index 0000000000..2142d9ece3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/main/scala/sample/HelloworldImpl.scala @@ -0,0 +1,9 @@ +package sample
+
+class HelloworldImpl extends Helloworld {
+
+ def sayHello(name : String) = {
+ "Hello " + name
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/test/scala/sample/HelloworldTestCase.scala b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/test/scala/sample/HelloworldTestCase.scala new file mode 100644 index 0000000000..61b6f48d55 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-scala-contribution/src/test/scala/sample/HelloworldTestCase.scala @@ -0,0 +1,23 @@ +package samples
+
+import org.junit._
+import Assert._
+import org.apache.tuscany.sca._
+
+@Test
+class HelloworldTestCase {
+
+ @Test
+ def testSayHello() = {
+ var node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes");
+ try {
+ var helloworld = node.getService(classOf[sample.Helloworld], "HelloworldComponent");
+ assertEquals("Hello Amelia", helloworld.sayHello("Amelia"));
+ } finally {
+ node.stop();
+ }
+ }
+
+}
+
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/README new file mode 100644 index 0000000000..506deddb32 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/README @@ -0,0 +1,28 @@ +Tuscany - Getting Started - Helloworld Sample
+---------------------------------------------
+
+This sample demonstrates a helloworld style SCA application that uses the Spring implementation type.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project creates an SCA contribution with a deployable composite named helloworld-spring.comosite.
+The composite defines an SCA component, HelloworldComponent, which provides a Helloworld service,
+the component is implemented by a Spring bean.
+
+You can use the contribution by starting the composite in the Tuscany Shell. To do that run the
+following command in the helloworld-spring-contribution folder:
+
+ mvn tuscany:run
+
+Alternatively, the Tuscany Shell can be started with the scripts in the Tuscany binary distribution
+bin folder. To do that run the following command at the root of a Tuscany binary distribution:
+
+ bin\tuscany.bat samples\getting-started\helloworld-spring-contribution
+
+Once the Shell has been started with one of those methods you can use Shell commands to explore
+the SCA domain, for example, use the "installed" command to get the status of installed contributions,
+"services" to see the available component services, and you may test calling the helloworld service by
+using the "invoke" command:
+
+ invoke HelloworldComponent sayHello yourName
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/pom.xml new file mode 100644 index 0000000000..6e99c82611 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/pom.xml @@ -0,0 +1,91 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>helloworld-spring-contribution</artifactId> + <name>Tuscany Sample Helloworld using Spring Contribution</name> + + <properties> + <tuscany.version>2.0-Beta3-SNAPSHOT</tuscany.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>${tuscany.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-spring-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <defaultGoal>install</defaultGoal> + + <plugins> + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>${tuscany.version}</version> + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-spring-runtime</artifactId> + <version>${tuscany.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + + </build> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..1eeb8be9fd --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/java/sample/Helloworld.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; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Helloworld { + + String sayHello(String name); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..d8bdadbfe5 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/java/sample/HelloworldImpl.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; + + +//@Scope("COMPOSITE") @EagerInit +public class HelloworldImpl implements Helloworld { + + public String sayHello(String name) { + return "Hello " + name; + } + +// @Init + public void init() { + System.out.println(sayHello("world")); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/resources/META-INF/helloworld-context.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/resources/META-INF/helloworld-context.xml new file mode 100644 index 0000000000..8718d70597 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/resources/META-INF/helloworld-context.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca-j/spring/200810" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd"> + + <sca:service name="HelloworldService" target="HelloworldBean" /> + + <bean id="HelloworldBean" class="sample.HelloworldImpl"> + </bean> + +</beans>
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/resources/META-INF/helloworld.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/resources/META-INF/helloworld.composite new file mode 100644 index 0000000000..755fa41638 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/resources/META-INF/helloworld.composite @@ -0,0 +1,29 @@ +<?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"
+ name="helloworld-spring">
+
+ <component name="HelloworldComponent">
+ <implementation.spring location="helloworld-context.xml"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..2476201c93 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?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:helloworld-spring" /> + +</contribution> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..1c5c085e8b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-contribution/src/test/java/sample/HelloworldTestCase.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; + +import org.junit.Assert; + +import org.apache.tuscany.sca.Node; +import org.apache.tuscany.sca.TuscanyRuntime; +import org.junit.Test; +import org.oasisopen.sca.NoSuchServiceException; + +public class HelloworldTestCase { + + @Test + public void testSayHello() throws NoSuchServiceException { + + // Run the SCA composite in a Tuscany runtime + Node node = TuscanyRuntime.runComposite(null, "target/classes"); + try { + + // Get the Helloworld service proxy + Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent"); + + // test that it works as expected + Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia")); + + } finally { + // Stop the Tuscany runtime Node + node.stop(); + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/README b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/README new file mode 100644 index 0000000000..506deddb32 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/README @@ -0,0 +1,28 @@ +Tuscany - Getting Started - Helloworld Sample
+---------------------------------------------
+
+This sample demonstrates a helloworld style SCA application that uses the Spring implementation type.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project creates an SCA contribution with a deployable composite named helloworld-spring.comosite.
+The composite defines an SCA component, HelloworldComponent, which provides a Helloworld service,
+the component is implemented by a Spring bean.
+
+You can use the contribution by starting the composite in the Tuscany Shell. To do that run the
+following command in the helloworld-spring-contribution folder:
+
+ mvn tuscany:run
+
+Alternatively, the Tuscany Shell can be started with the scripts in the Tuscany binary distribution
+bin folder. To do that run the following command at the root of a Tuscany binary distribution:
+
+ bin\tuscany.bat samples\getting-started\helloworld-spring-contribution
+
+Once the Shell has been started with one of those methods you can use Shell commands to explore
+the SCA domain, for example, use the "installed" command to get the status of installed contributions,
+"services" to see the available component services, and you may test calling the helloworld service by
+using the "invoke" command:
+
+ invoke HelloworldComponent sayHello yourName
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/pom.xml new file mode 100644 index 0000000000..c3e8eb9ca5 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/pom.xml @@ -0,0 +1,136 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tuscany.sca.samples</groupId> + <artifactId>tuscany-samples</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>helloworld-spring-web-contribution</artifactId> + <name>Tuscany Sample Helloworld using Spring and binding http/rest Contribution</name> + + <properties> + <tuscany.version>2.0-Beta3-SNAPSHOT</tuscany.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>${tuscany.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-spring-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-http-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-json</artifactId> + <version>2.0-Beta3-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + <version>1.1.1</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-rest-runtime</artifactId> + <version>${tuscany.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty</artifactId> + <version>6.1.19</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <defaultGoal>install</defaultGoal> + + <plugins> + <plugin> + <groupId>org.apache.tuscany.maven.plugins</groupId> + <artifactId>maven-tuscany-plugin</artifactId> + <version>${tuscany.version}</version> + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-spring-runtime</artifactId> + <version>${tuscany.version}</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-rest-runtime</artifactId> + <version>${tuscany.version}</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-http-runtime</artifactId> + <version>${tuscany.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + + </build> + +</project> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..2faf096c33 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/java/sample/Helloworld.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; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Helloworld { + + @GET + @Path("sayHello") + String sayHello(@QueryParam("name")String name); + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..d8bdadbfe5 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/java/sample/HelloworldImpl.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; + + +//@Scope("COMPOSITE") @EagerInit +public class HelloworldImpl implements Helloworld { + + public String sayHello(String name) { + return "Hello " + name; + } + +// @Init + public void init() { + System.out.println(sayHello("world")); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/resources/META-INF/helloworld-context.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/resources/META-INF/helloworld-context.xml new file mode 100644 index 0000000000..2e3e34cc18 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/resources/META-INF/helloworld-context.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:sca="http://www.springframework.org/schema/sca" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd"> + + <sca:service name="Helloworld" target="HelloworldBean" /> + + <bean id="HelloworldBean" class="sample.HelloworldImpl"> + </bean> + +</beans>
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/resources/META-INF/helloworld.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/resources/META-INF/helloworld.composite new file mode 100644 index 0000000000..6d89d1ad71 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/resources/META-INF/helloworld.composite @@ -0,0 +1,33 @@ +<?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"
+ name="helloworld-spring">
+
+ <component name="HelloworldComponent">
+ <implementation.spring location="helloworld-context.xml"/>
+ <service name="Helloworld">
+ <tuscany:binding.http />
+ <tuscany:binding.rest name="foo" />
+ </service>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..2476201c93 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?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:helloworld-spring" /> + +</contribution> diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..cf50eb4d54 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/helloworld-spring-web-contribution/src/test/java/sample/HelloworldTestCase.java @@ -0,0 +1,71 @@ +/* + * 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.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; + +import org.apache.tuscany.sca.Node; +import org.apache.tuscany.sca.TuscanyRuntime; +import org.junit.Assert; +import org.junit.Test; +import org.oasisopen.sca.NoSuchServiceException; + +public class HelloworldTestCase { + + @Test + public void testSayHello() throws NoSuchServiceException, IOException { + + // Run the SCA composite in a Tuscany runtime + Node node = TuscanyRuntime.runComposite(null, "target/classes"); + try { + + // test that has exposed an HTTP endpoint that works as expected + URL url = new URL("http://localhost:8080/HelloworldComponent/Helloworld/foo/sayHello?name=Amelia"); + Assert.assertEquals("Hello Amelia", read(url.openStream())); + + url = new URL("http://localhost:8080/HelloworldComponent/Helloworld/sayHello?name=Amelia"); + Assert.assertEquals("\"Hello Amelia\"", read(url.openStream())); + + } finally { + // Stop the Tuscany runtime Node + node.stop(); + } + } + + private static String read(InputStream is) throws IOException { + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(is)); + StringBuffer sb = new StringBuffer(); + String str; + while ((str = reader.readLine()) != null) { + sb.append(str); + } + return sb.toString(); + } finally { + if (reader != null) { + reader.close(); + } + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/using-tuscany.odt b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/using-tuscany.odt Binary files differnew file mode 100644 index 0000000000..48b9a42e47 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/samples/using-tuscany.odt diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/commands.txt b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/commands.txt new file mode 100644 index 0000000000..b784087833 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/commands.txt @@ -0,0 +1,227 @@ +// Show the test bundle resolving against the Tuscany base repo
+
+java -jar bin/felix.jar
+
+obr:repos add file:///D:/sca-java-2.x/unreleased/testing/itest/bundle/target/repository.xml
+
+obr:list
+
+Apache Felix Bundle Repository (1.4.3, ...)
+Apache Felix Configuration Admin Service (1.2.4, ...)
+Apache Felix Declarative Services (1.6.0, ...)
+Apache Felix EventAdmin (1.0.0)
+Apache Felix File Install (3.0.2, ...)
+Apache Felix Gogo Command (0.8.0, ...)
+Apache Felix Gogo Runtime (0.8.0, ...)
+Apache Felix Gogo Shell (0.8.0, ...)
+Apache Felix Gogo Shell Commands (0.2.0)
+Apache Felix Gogo Shell Console (0.2.0)
+Apache Felix Gogo Shell Launcher (0.2.0)
+Apache Felix Gogo Shell Runtime (0.2.0)
+Apache Felix Http Api (2.0.4)
+Apache Felix Http Base (2.0.4)
+Apache Felix Http Bridge (2.0.4)
+Apache Felix Http Bundle (2.0.4)
+Apache Felix Http Jetty (2.0.4)
+Apache Felix Http Proxy (2.0.4)
+Apache Felix Http Samples - Filter (2.0.4)
+Apache Felix Http Samples - Whiteboard (2.0.4)
+Apache Felix HTTP Service Jetty (1.0.1, ...)
+Apache Felix Http Whiteboard (2.0.4)
+Apache Felix iPOJO (1.8.0, ...)
+Apache Felix iPOJO (0.8.0)
+Apache Felix iPOJO API (1.6.0, ...)
+Apache Felix iPOJO Arch Command (1.6.0, ...)
+Apache Felix iPOJO Composite (1.8.0, ...)
+Apache Felix iPOJO Composite (1.0.0, ...)
+Apache Felix iPOJO Event Admin Handler (1.6.0, ...)
+Apache Felix iPOJO Extender Pattern Handler (1.4.0, ...)
+Apache Felix iPOJO Extender Pattern Handler (1.0.0, ...)
+Apache Felix iPOJO Gogo Command (1.0.1, ...)
+Apache Felix iPOJO JMX Handler (1.4.0, ...)
+Apache Felix iPOJO Temporal Service Dependency Handler (1.6.0,
+Apache Felix iPOJO URL Handler (1.6.0, ...)
+Apache Felix iPOJO WebConsole Plugins (1.6.0, ...)
+Apache Felix iPOJO White Board Pattern Handler (1.2.0, ...)
+Apache Felix iPOJO White Board Pattern Handler (1.4.0)
+Apache Felix Log Service (1.0.0)
+Apache Felix Metatype Service (1.0.2, ...)
+Apache Felix Prefrences Service (1.0.2)
+Apache Felix Remote Shell (1.0.4, ...)
+Apache Felix Remote Shell (1.1.2, ...)
+Apache Felix Shell Service (1.4.2, ...)
+Apache Felix Shell TUI (1.4.1, ...)
+Apache Felix UPnP Base Driver (0.8.0)
+Apache Felix UPnP Extra (0.4.0)
+Apache Felix UPnP Tester (0.4.0)
+Apache Felix Web Console Event Plugin (1.0.2)
+Apache Felix Web Console Memory Usage Plugin (1.0.0)
+Apache Felix Web Console Memory Usage Plugin (1.0.2)
+Apache Felix Web Console UPnP Plugin (1.0.0)
+Apache Felix Web Management Console (3.1.2, ...)
+Apache Felix Web Management Console (3.1.2, ...)
+Apache Tuscany Java Interface for JAXWS (2.0.0)
+Apache Tuscany Launcher (2.0.0)
+Apache Tuscany Python Implementation Model (2.0.0)
+Apache Tuscany SCA API (2.0.0)
+Apache Tuscany SCA Assembly Model (2.0.0)
+Apache Tuscany SCA Assembly Model XML Schemas (2.0.0)
+Apache Tuscany SCA Atom Feed Binding Extension (2.0.0)
+Apache Tuscany SCA BPEL Implementation Model (2.0.0)
+Apache Tuscany SCA Client Impl (2.0.0)
+Apache Tuscany SCA Comet Binding Model (2.0.0)
+Apache Tuscany SCA Common HTTP (2.0.0)
+Apache Tuscany SCA Common Java (2.0.0)
+Apache Tuscany SCA Common XML (2.0.0)
+Apache Tuscany SCA Contribution Model (2.0.0)
+Apache Tuscany SCA CORBA Binding Extension (2.0.0)
+Apache Tuscany SCA CORBA Host Extension Point (2.0.0)
+Apache Tuscany SCA Core Runtime (2.0.0)
+Apache Tuscany SCA Core SPI (2.0.0)
+Apache Tuscany SCA Core/DataBinding Integration (2.0.0)
+Apache Tuscany SCA Data API (2.0.0)
+Apache Tuscany SCA Data Binding for JAXB (2.0.0)
+Apache Tuscany SCA DataBinding Framework (2.0.0)
+Apache Tuscany SCA Default Binding Model (2.0.0)
+Apache Tuscany SCA Deployment (2.0.0)
+Apache Tuscany SCA EJB Binding Model (2.0.0)
+Apache Tuscany SCA Extensibility (2.0.0)
+Apache Tuscany SCA HTTP Binding Model (2.0.0)
+Apache Tuscany SCA HTTP Servlet Host Extension Point (2.0.0)
+Apache Tuscany SCA Java Implementation Model (2.0.0)
+Apache Tuscany SCA Java Implementation Model (2.0.0)
+Apache Tuscany SCA Java Interface Model (2.0.0)
+Apache Tuscany SCA JAX-RS Implementation Model (2.0.0)
+Apache Tuscany SCA JAXWS RI based WS Binding Extension (2.0.0)
+Apache Tuscany SCA JAXWS-based WS Binding Extension (2.0.0)
+Apache Tuscany SCA Jetty Servlet Host Extension (2.0.0)
+Apache Tuscany SCA JMS Binding Model (2.0.0)
+Apache Tuscany SCA JSON-RPC Binding Model (2.0.0)
+Apache Tuscany SCA JSONP Binding Model (2.0.0)
+Apache Tuscany SCA Model Builders (2.0.0)
+Apache Tuscany SCA Monitor (2.0.0)
+Apache Tuscany SCA Node API (2.0.0)
+Apache Tuscany SCA Node Implementation (2.0.0)
+Apache Tuscany SCA REST Binding Model (2.0.0)
+Apache Tuscany SCA RMI Binding Model (2.0.0)
+Apache Tuscany SCA Script Implementation Model (2.0.0)
+Apache Tuscany SCA Shell (2.0.0)
+Apache Tuscany SCA Spring Implementation Model (2.0.0)
+Apache Tuscany SCA Web Implementation Web Model (2.0.0)
+Apache Tuscany SCA Web Implementation Web Runtime (2.0.0)
+Apache Tuscany SCA Web Service binding WSDL Generator (2.0.0)
+Apache Tuscany SCA Webapp Host (2.0.0)
+Apache Tuscany SCA Widget Implementation Model (2.0.0)
+Apache Tuscany SCA Wink (2.0.0)
+Apache Tuscany SCA WS Binding Model (2.0.0)
+Apache Tuscany SCA WSDL Interface Model (2.0.0)
+Apache Tuscany SCA XML Assembly Model (2.0.0)
+Apache Tuscany SCA XSD Model (2.0.0)
+Apache Tuscany Security Policy Model (2.0.0)
+asm.asm (3.1.0)
+cglib.cglib (2.2.0)
+jsr311-api (1.1.1)
+OSGi OBR Service API (1.0.0)
+OSGi R4 Compendium Bundle (4.0.0)
+Servlet 2.1 API (1.0.0)
+wsdl4j.wsdl4j (1.6.2)
+XmlSchema (1.4.3)
+
+obr:repos list
+
+file:/D:/sca-java-2.x/unreleased/testing/itest/bundle/target/repository.xml
+http://felix.apache.org/obr/releases.xml
+
+
+//install file:///D:/sca-java-2.x/modules/sca-api/target/tuscany-sca-api-2.0-SNAPSHOT.jar
+//start #
+
+install file:///D:/sca-java-2.x/unreleased/testing/itest/bundle/target/bundle-2.0-SNAPSHOT.jar
+start #
+
+
+// Create repository.xml for a maven resource or repository
+
+mvn org.apache.felix:maven-bundle-plugin:2.1.0:install-file -DpomFile=pom.xml -Dfile=target\bundle-2.0-SNAPSHOT.jar
+mvn org.apache.felix:maven-bundle-plugin:2.1.0:install-file -DpomFile=pom.xml -Dfile=target\tuscany-sca-api-2.0-SNAPSHOT.jar
+
+mvn org.apache.felix:maven-bundle-plugin:2.1.0:index -DurlTemplate=maven
+~/.m2/repository/repository.xml
+
+
+// problems getting OBR to work
+
+g! obr:info "Apache Tuscany SCA API"
+----------------------
+Apache Tuscany SCA API
+----------------------
+id: org.apache.tuscany.sca.api/2.0.0
+symbolicname: org.apache.tuscany.sca.api
+presentationname: Apache Tuscany SCA API
+uri: file:/D:/sca-java-2.x/unreleased/testing/itest/bundle/target/../../../../..
+/distribution/all/target/modules/tuscany-sca-api-2.0-SNAPSHOT.jar
+version: 2.0.0
+Requires:
+ (&(package=org.oasisopen.sca.annotation)(version>=2.0.0))
+ (&(package=org.oasisopen.sca)(version>=2.0.0))
+ (&(package=org.oasisopen.sca.client)(version>=2.0.0))
+ (&(package=javax.security.auth))
+Capabilities:
+ {symbolicname=org.apache.tuscany.sca.api, presentationname=Apache Tuscany SCA
+ API, bundle-manifestversion=2, version=2.0.0}
+ {bundle-version=2.0.0, package=org.oasisopen.sca, bundle-symbolic-name=org.ap
+ache.tuscany.sca.api, uses:=javax.security.auth, version=2.0.0}
+ {bundle-version=2.0.0, package=org.oasisopen.sca.annotation, bundle-symbolic-
+name=org.apache.tuscany.sca.api, version=2.0.0}
+ {bundle-version=2.0.0, package=org.oasisopen.sca.client, bundle-symbolic-name
+=org.apache.tuscany.sca.api, version=2.0.0}
+g! lb
+START LEVEL 1
+ ID|State |Level|Name
+ 0|Active | 0|System Bundle (3.0.8)
+ 1|Active | 1|Apache Felix Bundle Repository (1.6.2)
+ 2|Active | 1|Apache Felix Gogo Command (0.8.0)
+ 3|Active | 1|Apache Felix Gogo Runtime (0.8.0)
+ 4|Active | 1|Apache Felix Gogo Shell (0.8.0)
+ 20|Installed | 1|Apache Tuscany SCA iTest Bundle (2.0.0.SNAPSHOT)
+g! start 20
+org.osgi.framework.BundleException: Unresolved constraint in bundle org.apache.t
+uscany.sca.bundle [20]: Unable to resolve 20.0: missing requirement [20.0] packa
+ge; (&(package=org.oasisopen.sca.annotation)(version>=2.0.0))
+g!
+
+
+g! obr:deploy "Apache Tuscany SCA API"
+Target resource(s):
+-------------------
+ Apache Tuscany SCA API (2.0.0)
+
+Deploying...done.
+g! lb
+START LEVEL 1
+ ID|State |Level|Name
+ 0|Active | 0|System Bundle (3.0.8)
+ 1|Active | 1|Apache Felix Bundle Repository (1.6.2)
+ 2|Active | 1|Apache Felix Gogo Command (0.8.0)
+ 3|Active | 1|Apache Felix Gogo Runtime (0.8.0)
+ 4|Active | 1|Apache Felix Gogo Shell (0.8.0)
+ 20|Installed | 1|Apache Tuscany SCA iTest Bundle (2.0.0.SNAPSHOT)
+ 21|Installed | 1|Apache Tuscany SCA API (2.0.0)
+g! start 21
+g! lb
+START LEVEL 1
+ ID|State |Level|Name
+ 0|Active | 0|System Bundle (3.0.8)
+ 1|Active | 1|Apache Felix Bundle Repository (1.6.2)
+ 2|Active | 1|Apache Felix Gogo Command (0.8.0)
+ 3|Active | 1|Apache Felix Gogo Runtime (0.8.0)
+ 4|Active | 1|Apache Felix Gogo Shell (0.8.0)
+ 20|Installed | 1|Apache Tuscany SCA iTest Bundle (2.0.0.SNAPSHOT)
+ 21|Active | 1|Apache Tuscany SCA API (2.0.0)
+g! start 20
+14-Mar-2011 14:31:45 sample.impl.SampleActivator start
+INFO: Starting org.apache.tuscany.sca.bundle [20]
+14-Mar-2011 14:31:45 sample.impl.SampleActivator start
+INFO: Hello Fred Bloggs->null
+
+
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/pom.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/pom.xml new file mode 100644 index 0000000000..4d0dc217b9 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/pom.xml @@ -0,0 +1,265 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>bundle</artifactId>
+ <name>Apache Tuscany SCA iTest Bundle</name>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <tuscany.version>2.0-Beta3-SNAPSHOT</tuscany.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-Beta3-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.api</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.management</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.modeller</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.resolver.obr</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Test dependencies -->
+<!--
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+-->
+
+ <!-- Pax Exam test runtime -->
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>1.2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <version>1.2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <version>1.2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-api</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-service</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-mvn</artifactId>
+ <version>1.2.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- extra bundles that will be loaded -->
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.bundlerepository</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+
+<!--
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <version>1.2.4</version>
+ <scope>test</scope>
+ </dependency>
+-->
+
+ <dependency>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.proxy</groupId>
+ <artifactId>org.apache.aries.proxy</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.runtime</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.default.local.platform</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.runtime.itest.interfaces</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-all</artifactId>
+ <version>3.3.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.2.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.2.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+<!-- create a repositoy.xml file for this bundle
+ <executions>
+ <execution>
+ <id>generate-obr</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>install</goal>
+ </goals>
+ </execution>
+ </executions>
+-->
+ <configuration>
+<!--
+ <obrRepository>target/obr</obrRepository>
+-->
+ <instructions>
+ <Export-Package>sample</Export-Package>
+ <Private-Package>sample.impl</Private-Package>
+ <Bundle-Activator>sample.impl.SampleActivator</Bundle-Activator>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>generate-depends-file</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ <configuration>
+ <outputFile>${project.build.directory}/test-classes/META-INF/maven/dependencies.properties</outputFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..f4e8c50448 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/java/sample/Helloworld.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;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/java/sample/impl/HelloworldImpl.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/java/sample/impl/HelloworldImpl.java new file mode 100644 index 0000000000..0e6d3cb1c7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/java/sample/impl/HelloworldImpl.java @@ -0,0 +1,43 @@ +/*
+ * 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.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+
+import sample.Helloworld;
+
+public class HelloworldImpl implements Helloworld {
+
+ @Reference(required=false)
+ protected Helloworld hwRef;
+
+ @Property
+ protected String componentName;
+
+ public String sayHello(String name) {
+ String returnString = "Hello " + name + "->" + componentName;
+ if (hwRef != null){
+ return hwRef.sayHello(returnString);
+ } else {
+ return returnString;
+ }
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/java/sample/impl/SampleActivator.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/java/sample/impl/SampleActivator.java new file mode 100644 index 0000000000..4838b534db --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/java/sample/impl/SampleActivator.java @@ -0,0 +1,45 @@ +/*
+ * 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.util.logging.Logger;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+import sample.Helloworld;
+
+public class SampleActivator implements BundleActivator {
+ private Logger logger = Logger.getLogger(SampleActivator.class.getName());
+
+
+ public void start(BundleContext context) throws Exception {
+ logger.info("Starting " + context.getBundle());
+
+ Helloworld hw = new HelloworldImpl();
+ logger.info(hw.sayHello("Fred Bloggs"));
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ logger.info("Stopping " + context.getBundle());
+ // Registered services will be automatically unregistered
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..95c32fb5bf --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?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:helloworld-contribution" />
+
+</contribution>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..e3f31ae8d7 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/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.
+
+sample.ImplementationGenericPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#implementationGenericPolicy,model=sample.ImplementationGenericPolicy
+sample.InteractionGenericPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#interactionGenericPolicy,model=sample.InteractionGenericPolicy
+sample.InteractionBindingWSPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#interactionBindingWSPolicy,model=sample.InteractionBindingWSPolicy
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions new file mode 100644 index 0000000000..f362b64a1f --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions @@ -0,0 +1,17 @@ +# 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.
+definitions.xml
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory new file mode 100644 index 0000000000..cbfb70c346 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory @@ -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.InteractionBindingWSPolicyProviderFactory;model=sample.InteractionBindingWSPolicy
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/definitions.xml b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/definitions.xml new file mode 100644 index 0000000000..f37fde76ab --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/definitions.xml @@ -0,0 +1,60 @@ +<?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.
+-->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <intent name="implementation.generic" constrains="implementation">
+ <description>
+ An intent that targets policy interceptors at the implementation
+ </description>
+ </intent>
+
+ <intent name="interaction.generic" constrains="binding">
+ <description>
+ An intent that targets policy interceptors at the binding generically
+ </description>
+ </intent>
+
+ <intent name="interaction.bindingws" constrains="binding.ws">
+ <description>
+ An intent that targets policy interceptors at binding.ws
+ </description>
+ </intent>
+
+ <policySet name="ImplementationGeneric"
+ provides="tuscany:implementation.generic"
+ appliesTo="//implementation">
+ <tuscany:implementationGenericPolicy name="ImplementationGeneric"/>
+ </policySet>
+
+ <policySet name="InteractionGeneric"
+ provides="tuscany:interaction.generic"
+ appliesTo="//binding">
+ <tuscany:interactionGenericPolicy name="InteractionGeneric"/>
+ </policySet>
+
+ <policySet name="InteractionBindingWS"
+ provides="tuscany:interaction.bindingws"
+ appliesTo="//binding.ws">
+ <tuscany:interactionBindingWSPolicy name="InteractionBindingWS"/>
+ </policySet>
+
+</definitions>
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/helloworld.composite b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..47488f8bbd --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/main/resources/helloworld.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"
+ name="helloworld-contribution">
+
+ <component name="HelloworldComponent1">
+ <implementation.java class="sample.HelloworldImpl"/>
+ <reference name="hwRef"
+ target="HelloworldComponent2"
+ requires="tuscany:interaction.bindingws"
+ policySets="tuscany:InteractionBindingWS"/>
+ <property name="componentName" value="HelloworldComponent1"/>
+ </component>
+
+ <component name="HelloworldComponent2">
+ <implementation.java class="sample.HelloworldImpl"/>
+ <service name="Helloworld"
+ requires="tuscany:interaction.bindingws"
+ policySets="tuscany:InteractionBindingWS">
+ <binding.ws/>
+ </service>
+ <reference name="hwRef" target="HelloworldComponent3"/>
+ <property name="componentName" value="HelloworldComponent2"/>
+ </component>
+
+ <component name="HelloworldComponent3">
+ <implementation.java class="sample.HelloworldImpl"/>
+ <property name="componentName" value="HelloworldComponent3"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/test/java/sample/HelloworldTestCase.java new file mode 100644 index 0000000000..4c3f0271fa --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/unreleased/testing/itest/bundle/src/test/java/sample/HelloworldTestCase.java @@ -0,0 +1,216 @@ +/*
+ * 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 org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
+
+import org.apache.aries.application.filesystem.IDirectory;
+import org.apache.aries.application.management.spi.repository.RepositoryGenerator;
+import org.apache.aries.application.modelling.ModelledResourceManager;
+import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.container.def.options.WorkingDirectoryOption;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.util.tracker.ServiceTracker;
+
+/* For debugging, uncomment the next two lines and add these imports:
+ */
+import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+
+
+/**
+ * Note that much of the technical detail/instruction comes from...
+ *
+ * http://svn.apache.org/repos/asf/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java
+ *
+ */
+
+@RunWith( JUnit4TestRunner.class )
+public class HelloworldTestCase {
+
+ public static final long DEFAULT_TIMEOUT = 30000;
+
+ @Inject
+ protected BundleContext bundleContext;
+
+ @Configuration
+ public static Option[] configuration() {
+ Option[] options = options(
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+// mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+ mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+ mavenBundle("asm", "asm-all"),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
+
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform"),
+ mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime"),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
+ mavenBundle("org.osgi", "org.osgi.compendium"),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+
+ mavenBundle("org.apache.tuscany.sca", "tuscany-sca-api"),
+
+ mavenBundle("org.apache.tuscany.sca", "bundle"),
+
+ /* For debugging, uncomment the next two lines
+ vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"),
+ waitForFrameworkStartup(),
+ */
+
+ workingDirectory("D://sca-java-2.x//unreleased//testing//itest//bundle//target"),
+
+ equinox().version("3.5.0"));
+
+ return options;
+ }
+
+ @Test
+ public void testSayHello() {
+ System.out.println("testSayHello - start");
+ System.out.println("test dir = " + System.getProperty("user.dir"));
+ System.out.println("current dir = " + this.getClass().getProtectionDomain().getCodeSource().getLocation());
+
+ // get the OBR repository admin service
+ RepositoryAdmin respositoryAdminService = getOsgiService(RepositoryAdmin.class);
+
+ // print currently registered repos
+ Repository[] repos = respositoryAdminService.listRepositories();
+ System.out.println("initial repos");
+ for (Repository repo : repos) {
+ System.out.println("Repo >>> " + repo.getName());
+ }
+
+ // get the repository generator service
+ System.out.println("get RepositoryGenerator service =");
+ RepositoryGenerator repositoryGenerator = getOsgiService(RepositoryGenerator.class);
+ System.out.println(repositoryGenerator);
+
+ System.out.println("get ModelledResourceManager service =");
+ ModelledResourceManager modelledResourceManager = getOsgiService(ModelledResourceManager.class);
+ System.out.println(modelledResourceManager);
+
+ Set<ModelledResource> mrs = new HashSet<ModelledResource>();
+
+ try {
+ // create mrs based on base runtime
+ populateMRS(modelledResourceManager,
+ mrs,
+ "../../../../../distribution/all/target/features/tuscany-base-runtime-pom/which-jars",
+ "../../../../../distribution/all/target/modules");
+ //File outFile = new File("D://sca-java-2.x//unreleased//testing//itest//bundle//target//myrepository.xml");
+ //File outFile = new File(".//target//myrepository.xml");
+ //FileOutputStream fout = new FileOutputStream(outFile);
+ FileOutputStream fout = new FileOutputStream("repository.xml");
+ repositoryGenerator.generateRepository("Test repo description", mrs, fout);
+ fout.close();
+
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ }
+
+ System.out.println("testSayHello - end");
+ }
+
+ private void populateMRS(ModelledResourceManager modelledResourceManager,
+ Set<ModelledResource> mrs,
+ String whichJars,
+ String modules){
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(whichJars));
+ String line;
+ while ((line = in.readLine()) != null) {
+ if (line.endsWith(".jar")){
+ int dirSeparatorIndex = line.indexOf("/");
+ if (dirSeparatorIndex > 0){
+ line = line.substring(0, dirSeparatorIndex);
+ }
+ System.out.println("Processing - " + line);
+ File bundleFile = new File(modules + "\\" + line);
+ IDirectory jarDir = FileSystem.getFSRoot(bundleFile);
+ mrs.add(modelledResourceManager.getModelledResource(bundleFile.toURI().toString(), jarDir));
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private <T> T getOsgiService(Class<T> type) {
+ try {
+ String filterString = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
+ Filter osgiFilter = FrameworkUtil.createFilter(filterString);
+ ServiceTracker tracker = new ServiceTracker(bundleContext, osgiFilter, null);
+ tracker.open();
+ Object tmp = tracker.waitForService(DEFAULT_TIMEOUT);
+ return type.cast(tmp);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ private static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId) {
+ return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId).versionAsInProject();
+ }
+}
+
+
|