diff options
Diffstat (limited to 'sandbox')
14 files changed, 781 insertions, 12 deletions
diff --git a/sandbox/sca-cloud-tutorial/pom.xml b/sandbox/sca-cloud-tutorial/pom.xml index 1f8d1dad5e..d69a32a0c6 100644 --- a/sandbox/sca-cloud-tutorial/pom.xml +++ b/sandbox/sca-cloud-tutorial/pom.xml @@ -42,6 +42,7 @@ <module>cloud-google</module> <module>store-assets</module> <module>store-appengine-webapp</module> + <module>store-merger-appengine-webapp</module> <module>store-catalog-appengine-webapp</module> <module>store-catalog-ibmcloud-webapp</module> <module>expertise-rest-appengine-webapp</module> diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.composite b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.composite index 8705f9a52a..bbd90a63bb 100644 --- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.composite +++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.composite @@ -23,21 +23,13 @@ targetNamespace="http://store" name="catalog"> - <component name="CatalogAggregator"> - <implementation.java class="services.CatalogAggregatorImpl"/> + <component name="Catalog"> + <implementation.java class="services.FruitsCatalogImpl"/> <property name="currencyCode">USD</property> <service name="Catalog"> <interface.java interface="services.Catalog"/> - <tuscany:binding.jsonrpc uri="/CatalogAggregator"/> + <tuscany:binding.jsonrpc uri="/Catalog"/> </service> - <reference name="fruitsCatalog"> - <interface.java interface="services.Catalog"/> - <tuscany:binding.jsonrpc uri="http://tuscany-store-catalog.appspot.com/Catalog"/> - </reference> - <reference name="vegetablesCatalog"> - <interface.java interface="services.Catalog"/> - <tuscany:binding.jsonrpc uri="http://tuscany.figueiredos.com/store-catalog-ibmcloud-webapp/Catalog"/> - </reference> <reference name="currencyConverter" target="CurrencyConverter" /> </component> diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html index 0afe661540..aadb4ebd4f 100644 --- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html +++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html @@ -33,7 +33,7 @@ var userServices = new dojo.rpc.JsonService("/User?smd"); - var catalog = new dojo.rpc.JsonService("/CatalogAggregator?smd"); + var catalog = new dojo.rpc.JsonService("/Catalog?smd"); var shoppingCart = new dojo.rpc.JsonService("/ShoppingCart?smd"); diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/build-dojo.xml b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/build-dojo.xml new file mode 100644 index 0000000000..4708b1bcea --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/build-dojo.xml @@ -0,0 +1,92 @@ +<?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 name="DojoZipInstaller"> + + + <property name="dojo.version" value="1.3.0"/> + <property name="unpack.location" value="${basedir}/war/dojo"/> + + + <target name="check-dojo-installed"> + <condition property="already.installed" > + <available file="${localRepository}/dojo/dojo/${dojo.version}/dojo-${dojo.version}.zip"/> + </condition> + <condition property="maven.suffix" value=""> + <os family="unix"/> + </condition> + <condition property="maven.suffix" value=".bat"> + <os family="windows"/> + </condition> + </target> + + + <target name="check-dojo-unpacked"> + <condition property="already.unpacked" > + <available file="${unpack.location}"/> + </condition> + </target> + + <target name="install-dojo" depends="check-dojo-installed" unless="already.installed"> + <mkdir dir="${basedir}/target/dojo-download/"/> + <get src="http://download.dojotoolkit.org/release-${dojo.version}/dojo-release-${dojo.version}.zip" + dest="${basedir}/target/dojo-download/dojo-release-${dojo.version}.zip" + verbose="true" + usetimestamp="true"/> + <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false"> + <arg line="install:install-file -DgroupId=dojo -DartifactId=dojo -Dversion=${dojo.version} -Dpackaging=zip -DgeneratePom=true -Dfile=${basedir}/target/dojo-download/dojo-release-${dojo.version}.zip"/> + </exec> + </target> + + <target name="install-dojo-nomaven" depends="check-dojo-installed" unless="already.installed"> + <mkdir dir="${basedir}/target/dojo-download/"/> + <get src="http://download.dojotoolkit.org/release-${dojo.version}/dojo-release-${dojo.version}.zip" + dest="${basedir}/target/dojo-download/dojo-release-${dojo.version}.zip" + verbose="true" + usetimestamp="true"/> + <copy file="${basedir}/target/dojo-download/dojo-release-${dojo.version}.zip" + tofile="${localRepository}/dojo/dojo/${dojo.version}/dojo-${dojo.version}.zip"/> + </target> + + + <target name="unpack-dojo-files" depends="check-dojo-installed, check-dojo-unpacked" unless="already.unpacked"> + <fail message="dojo zip file not installed in local repository: ${localRepository}" unless="already.installed"/> + <mkdir dir="${basedir}/target/dojo-unpack-temp/"/> + <unzip src="${localRepository}/dojo/dojo/${dojo.version}/dojo-${dojo.version}.zip" + dest="${basedir}/target/dojo-unpack-temp/" + overwrite="false"> + <patternset> + <include name="dojo-release-${dojo.version}/dojo/**"/> + <exclude name="dojo-release-${dojo.version}/dojo/tests/**"/> + <include name="dojo-release-${dojo.version}/dijit/**"/> + <exclude name="dojo-release-${dojo.version}/dojox/**"/> + <exclude name="dojo-release-${dojo.version}/util/**"/> + </patternset> + </unzip> + <move file="${basedir}/target/dojo-unpack-temp/dojo-release-${dojo.version}" + tofile="${unpack.location}" + verbose="true"/> + <delete dir="${basedir}/target/dojo-unpack-temp/"/> + </target> + + + <target name="clean-dojo-files"> + <delete dir="${unpack.location}"/> + </target> +</project> diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/pom.xml b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/pom.xml new file mode 100644 index 0000000000..509ce68f91 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/pom.xml @@ -0,0 +1,216 @@ +<?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-sca</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>store-merger-appengine-webapp</artifactId> + <packaging>war</packaging> + <name>Apache Tuscany Store</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>store-assets</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-cloud-api</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-cloud-google</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-jsonrpc-runtime</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-webapp</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-jaxb</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-java-jaxws</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <sourceDirectory>src</sourceDirectory> + <outputDirectory>war/WEB-INF/classes</outputDirectory> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <configuration> + <sourceIncludes> + <sourceInclude>**/*</sourceInclude> + </sourceIncludes> + + <projectnatures> + <projectnature>org.eclipse.jdt.core.javanature</projectnature> + <projectnature>com.google.appengine.eclipse.core.gaeNature</projectnature> + <projectnature>com.google.gdt.eclipse.core.webAppNature</projectnature> + </projectnatures> + <buildcommands> + <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand> + <buildcommand>com.google.appengine.eclipse.core.enhancerbuilder</buildcommand> + <buildcommand>com.google.appengine.eclipse.core.projectValidator</buildcommand> + <buildcommand>com.google.gdt.eclipse.core.webAppProjectValidator</buildcommand> + </buildcommands> + <classpathContainers> + <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer> + <classpathContainer>com.google.appengine.eclipse.core.GAE_CONTAINER</classpathContainer> + </classpathContainers> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <!-- version>1.1</version --> + <dependencies> + <dependency> + <groupId>ant</groupId> + <artifactId>ant-trax</artifactId> + <version>1.6.5</version> + </dependency> + </dependencies> + <executions> + <execution> + <id>install-dojo</id> + <phase>validate</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <ant antfile="./build-dojo.xml" target="install-dojo"> + <property name="localRepository" value="${settings.localRepository}" /> + </ant> + </tasks> + </configuration> + </execution> + <execution> + <id>copy-dojo-files</id> + <phase>generate-resources</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <ant antfile="./build-dojo.xml" target="unpack-dojo-files"> + <property name="localRepository" value="${settings.localRepository}" /> + <property name="artifactId" value="${artifactId}" /> + </ant> + </tasks> + </configuration> + </execution> + <execution> + <id>clean-dojo-files</id> + <phase>clean</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <ant antfile="./build-dojo.xml" target="clean-dojo-files"> + <property name="localRepository" value="${settings.localRepository}" /> + <property name="artifactId" value="${artifactId}" /> + </ant> + </tasks> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.1</version> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>process-sources</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>war/WEB-INF/lib</outputDirectory> + <overWriteIfNewer>true</overWriteIfNewer> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>2.1-beta-1</version> + <configuration> + <warSourceDirectory>war</warSourceDirectory> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/src/Workaround.java b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/src/Workaround.java new file mode 100644 index 0000000000..2f345ecedd --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/src/Workaround.java @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class Workaround { + +} diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/META-INF/sca-contribution.xml b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..f3b6c89fe0 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/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/200903" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + xmlns:store="http://store"> + + <deployable composite="store:catalog" /> + <!-- import.java package="services" / --> +</contribution>
\ No newline at end of file diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/appengine-web.xml b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/appengine-web.xml new file mode 100644 index 0000000000..0e5f6fc072 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/appengine-web.xml @@ -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. +--> +<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> + <application>tuscany-store-merger</application> + <version>1</version> + + <!-- Configure java.util.logging --> + <system-properties> + <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> + </system-properties> + +</appengine-web-app>
\ No newline at end of file diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/logging.properties b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/logging.properties new file mode 100644 index 0000000000..bd3b8308fc --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/logging.properties @@ -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. +# +# +# A default java.util.logging configuration. +# (All App Engine logging is through java.util.logging by default). +# +# To use this configuration, copy it into your application's WEB-INF +# folder and add the following to your appengine-web.xml: +# +# <system-properties> +# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> +# </system-properties> +# + +# Set the default logging level for all loggers to WARNING +.level = WARNING + +#tuscany debug messages +org.apache.tuscany.level = WARNING + diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/web.xml b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/web.xml new file mode 100644 index 0000000000..31fc39a160 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/web.xml @@ -0,0 +1,42 @@ +<?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. +--> +<!DOCTYPE web-app + PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd"> + +<web-app> + + <!-- Tuscany Filter --> + <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> + + <!-- Default page to serve --> + <welcome-file-list> + <welcome-file>store.html</welcome-file> + </welcome-file-list> + +</web-app> diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/log4j.properties b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/log4j.properties new file mode 100644 index 0000000000..036b48afd7 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/log4j.properties @@ -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. +# +# + +# Configure the console as our one appender +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n + +#tuscany debug messages +log4j.category.org.apache.tuscany=ALL,A1 diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.composite b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.composite new file mode 100644 index 0000000000..5671c81f1a --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.composite @@ -0,0 +1,68 @@ +<?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/200903" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + xmlns:s="http://store" + targetNamespace="http://store" + name="catalog"> + + <component name="CatalogAggregator"> + <implementation.java class="services.CatalogAggregatorImpl"/> + <property name="currencyCode">USD</property> + <service name="Catalog"> + <interface.java interface="services.Catalog"/> + <tuscany:binding.jsonrpc uri="/Catalog"/> + </service> + <reference name="fruitsCatalog"> + <interface.java interface="services.Catalog"/> + <tuscany:binding.jsonrpc uri="http://tuscany-store-catalog.appspot.com/Catalog"/> + </reference> + <reference name="vegetablesCatalog"> + <interface.java interface="services.Catalog"/> + <tuscany:binding.jsonrpc uri="http://tuscany.figueiredos.com/store-catalog-ibmcloud-webapp/Catalog"/> + </reference> + <reference name="currencyConverter" target="CurrencyConverter" /> + </component> + + <component name="CurrencyConverter"> + <implementation.java class="services.CurrencyConverterImpl" /> + <service name="CurrencyConverter"> + <interface.java interface="services.CurrencyConverter"/> + </service> + </component> + + <component name="ShoppingCartManager"> + <implementation.java class="services.ShoppingCartManager"/> + <service name="ShoppingCart"> + <tuscany:binding.jsonrpc uri="/ShoppingCart"/> + </service> + <reference name="userService" target="UserService"> + <binding.sca name="local"/> + </reference> + </component> + + <component name="UserService"> + <implementation.java class="org.apache.tuscany.sca.cloud.user.impl.GoogleUserService"/> + <service name="UserService"> + <binding.sca name="local"/> + <tuscany:binding.jsonrpc uri="/User"/> + </service> + </component> +</composite> diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.css b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.css new file mode 100644 index 0000000000..0b1d541bea --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.css @@ -0,0 +1,22 @@ +<style type="text/css"> + +html, body { + height:100%; + margin:0; + overflow:hidden; + width:100%; +} + +.header { + font-size:13px; + text-align:right; + color:#CCCCCC; + + + padding:5px 5px 0; + padding-right:8px; + padding-top:0px !important; + padding-bottom: 0px; + border-bottom: 1px solid black; +} +</style>
\ No newline at end of file diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.html b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.html new file mode 100644 index 0000000000..aadb4ebd4f --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.html @@ -0,0 +1,194 @@ +<!-- + * 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> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Online Store - Powered by Apache Tuscany</title> + +<link href="store.css" rel="stylesheet" type="text/css"> + +<script type="text/javascript" src="dojo/dojo/dojo.js"></script> + +<script type="text/javascript"> + dojo.require("dojo.rpc.JsonService"); +</script> + +<script language="JavaScript"> + + var userServices = new dojo.rpc.JsonService("/User?smd"); + + var catalog = new dojo.rpc.JsonService("/Catalog?smd"); + + var shoppingCart = new dojo.rpc.JsonService("/ShoppingCart?smd"); + + var userContext; + + var catalogItems; + + function showHeader() { + var userContextCallback = function(context) { + userContext = context; + //alert(userContext.userId + " --> " + userContext.loginUrl); + + var html=''; + if(! userContext.userId) { + html = "<a href='" + userContext.loginUrl +"'>Login</a>"; + } else { + html = userContext.email + " | <a href='" + userContext.logoutUrl +"'> Logout</a>"; + } + + document.getElementById('appHeader').innerHTML = html; + } + + userServices.getUserContext(document.URL, "").addCallback(userContextCallback); + } + + function showCatalogs() { + var catalogCallback = function(items) { + var catalog = ""; + for (var i=0; i<items.length; i++) { + var item = items[i].name + ' - ' + items[i].currencySymbol + items[i].price; + catalog += '<input name="items" type="checkbox" value="' + + item + '">' + item + ' <br>'; + } + document.getElementById('catalog').innerHTML=catalog; + catalogItems = items; + } + + catalog.get().addCallback(catalogCallback); + } + + + // This handles the response from shoppingCart.getAll + // which is a collection of Entry<K,D> + function shoppingCart_getResponse(items) { + var list=''; + for (var i=0; i<items.length; i++) { + //get the actual item, that is Entry.data + var item = items[i].data; + // process its attributes + var name = item.name; + var symbol = item.currencySymbol; + var price = item.price + list += name + ' - ' + symbol + price + ' <br>'; + } + document.getElementById("shoppingCart").innerHTML = list; + + if (items.length != 0) { + try { + shoppingCart.getTotal().addCallback(shoppingCart_getTotalResponse); + } + catch(e){ + alert(e); + } + } + } + + function shoppingCart_getTotalResponse(total,exception) { + if(exception) { + alert(exception.message); + return; + } + document.getElementById('total').innerHTML = total; + } + + function shoppingCart_postResponse(entry) { + shoppingCart.getAll().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) { + shoppingCart.post("", catalogItems[i]).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.delete(""); + } + function deleteCart() { + shoppingCart.delete(""); + document.getElementById('shoppingCart').innerHTML = ""; + document.getElementById('total').innerHTML = ""; + } + + + + function init() { + try { + showHeader(); + + showCatalogs(); + + shoppingCart.getAll().addCallback(shoppingCart_getResponse); + } catch (e) { + alert(e); + } + } + + +</script> + +</head> + +<body onload="init()"> + <div id="appHeader" class="header"> + </div> + + <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"> + </form> + </div> +</body> + +</html>
\ No newline at end of file |