You are viewing a plain text version of this content. The canonical link for it is here.
Posted to nuvem-commits@incubator.apache.org by jo...@apache.org on 2011/05/07 22:44:15 UTC
svn commit: r1100647 [1/4] - in /incubator/nuvem/trunk/nuvem-samples:
store-appengine-webapp/ store-appengine-webapp/src/
store-appengine-webapp/src/services/ store-appengine-webapp/war/
store-appengine-webapp/war/META-INF/ store-appengine-webapp/war/W...
Author: johnp
Date: Sat May 7 22:44:12 2011
New Revision: 1100647
URL: http://svn.apache.org/viewvc?rev=1100647&view=rev
Log:
sample applications grouped under a single parent nuvem-samples
Added:
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/README
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/build-dojo.xml
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/pom.xml
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/src/
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/src/services/
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/src/services/CachedShoppingCartManager.java
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/META-INF/
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/META-INF/sca-contribution.xml
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/appengine-web.xml
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/logging.properties
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/web.xml
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.composite
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.css
incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.html
incubator/nuvem/trunk/nuvem-samples/store-assets/
incubator/nuvem/trunk/nuvem-samples/store-assets/META-INF/
incubator/nuvem/trunk/nuvem-samples/store-assets/META-INF/MANIFEST.MF
incubator/nuvem/trunk/nuvem-samples/store-assets/pom.xml
incubator/nuvem/trunk/nuvem-samples/store-assets/src/
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Address.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Cart.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Catalog.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CatalogAggregatorImpl.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverter.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverterImpl.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Event.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/FruitsCatalogImpl.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Item.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Location.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/LocationCode.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Shipment.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/ShipmentException.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/ShipmentObserver.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/ShipmentRegistry.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/ShipmentService.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/ShipmentServiceImpl.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/ShoppingCart.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/ShoppingCartImpl.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/ShoppingCartManager.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Total.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/TrackingCode.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/VegetablesCatalogImpl.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/XMPPShipmentObserver.java
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/resources/
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/resources/META-INF/
incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/resources/META-INF/sca-contribution.xml
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/README
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/pom.xml
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/src/
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/src/Workaround.java
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/war/
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/war/META-INF/
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/war/META-INF/sca-contribution.xml
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/war/WEB-INF/
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/war/WEB-INF/appengine-web.xml
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/war/WEB-INF/logging.properties
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/war/WEB-INF/web.xml
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/war/catalog.composite
incubator/nuvem/trunk/nuvem-samples/store-catalog-appengine-webapp/war/index.html
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/README
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/pom.xml
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/resources/
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/resources/catalog.composite
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/webapp/
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/webapp/META-INF/
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/webapp/META-INF/sca-contribution-generated.xml
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/webapp/WEB-INF/
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/webapp/WEB-INF/geronimo-web.xml
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/webapp/WEB-INF/web.xml
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/src/main/webapp/index.html
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/store.png (with props)
incubator/nuvem/trunk/nuvem-samples/store-catalog-ibmcloud-webapp/store.svg
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/build-dojo.xml
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/pom.xml
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/src/
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/src/Workaround.java
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/META-INF/
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/META-INF/sca-contribution.xml
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/WEB-INF/
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/WEB-INF/appengine-web.xml
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/WEB-INF/logging.properties
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/WEB-INF/web.xml
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/store.composite
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/store.css
incubator/nuvem/trunk/nuvem-samples/store-merger-appengine-webapp/war/store.html
incubator/nuvem/trunk/nuvem-samples/store-standalone/
incubator/nuvem/trunk/nuvem-samples/store-standalone/README
incubator/nuvem/trunk/nuvem-samples/store-standalone/pom.xml
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/launch/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/launch/Launch.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/Cart.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/Catalog.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/CatalogImpl.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/CurrencyConverter.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/CurrencyConverterImpl.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/FruitsCatalogImpl.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/Item.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/ShoppingCartImpl.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/java/services/Total.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/resources/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/resources/store.composite
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/resources/uiservices/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/resources/uiservices/store.css
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/main/resources/uiservices/store.html
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/test/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/test/java/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/test/java/client/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/test/java/client/Shopper.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/test/java/client/ShopperImpl.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/test/java/store/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/test/java/store/StoreTestCase.java
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/test/resources/
incubator/nuvem/trunk/nuvem-samples/store-standalone/src/test/resources/store-client.composite
incubator/nuvem/trunk/nuvem-samples/store-standalone/store.png (with props)
incubator/nuvem/trunk/nuvem-samples/store-standalone/store.svg
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/README
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/README?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/README (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/README Sat May 7 22:44:12 2011
@@ -0,0 +1,11 @@
+Steps to run with Maven
+
+ 1.) "mvn gae:unpack " to unpack appengine SDK.
+
+ 2.) "mvn gae:run" to run the application locally. You can access application using http://localhost:8080/ url.
+
+ 3.) Change the application name in the "appengine-web.xml" file located in store-appengine-webapp/war/WEB-INF directory.
+
+ e.g - <application>yournamedemo1</application>
+
+ 4.) "mvn gae:update" to upload the application.
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/build-dojo.xml
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/build-dojo.xml?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/build-dojo.xml (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/build-dojo.xml Sat May 7 22:44:12 2011
@@ -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>
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/pom.xml?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/pom.xml (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/pom.xml Sat May 7 22:44:12 2011
@@ -0,0 +1,240 @@
+<?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.nuvem</groupId>
+ <artifactId>nuvem-samples</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>store-appengine-webapp</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>Apache Nuvem Cloud Store Scenario</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.nuvem</groupId>
+ <artifactId>store-assets</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.nuvem</groupId>
+ <artifactId>nuvem-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.nuvem</groupId>
+ <artifactId>nuvem-google</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.nuvem</groupId>
+ <artifactId>nuvem-standalone</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>${tuscany.version}</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>
+
+ <!--
+ The maven-gae-plugin. Type "mvn gae:run" to run project, "mvn
+ gae:deploy" to upload to GAE.
+ -->
+ <plugin>
+ <groupId>net.kindleit</groupId>
+ <artifactId>maven-gae-plugin</artifactId>
+ <version>${maven.gae.plugin.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>net.kindleit</groupId>
+ <artifactId>gae-runtime</artifactId>
+ <version>${gae.version}</version>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/src/services/CachedShoppingCartManager.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/src/services/CachedShoppingCartManager.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/src/services/CachedShoppingCartManager.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/src/services/CachedShoppingCartManager.java Sat May 7 22:44:12 2011
@@ -0,0 +1,210 @@
+/*
+ * 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.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+import net.sf.jsr107cache.Cache;
+import net.sf.jsr107cache.CacheManager;
+
+import org.apache.nuvem.cloud.user.User;
+import org.apache.nuvem.cloud.user.UserService;
+import org.apache.nuvem.cloud.xmpp.JID;
+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.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Scope("COMPOSITE")
+@Service(ShoppingCart.class)
+public class CachedShoppingCartManager implements ShoppingCart {
+ private static final Logger log = Logger.getLogger(CachedShoppingCartManager.class.getName());
+ private static String ANONYMOUS = "anonymous";
+
+ private Cache cache;
+
+ @Reference
+ private ShipmentService shipmentService;
+
+ @Init
+ public void init() {
+ try {
+ cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
+ } catch (Throwable t) {
+ log.log(Level.SEVERE, "Error initialize cache + " + t.getMessage());
+ }
+ }
+
+ @Reference
+ private UserService userService;
+
+ public Entry<String, Item>[] getAll() {
+ Map<String, Item> cart = getUserItems();
+
+ 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 {
+ Map<String, Item> cart = getUserItems();
+
+ Item item = cart.get(key);
+ if (item == null) {
+ throw new NotFoundException(key);
+ } else {
+ return item;
+ }
+ }
+
+ public String post(String key, Item item) {
+ Map<String, Item> cart = getUserItems();
+
+ if (key == null || key.isEmpty()) {
+ key = this.generateItemKey();
+ }
+
+ cart.put(key, item);
+ cache.put(getCartKey(), cart);
+ return key;
+ }
+
+ public void put(String key, Item item) throws NotFoundException {
+ Map<String, Item> cart = getUserItems();
+
+ if (!cart.containsKey(key)) {
+ throw new NotFoundException(key);
+ }
+ cart.put(key, item);
+ cache.put(getCartKey(), cart);
+ }
+
+ public void delete(String key) throws NotFoundException {
+ if (key == null || key.isEmpty()) {
+ cache.remove(getCartKey());
+ } else {
+ Map<String, Item> cart = getUserItems();
+
+ Item item = cart.remove(key);
+ if (item == null) {
+ throw new NotFoundException(key);
+ }
+ cache.put(getCartKey(), cart);
+ }
+ }
+
+ public Entry<String, Item>[] query(String queryString) {
+ throw new UnsupportedOperationException("Operation not supported !");
+ }
+
+ public String getTotal() {
+ double total = 0;
+ String currencySymbol = "";
+ if (cache.containsKey(getCartKey())) {
+ Map<String, Item> cart = getUserItems();
+ if (!cart.isEmpty()) {
+ Item item = cart.values().iterator().next();
+ currencySymbol = item.getCurrencySymbol();
+ }
+ for (Item item : cart.values()) {
+ total += item.getPrice();
+ }
+
+ }
+ return currencySymbol + String.valueOf(total);
+ }
+
+ /**
+ * Utility functions
+ */
+ /*
+ * private ShoppingCart getUserShoppingCart() { String key = getCartKey();
+ * ShoppingCart userCart = (ShoppingCart) cache.get(key); if(userCart ==
+ * null) { userCart = new ShoppingCartImpl(); cache.put(key, userCart); }
+ * return userCart; }
+ */
+
+ private String getUserId() {
+ String userId = null;
+ if (userService != null) {
+ try {
+ User user = userService.getCurrentUser();
+ userId = user.getUserId();
+ } catch (Exception e) {
+ // ignore
+ e.printStackTrace();
+ }
+ }
+ if (userId == null || userId.length() == 0) {
+ userId = ANONYMOUS;
+ }
+ return userId;
+ }
+
+ private String getCartKey() {
+ String cartKey = "cart-" + this.getUserId();
+ return cartKey;
+ }
+
+ private String generateItemKey() {
+ String itemKey = getCartKey() + "-item-" + UUID.randomUUID().toString();
+ return itemKey;
+ }
+
+ private Map<String, Item> getUserItems() {
+ String userCartKey = getCartKey();
+ HashMap<String, Item> cartMap;
+
+ if (!cache.containsKey(userCartKey)) {
+ cartMap = new HashMap<String, Item>();
+ cache.put(userCartKey, cartMap);
+ } else {
+ cartMap = (HashMap<String, Item>)cache.get(userCartKey);
+ }
+
+ return cartMap;
+ }
+
+ @Override
+ public String shipItems(String jid) {
+ List<Item> items = new ArrayList<Item>();
+ items.addAll(getUserItems().values());
+ try {
+ return shipmentService.shipItemsAndRegisterForUpdates(
+ Address.DUMMY_ADDRESS, new JID(jid), items);
+ } catch (ShipmentException e) {
+ return "shipment error";
+ }
+ }
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/META-INF/sca-contribution.xml?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/META-INF/sca-contribution.xml (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/META-INF/sca-contribution.xml Sat May 7 22:44:12 2011
@@ -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:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:store="http://store">
+
+ <deployable composite="store:store" />
+ <!-- import.java package="services" / -->
+</contribution>
\ No newline at end of file
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/appengine-web.xml
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/appengine-web.xml?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/appengine-web.xml (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/appengine-web.xml Sat May 7 22:44:12 2011
@@ -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>exodusstores</application>
+ <version>7</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
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/logging.properties
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/logging.properties?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/logging.properties (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/logging.properties Sat May 7 22:44:12 2011
@@ -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 = DEBUG
+
+#tuscany debug messages
+org.apache.tuscany.level = WARNING
+
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/web.xml?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/web.xml (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/WEB-INF/web.xml Sat May 7 22:44:12 2011
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns="http://java.sun.com/xml/ns/javaee"
+xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
+
+ <!-- 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>
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.composite
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.composite?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.composite (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.composite Sat May 7 22:44:12 2011
@@ -0,0 +1,82 @@
+<?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" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:s="http://store" targetNamespace="http://store" name="store">
+
+ <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="/Catalog" />
+ </service>
+ <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>
+ <reference name="shipmentService" target="ShipmentService" />
+ <reference name="documentService" target="DocumentService" />
+ </component>
+
+ <component name="DocumentService">
+ <implementation.java
+ class="org.apache.nuvem.cloud.data.impl.MapDocumentServiceImpl" />
+ <!--
+ implementation.java
+ class="org.apache.nuvem.cloud.data.impl.MemcacheDocumentServiceImpl"/
+ -->
+ </component>
+
+ <component name="UserService">
+ <implementation.java
+ class="org.apache.nuvem.cloud.user.impl.GoogleUserService" />
+ <service name="UserService">
+ <binding.sca name="local" />
+ <tuscany:binding.jsonrpc uri="/User" />
+ </service>
+ </component>
+
+ <component name="XMPPEndpoint">
+ <implementation.java
+ class="org.apache.nuvem.cloud.xmpp.impl.GoogleXMPPEndPoint" />
+ </component>
+
+ <component name="ShipmentObserver">
+ <implementation.java class="services.XMPPShipmentObserver" />
+ <reference name="endpoint" target="XMPPEndpoint" />
+ </component>
+
+ <component name="ShipmentService">
+ <implementation.java class="services.ShipmentServiceImpl" />
+ <reference name="observer" target="ShipmentObserver" />
+ </component>
+
+</composite>
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.css
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.css?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.css (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.css Sat May 7 22:44:12 2011
@@ -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
+ */
+<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
Added: incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.html
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.html?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.html (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-appengine-webapp/war/store.html Sat May 7 22:44:12 2011
@@ -0,0 +1,196 @@
+<!--
+ * 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 Nuvem</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.items().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() {
+ var jid = document.getElementById('jidToNotify').value;
+ alert(jid);
+ 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.shipItems(jid);
+ }
+ 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>
+Enter your JID to recieve instant updates : <input type="text"
+ id="jidToNotify"> <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
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/META-INF/MANIFEST.MF?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/META-INF/MANIFEST.MF (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/META-INF/MANIFEST.MF Sat May 7 22:44:12 2011
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Export-Package: services
+Tool: Bnd-0.0.357
+Bundle-Name: Apache Nuvem Cloud Store Tutorial Assets
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1256186081729
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Nuvem Cloud API
+Import-Package: org.apache.nuvem.cloud.data;version="2.0.0",
+ org.apache.nuvem.cloud.user;version="2.0.0",
+ org.apache.tuscany.sca.data.collection;version="2.0.0",
+ services
+Bundle-SymbolicName: org.apache.nuvem.store.assets
+Bundle-DocURL: http://www.apache.org/
+
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/pom.xml
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/pom.xml?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/pom.xml (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/pom.xml Sat May 7 22:44:12 2011
@@ -0,0 +1,56 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.nuvem</groupId>
+ <artifactId>nuvem-samples</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>store-assets</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <name>Apache Nuvem Cloud Store common assets</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.nuvem</groupId>
+ <artifactId>nuvem-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.nuvem</groupId>
+ <artifactId>nuvem-google</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+
+</project>
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Address.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Address.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Address.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Address.java Sat May 7 22:44:12 2011
@@ -0,0 +1,104 @@
+/*
+ * 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.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+public class Address {
+
+ public static final Address DUMMY_ADDRESS = new Address("245",
+ Location.UNKNOWN, Location.UNKNOWN, Location.UNKNOWN);
+
+ private String door;
+
+ private Location street;
+
+ private Location city;
+
+ private Location country;
+
+ /**
+ * To support tuscany.
+ */
+ public Address() {
+
+ }
+
+ public Address(String door, Location street, Location city, Location country) {
+ this.door = door;
+ this.street = street;
+ this.city = city;
+ this.country = country;
+ }
+
+ public String getDoor() {
+ return door;
+ }
+
+ public void setDoor(String door) {
+ this.door = door;
+ }
+
+ public Location getStreet() {
+ return street;
+ }
+
+ public void setStreet(Location street) {
+ this.street = street;
+ }
+
+ public Location getCity() {
+ return city;
+ }
+
+ public void setCity(Location city) {
+ this.city = city;
+ }
+
+ public Location getCountry() {
+ return country;
+ }
+
+ public void setCountry(Location country) {
+ this.country = country;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ final Address rhs = (Address) o;
+
+ return new EqualsBuilder().append(this.door, rhs.door).append(
+ this.city, rhs.city).append(this.country, rhs.country)
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(door).append(city).append(country)
+ .toHashCode();
+ }
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Cart.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Cart.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Cart.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Cart.java Sat May 7 22:44:12 2011
@@ -0,0 +1,83 @@
+/*
+ * 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.Entry;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+/**
+ * [rfeng] Tuscany cannot handle subclassing Collection<String, Item> to resolve the type variable. As a workaround, we copy all the methods into this interface directly
+ */
+public interface Cart {
+ /**
+ * Get the whole collection.
+ *
+ * @return the whole collection.
+ */
+ Entry<String, Item>[] getAll();
+
+ /**
+ * Returns a collection resulting from a query.
+ *
+ * @return the collection.
+ */
+ Entry<String, Item>[] query(String queryString);
+
+ /**
+ * Creates a new item.
+ *
+ * @param key
+ * @param item
+ * @return
+ */
+ String post(String key, Item item);
+
+ /**
+ * Retrieves an item.
+ *
+ * @param key
+ * @return
+ */
+ Item get(String key) throws NotFoundException;
+
+ /**
+ * Updates an item.
+ *
+ * @param key
+ * @param item
+ * @return
+ */
+ void put(String key, Item item) throws NotFoundException;
+
+ /**
+ * Delete an item.
+ *
+ * @param key
+ */
+ void delete(String key) throws NotFoundException;
+
+ /**
+ * Ships the items selected in the shopping cart. this will be called in a
+ * secure manner after the payment process.
+ */
+ String shipItems(String jid);
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Catalog.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Catalog.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Catalog.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Catalog.java Sat May 7 22:44:12 2011
@@ -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[] items();
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CatalogAggregatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CatalogAggregatorImpl.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CatalogAggregatorImpl.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CatalogAggregatorImpl.java Sat May 7 22:44:12 2011
@@ -0,0 +1,76 @@
+/*
+ * 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.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(Catalog.class)
+@Scope("COMPOSITE")
+public class CatalogAggregatorImpl implements Catalog {
+
+ @Property
+ public String currencyCode = "USD";
+
+ @Reference
+ public CurrencyConverter currencyConverter;
+
+ @Reference(required = false)
+ public Catalog fruitsCatalog;
+
+ @Reference(required = false)
+ public Catalog vegetablesCatalog;
+
+ public Item[] items() {
+ String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
+
+ List<Item> catalog = new ArrayList<Item>();
+ if (fruitsCatalog != null) {
+ Item[] fruits = fruitsCatalog.items();
+
+ for (Item item : fruits) {
+ double price = item.getPrice();
+ price = currencyConverter.getConversion("USD", currencyCode, price);
+ catalog.add(new Item(item.getName(), currencyCode, currencySymbol, price));
+ }
+ }
+
+ if (vegetablesCatalog != null) {
+ Item[] vegetables = vegetablesCatalog.items();
+
+ for (Item item : vegetables) {
+ double price = item.getPrice();
+ price = currencyConverter.getConversion("USD", currencyCode, price);
+ catalog.add(new Item(item.getName(), currencyCode, currencySymbol, price));
+ }
+ }
+
+ Item[] catalogArray = new Item[catalog.size()];
+ catalog.toArray(catalogArray);
+
+ return catalogArray;
+ }
+
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverter.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverter.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverter.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverter.java Sat May 7 22:44:12 2011
@@ -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);
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverterImpl.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverterImpl.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/CurrencyConverterImpl.java Sat May 7 22:44:12 2011
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package services;
+
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CurrencyConverter.class)
+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 "?";
+ }
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Event.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Event.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Event.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Event.java Sat May 7 22:44:12 2011
@@ -0,0 +1,132 @@
+/*
+ * 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.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+public class Event {
+
+ private Location loacationBeforeEvent = Location.UNKNOWN;
+
+ private Location loacationAfterEvent = Location.UNKNOWN;
+
+ private Type type;
+
+ private Shipment eventFor;
+
+ private static void generateAndTriggerEvent(Shipment shipment,
+ Location currentLocation, Type type) {
+ Event event = new Event();
+ event.loacationBeforeEvent = shipment.getCurrentLocation();
+ event.loacationAfterEvent = currentLocation;
+ event.type = type;
+ event.eventFor = shipment;
+ shipment.updateStatus(event);
+ }
+
+ public Shipment eventFor() {
+ return eventFor;
+ }
+
+ public static void newShipment(Shipment shipment) {
+ generateAndTriggerEvent(shipment, shipment.getCurrentLocation(), Type.READY);
+ }
+
+ public static void updateShipment(Shipment shipment,
+ Location currentLocation) {
+ generateAndTriggerEvent(shipment, currentLocation, Type.INPROGRESS);
+ }
+
+ public static void triggerCancellation(Shipment shipment,
+ Location currentLocation) {
+ generateAndTriggerEvent(shipment, currentLocation, Type.CANCELED);
+ }
+
+ public static void triggerDeliverySuccessful(Shipment shipment,
+ Location currentLocation) {
+ generateAndTriggerEvent(shipment, currentLocation, Type.DELIVERED);
+ }
+
+ public Type type() {
+ return type;
+ }
+
+ public Location loacationAfterEvent() {
+ return loacationAfterEvent;
+ }
+
+ public Location loacationBeforeEvent() {
+ return loacationBeforeEvent;
+ }
+
+ public static enum Type {
+ READY, INPROGRESS, ONHOLD, CANCELED, DELIVERED;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ final Event rhs = (Event) o;
+
+ return new EqualsBuilder().append(this.loacationBeforeEvent,
+ rhs.loacationBeforeEvent).append(this.loacationAfterEvent,
+ rhs.loacationAfterEvent).append(this.type, rhs.type).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(loacationBeforeEvent).append(
+ loacationBeforeEvent).append(type).toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ String description = null;
+ switch (type) {
+ case READY:
+ description = "shipment ready for the voyage from : "
+ + this.loacationBeforeEvent;
+ break;
+ case INPROGRESS:
+ description = "shipmet moved from location: "
+ + this.loacationBeforeEvent + " to location: "
+ + this.loacationAfterEvent;
+ break;
+ case ONHOLD:
+ description = "shipment put on hold at location: "
+ + this.loacationBeforeEvent;
+ break;
+ case CANCELED:
+ description = "shipment canceled at: " + this.loacationAfterEvent;
+ break;
+ case DELIVERED:
+ description = "shipment delivered to the recipient";
+ }
+ return String.format(
+ "update for Shipment with tracking code: %s -> %s ",
+ this.eventFor.trackingCode(), description);
+ }
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/FruitsCatalogImpl.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/FruitsCatalogImpl.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/FruitsCatalogImpl.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/FruitsCatalogImpl.java Sat May 7 22:44:12 2011
@@ -0,0 +1,60 @@
+/*
+ * 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;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(Catalog.class)
+@Scope("COMPOSITE")
+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", currencyCode, currencySymbol, currencyConverter.getConversion("USD",
+ currencyCode,
+ 2.99)));
+ catalog.add(new Item("Orange", currencyCode, currencySymbol, currencyConverter.getConversion("USD",
+ currencyCode,
+ 3.55)));
+ catalog.add(new Item("Pear", currencyCode, currencySymbol, currencyConverter.getConversion("USD",
+ currencyCode,
+ 1.55)));
+ }
+
+ public Item[] items() {
+ Item[] catalogArray = new Item[catalog.size()];
+ catalog.toArray(catalogArray);
+ return catalogArray;
+ }
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Item.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Item.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Item.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Item.java Sat May 7 22:44:12 2011
@@ -0,0 +1,73 @@
+/*
+ * 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.io.Serializable;
+
+public class Item implements Serializable {
+ private static final long serialVersionUID = -5847326138627338217L;
+
+ private String name;
+ private String currencyCode;
+ private String currencySymbol;
+ private double price;
+
+ public Item() {
+ }
+
+ public Item(String name, String currencyCode, String currencySymbol, double price) {
+ this.name = name;
+ this.currencyCode = currencyCode;
+ this.currencySymbol = currencySymbol;
+ this.price = price;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getCurrencyCode() {
+ return this.currencyCode;
+ }
+
+ public void setCurrencyCode(String currencyCode) {
+ this.currencyCode = currencyCode;
+ }
+
+ public String getCurrencySymbol() {
+ return this.currencySymbol;
+ }
+
+ public void setCurrencySymbol(String currencySymbol) {
+ this.currencySymbol = currencySymbol;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Location.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Location.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Location.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/Location.java Sat May 7 22:44:12 2011
@@ -0,0 +1,83 @@
+/*
+ * 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 Location {
+
+ public static final Location UNKNOWN = new Location("unknown",
+ LocationCode.DUMMY);
+
+ private LocationCode code;
+
+ private String name;
+
+ /**
+ * To support tuscany.
+ */
+ public Location() {
+
+ }
+
+ public Location(String name, LocationCode code) {
+ if (code == null)
+ throw new IllegalArgumentException("location code cannot be null");
+ this.code = code;
+ this.name = name;
+ }
+
+ public LocationCode getCode() {
+ return code;
+ }
+
+ public void setCode(LocationCode code) {
+ this.code = code;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ final Location other = (Location) o;
+
+ return other.code != null && other.code.equals(this.code);
+ }
+
+ @Override
+ public int hashCode() {
+ return code.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return this.code.code();
+ }
+}
Added: incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/LocationCode.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/LocationCode.java?rev=1100647&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/LocationCode.java (added)
+++ incubator/nuvem/trunk/nuvem-samples/store-assets/src/main/java/services/LocationCode.java Sat May 7 22:44:12 2011
@@ -0,0 +1,66 @@
+/*
+ * 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;
+
+/**
+ * Holds the unique location codes
+ *
+ */
+public class LocationCode {
+
+ public static final LocationCode DUMMY = new LocationCode("EX31617");
+ private String code;
+
+ /**
+ * To support tuscany.
+ */
+ public LocationCode() {
+
+ }
+
+ public LocationCode(String code) {
+ if (code == null)
+ throw new IllegalArgumentException(
+ "code cannot be null for constructing location code");
+ this.code = code;
+ }
+
+ public String code() {
+ return code;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ final LocationCode other = (LocationCode) o;
+
+ return other.code != null && other.code.equals(this.code);
+ }
+
+ @Override
+ public int hashCode() {
+ return code.hashCode();
+ }
+}