Author: rfeng
Date: Tue Feb 10 21:59:01 2009
New Revision: 743122

URL: http://svn.apache.org/viewvc?rev=743122&view=rev
Log:
Add the SDO version of CreditCardPayment implementation

Added:
    tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/
      - copied from r742792, 
tuscany/sandbox/travelsample/chapter-09/payment-contribution/
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/pom.xml
      - copied, changed from r742796, 
tuscany/sandbox/travelsample/chapter-09/payment-contribution/pom.xml
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/CreditCardPayment.java
   (with props)
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/impl/
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java
   (with props)
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/creditcard.composite
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java
   (with props)
Removed:
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/Payment.java
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/PaymentImpl.java
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/java/payment/PaymentTestCase.java
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentImpl.java
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/resources/payment.composite
Modified:
    
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/CreditCardPayment.wsdl
    tuscany/sandbox/travelsample/chapter-09/pom.xml

Copied: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/pom.xml 
(from r742796, 
tuscany/sandbox/travelsample/chapter-09/payment-contribution/pom.xml)
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/pom.xml?p2=tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/pom.xml&p1=tuscany/sandbox/travelsample/chapter-09/payment-contribution/pom.xml&r1=742796&r2=743122&rev=743122&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/chapter-09/payment-contribution/pom.xml 
(original)
+++ 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/pom.xml 
Tue Feb 10 21:59:01 2009
@@ -25,32 +25,38 @@
         <version>1.4</version>
         <!--relativePath>../../pom.xml</relativePath-->
     </parent>
-    <artifactId>scatours-chapter-09-payment-contribution</artifactId>
-    <name>Apache Tuscany SCA Tours Chapter 09 Payment Contribution</name>
+    
<artifactId>scatours-chapter-09-creditcard-payment-contribution</artifactId>
+    <name>Apache Tuscany SCA Tours Chapter 09 Credit Card Payment 
Contribution</name>
 
     <dependencies>
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-host-embedded</artifactId>
+            <artifactId>tuscany-node-api</artifactId>
             <version>1.4</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <artifactId>tuscany-node-impl</artifactId>
             <version>1.4</version>
             <scope>runtime</scope>
         </dependency>
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
             <version>1.4</version>
             <scope>runtime</scope>
         </dependency>
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-databinding-sdo</artifactId>
+            <version>1.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-binding-ws-axis2</artifactId>
             <version>1.4</version>
             <scope>runtime</scope>
@@ -62,7 +68,7 @@
             <version>1.4</version>
             <scope>runtime</scope>
         </dependency>
-        
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
@@ -73,52 +79,52 @@
     </dependencies>
     <build>
         <finalName>${artifactId}</finalName>
-    <plugins>
-        <plugin>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>build-helper-maven-plugin</artifactId>
-            <version>1.0</version>
-            <executions>
-                <execution>
-                    <id>add-source</id>
-                    <phase>generate-sources</phase>
-                    <goals>
-                        <goal>add-source</goal>
-                    </goals>
-                    <configuration>
-                        <sources>
-                            <source>target/jaxws-source</source>
-                        </sources>
-                    </configuration>
-                </execution>
-            </executions>
-        </plugin>
-        <plugin>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>jaxws-maven-plugin</artifactId>
-            <version>1.9</version>
-            <executions>
-                <execution>
-                    <id>wsimport</id>
-                    <phase>generate-sources</phase>
-                    <goals>
-                        <goal>wsimport</goal>
-                    </goals>
-                    <configuration>
-                        <packageName>payment.creditcard</packageName>
-                        <wsdlDirectory>${basedir}/src/main/resources
-                        </wsdlDirectory>
-                        <wsdlFiles>
-                            <wsdlFile>CreditCardPayment.wsdl</wsdlFile>
-                        </wsdlFiles>
-                        <sourceDestDir>${project.build.directory}/jaxws-source
-                        </sourceDestDir>
-                        <verbose>false</verbose>
-                        <xnocompile>true</xnocompile>
-                    </configuration>
-                </execution>
-            </executions>
-        </plugin>
-    </plugins>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.0</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>target/sdo-source</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.tuscany.sdo</groupId>
+                <artifactId>tuscany-sdo-plugin</artifactId>
+                <version>1.1.1</version>
+                <executions>
+                    <execution>
+                        <id>generate-sdo</id>
+                        <phase>generate-sources</phase>
+                        <configuration>
+                            <schemaFile>
+                                
${basedir}/src/main/resources/CreditCardPayment.wsdl
+                            </schemaFile>
+                            <javaPackage>payment.creditcard</javaPackage>
+                            <prefix>CreditCardPayment</prefix>
+                            <noNotification>true</noNotification>
+                            <noContainer>true</noContainer>
+                            <noUnsettable>true</noUnsettable>
+                        </configuration>
+                        <goals>
+                            <goal>generate</goal>
+                        </goals>
+                    </execution>
+
+                </executions>
+            </plugin>
+
+        </plugins>
     </build>
 </project>

Added: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/CreditCardPayment.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/CreditCardPayment.java?rev=743122&view=auto
==============================================================================
--- 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/CreditCardPayment.java
 (added)
+++ 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/CreditCardPayment.java
 Tue Feb 10 21:59:01 2009
@@ -0,0 +1,39 @@
+
+package payment.creditcard;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+
+/**
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.1.3-b02-
+ * Generated source version: 2.1
+ * 
+ */
+...@webservice(name = "CreditCardPayment", targetNamespace = 
"http://www.example.org/CreditCardPayment/";)
+public interface CreditCardPayment {
+
+
+    /**
+     * 
+     * @param amount
+     * @param creditCard
+     * @return
+     *     returns java.lang.String
+     */
+    @WebMethod(action = "http://www.example.org/CreditCardPayment/authorize";)
+    @WebResult(name = "Status", targetNamespace = "")
+    @RequestWrapper(localName = "authorize", targetNamespace = 
"http://www.example.org/CreditCardPayment/";, className = 
"payment.creditcard.AuthorizeType")
+    @ResponseWrapper(localName = "authorizeResponse", targetNamespace = 
"http://www.example.org/CreditCardPayment/";, className = 
"payment.creditcard.AuthorizeResponseType")
+    public String authorize(
+        @WebParam(name = "CreditCard", targetNamespace = "")
+        CreditCardDetailsType creditCard,
+        @WebParam(name = "Amount", targetNamespace = "")
+        float amount);
+
+}

Propchange: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/CreditCardPayment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/CreditCardPayment.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java?rev=743122&view=auto
==============================================================================
--- 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java
 (added)
+++ 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java
 Tue Feb 10 21:59:01 2009
@@ -0,0 +1,47 @@
+/*
+ * 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 payment.creditcard.impl;
+
+import org.osoa.sca.annotations.Service;
+
+import payment.creditcard.CreditCardDetailsType;
+import payment.creditcard.CreditCardPayment;
+
+/**
+ * 
+ */
+...@service(CreditCardPayment.class)
+public class CreditCardPaymentImpl implements CreditCardPayment {
+    
+    public String authorize(CreditCardDetailsType creditCard, float amount) {
+        if (creditCard != null){
+            System.out.println("Checking card: name = " + 
+                               creditCard.getCardOwner().getName() +
+                               " number = " +
+                               creditCard.getCreditCardNumber() +
+                               " for amount " + 
+                               amount);
+        } else {
+            System.out.println("Checking card is null");
+        }
+        
+        return "OK";
+    }
+}

Propchange: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/CreditCardPayment.wsdl
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/CreditCardPayment.wsdl?rev=743122&r1=742792&r2=743122&view=diff
==============================================================================
--- 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/CreditCardPayment.wsdl
 (original)
+++ 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/CreditCardPayment.wsdl
 Tue Feb 10 21:59:01 2009
@@ -77,7 +77,7 @@
                     <xsd:element name="ZipCode" type="xsd:string" />
                     <xsd:element name="HomePhone" type="xsd:string" />
                 </xsd:sequence>
-            </xsd:complexType>
+            </xsd:complexType> 
         </xsd:schema>
     </wsdl:types>
     <wsdl:message name="AuthorizeRequest">
@@ -109,8 +109,9 @@
             <soap:address location="http://localhost:8080/CreditCardPayment"; />
         </wsdl:port>
     </wsdl:service>
-    
+
     <plnk:partnerLinkType name="CreditCardPaymentLinkType">
         <plnk:role name="forward" portType="tns:CreditCardPayment"/>
-    </plnk:partnerLinkType>    
+    </plnk:partnerLinkType>
+    
 </wsdl:definitions>
\ No newline at end of file

Added: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/creditcard.composite
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/creditcard.composite?rev=743122&view=auto
==============================================================================
--- 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/creditcard.composite
 (added)
+++ 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/main/resources/creditcard.composite
 Tue Feb 10 21:59:01 2009
@@ -0,0 +1,35 @@
+<?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://www.osoa.org/xmlns/sca/1.0"; 
+           targetNamespace="http://creditcard";
+           xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0";
+           xmlns:c="http://creditcard"; 
+           name="creditcard">
+
+    <component name="CreditCardPaymentComponent">
+        <implementation.java 
class="payment.creditcard.impl.CreditCardPaymentImpl" />
+        <service name="CreditCardPayment">
+            <interface.wsdl 
interface="http://www.example.org/CreditCardPayment/#wsdl.interface(CreditCardPayment)"/>
+            <binding.ws uri="http://localhost:8081/CreditCardPayment"; />
+            <binding.sca/>
+        </service>
+    </component>
+    
+</composite>
\ No newline at end of file

Added: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java?rev=743122&view=auto
==============================================================================
--- 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java
 (added)
+++ 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java
 Tue Feb 10 21:59:01 2009
@@ -0,0 +1,86 @@
+/*
+ * 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 payment.creditcard;
+
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class CreditCardPaymentTestCase {
+    private static SCANode node;
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        SCANodeFactory factory = SCANodeFactory.newInstance();
+        node = factory.createSCANodeFromClassLoader("creditcard.composite", 
CreditCardPayment.class.getClassLoader());
+        node.start();
+    }
+    
+    @Test
+    public void testCreditCardPayment() {
+        SCAClient client = (SCAClient) node;
+        CreditCardPayment cc = client.getService(CreditCardPayment.class, 
"CreditCardPaymentComponent/CreditCardPayment");
+        
+        CreditCardPaymentFactory factory = CreditCardPaymentFactory.INSTANCE;
+        CreditCardDetailsType ccDetails = 
factory.createCreditCardDetailsType();
+        ccDetails.setCreditCardType("Visa");
+        ccDetails.setCreditCardNumber("1111-2222-3333-4444");
+        ccDetails.setExpMonth(9);
+        ccDetails.setExpYear(2010);
+        PayerType ccOwner = factory.createPayerType();
+        ccOwner.setName("Fred");
+        ccDetails.setCardOwner(ccOwner);
+        
+        System.out.println(cc.authorize(ccDetails, 100.00f));
+    }
+    
+    @Test
+    @Ignore
+    public void testWaitForInput() {
+        System.out.println("Press a key to end");
+        try {
+            System.in.read();
+        } catch (Exception ex) {
+        }
+        System.out.println("Shutting down");
+    }    
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+        if (node != null) {
+            node.stop();
+            node = null;
+        }
+    }
+
+}

Propchange: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/sandbox/travelsample/chapter-09/creditcard-payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sandbox/travelsample/chapter-09/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/chapter-09/pom.xml?rev=743122&r1=743121&r2=743122&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/chapter-09/pom.xml (original)
+++ tuscany/sandbox/travelsample/chapter-09/pom.xml Tue Feb 10 21:59:01 2009
@@ -39,6 +39,7 @@
                 <module>node</module>
                 <module>ui-contribution</module>
                 <module>payment-contribution</module>
+                <module>creditcard-payment-contribution</module>
             </modules>
         </profile>
 


Reply via email to