diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-01 19:00:22 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-01 19:00:22 +0000 |
commit | 38ebe24c08241e09ac0c1c5e257a25583a868566 (patch) | |
tree | dffd176567c83812f03df4cc7cd658e4f5a25e7d /sandbox/travelsample/contrib/chapter-09 | |
parent | 066ce9d3b6b12a8523c5ce208673bcbc8e6a8de6 (diff) |
Move redundant modules into contrib
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@780781 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/travelsample/contrib/chapter-09')
27 files changed, 2364 insertions, 0 deletions
diff --git a/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/pom.xml b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/pom.xml new file mode 100644 index 0000000000..9388e4e3fb --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/pom.xml @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>1.6-SNAPSHOT</version> + <!--relativePath>../../pom.xml</relativePath--> + </parent> + <artifactId>scatours-chapter-09-creditcard-payment-sdo-contribution</artifactId> + <name>Apache Tuscany SCA Tours Chapter 09 SDO-based Credit Card Payment Contribution</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-api</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-impl</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-sdo</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-axis2</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-jetty</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + + </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/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> diff --git a/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/java/payment/creditcard/CreditCardPayment.java b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/java/payment/creditcard/CreditCardPayment.java new file mode 100644 index 0000000000..5b333648f4 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/java/payment/creditcard/CreditCardPayment.java @@ -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); + +} diff --git a/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java new file mode 100644 index 0000000000..178268eac1 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java @@ -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"; + } +} diff --git a/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/resources/CreditCardPayment.wsdl b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/resources/CreditCardPayment.wsdl new file mode 100644 index 0000000000..f73279e7d8 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/resources/CreditCardPayment.wsdl @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions name="CreditCardPayment"
+ targetNamespace="http://www.example.org/CreditCardPayment/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://www.example.org/CreditCardPayment/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+ <wsdl:types>
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.example.org/CreditCardPayment/"
+ xmlns:tns="http://www.example.org/CreditCardPayment/">
+
+ <xsd:element name="authorize" type="tns:AuthorizeType"/>
+ <xsd:complexType name="AuthorizeType">
+ <xsd:sequence>
+ <xsd:element name="CreditCard" type="tns:CreditCardDetailsType"></xsd:element>
+ <xsd:element name="Amount" type="xsd:float"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="authorizeResponse" type="tns:AuthorizeResponseType"/>
+ <xsd:complexType name="AuthorizeResponseType">
+ <xsd:sequence>
+ <xsd:element name="Status" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="CreditCardDetailsType">
+ <xsd:sequence>
+ <xsd:element name="CreditCardType" type="tns:CreditCardTypeType" minOccurs="0" />
+ <xsd:element name="CreditCardNumber" type="xsd:string" minOccurs="0" />
+ <xsd:element name="ExpMonth" type="xsd:int" minOccurs="0" />
+ <xsd:element name="ExpYear" type="xsd:int" minOccurs="0" />
+ <xsd:element name="CardOwner" type="tns:PayerType" minOccurs="0" />
+ <xsd:element name="CVV2" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:simpleType name="CreditCardTypeType">
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="Visa" />
+ <xsd:enumeration value="MasterCard" />
+ <xsd:enumeration value="Discover" />
+ <xsd:enumeration value="Amex" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <xsd:complexType name="PayerType">
+ <xsd:sequence>
+ <xsd:element name="Name" type="xsd:string" />
+ <xsd:element name="Address" type="tns:AddressType" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AddressType">
+ <xsd:sequence>
+ <xsd:element name="Street" type="xsd:string" />
+ <xsd:element name="City" type="xsd:string" />
+ <xsd:element name="State" type="xsd:string" />
+ <xsd:element name="ZipCode" type="xsd:string" />
+ <xsd:element name="HomePhone" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types> + <wsdl:message name="AuthorizeRequest">
+ <wsdl:part name="parameters" element="tns:authorize"></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="AuthorizeResponse">
+ <wsdl:part name="parameters" element="tns:authorizeResponse"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="CreditCardPayment">
+ <wsdl:operation name="authorize">
+ <wsdl:input message="tns:AuthorizeRequest"></wsdl:input>
+ <wsdl:output message="tns:AuthorizeResponse"></wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CreditCardPaymentBinding" type="tns:CreditCardPayment">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="authorize">
+ <soap:operation soapAction="http://www.example.org/CreditCardPayment/authorize" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CreditCardPaymentService">
+ <wsdl:port name="CreditCardPaymentPort" binding="tns:CreditCardPaymentBinding">
+ <soap:address location="http://localhost:8080/CreditCardPayment" />
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="CreditCardPaymentLinkType">
+ <plnk:role name="forward" portType="tns:CreditCardPayment"/>
+ </plnk:partnerLinkType>
+
+</wsdl:definitions>
\ No newline at end of file diff --git a/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..d22f4816ab --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"> + <export.java package="payment.creditcard"/> + <export.java package="payment.creditcard.impl"/> + <export.java package="payment.creditcard.ws"/> + <export.java package="payment.creditcard.ws.impl"/> +</contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/resources/creditcard.composite b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/resources/creditcard.composite new file mode 100644 index 0000000000..938385dbf9 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/main/resources/creditcard.composite @@ -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 diff --git a/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java new file mode 100644 index 0000000000..041e4e4847 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/creditcard-payment-sdo-contribution/src/test/java/payment/creditcard/CreditCardPaymentTestCase.java @@ -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; + } + } + +} diff --git a/sandbox/travelsample/contrib/chapter-09/node/build.xml b/sandbox/travelsample/contrib/chapter-09/node/build.xml new file mode 100644 index 0000000000..46333e4852 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/node/build.xml @@ -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. +--> + +<project name="scatours-chapter-09-node" default="compile"> + + <target name="compile"> + <mkdir dir="target/classes"/> + <javac destdir="target/classes" debug="on" source="1.5" target="1.5"> + <src path="src\main\java"/> + <classpath> + <fileset refid="tuscany.jars"/> + <fileset refid="3rdparty.jars"/> + </classpath> + </javac> + <copy todir="target/classes"> + <fileset dir="src\main\resources"/> + <fileset dir="src\main\resources"/> + </copy> + <jar destfile="target/scatours-chapter-09-node.jar" basedir="target/classes"> + <manifest> + <attribute name="Main-Class" value="scatours.LaunchNode"/> + </manifest> + </jar> + </target> + + <target name="package" depends="compile"/> + + <target name="run"> + <java classname="scatours.LaunchNode" fork="true"> + <classpath> + <pathelement location="target/scatours-chapter-09-node.jar"/> + <fileset refid="tuscany.jars"/> + <fileset refid="3rdparty.jars"/> + </classpath> + </java> + </target> + + <target name="clean"> + <delete includeemptydirs="true"> + <fileset dir="target"/> + </delete> + </target> + + <fileset id="tuscany.jars" dir="../../modules"> + <include name="tuscany-assembly-1.6-SNAPSHOT.jar"/> + <include name="tuscany-assembly-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-assembly-xsd-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-atom-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-atom-abdera-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-atom-js-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-http-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-http-runtime-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-jsonrpc-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-jsonrpc-runtime-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-sca-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-sca-axis2-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-sca-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-ws-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-ws-axis2-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-ws-axis2-policy-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-ws-wsdlgen-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-ws-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-impl-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-java-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-namespace-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-resource-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-core-1.6-SNAPSHOT.jar"/> + <include name="tuscany-core-databinding-1.6-SNAPSHOT.jar"/> + <include name="tuscany-core-spi-1.6-SNAPSHOT.jar"/> + <include name="tuscany-data-api-1.6-SNAPSHOT.jar"/> + <include name="tuscany-databinding-1.6-SNAPSHOT.jar"/> + <include name="tuscany-databinding-axiom-1.6-SNAPSHOT.jar"/> + <include name="tuscany-databinding-jaxb-1.6-SNAPSHOT.jar"/> + <include name="tuscany-databinding-jaxb-axiom-1.6-SNAPSHOT.jar"/> + <include name="tuscany-databinding-json-1.6-SNAPSHOT.jar"/> + <include name="tuscany-definitions-1.6-SNAPSHOT.jar"/> + <include name="tuscany-definitions-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-domain-manager-1.6-SNAPSHOT.jar"/> + <include name="tuscany-endpoint-1.6-SNAPSHOT.jar"/> + <include name="tuscany-extensibility-1.6-SNAPSHOT.jar"/> + <include name="tuscany-host-embedded-1.6-SNAPSHOT.jar"/> + <include name="tuscany-host-http-1.6-SNAPSHOT.jar"/> + <include name="tuscany-host-jetty-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-runtime-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-node-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-node-runtime-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-resource-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-resource-runtime-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-widget-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-widget-runtime-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-widget-runtime-tuscany-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-jaxws-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-wsdl-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-wsdl-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-monitor-1.6-SNAPSHOT.jar"/> + <include name="tuscany-node-api-1.6-SNAPSHOT.jar"/> + <include name="tuscany-node-impl-1.6-SNAPSHOT.jar"/> + <include name="tuscany-node-launcher-1.6-SNAPSHOT.jar"/> + <include name="tuscany-node-manager-1.6-SNAPSHOT.jar"/> + <include name="tuscany-policy-1.6-SNAPSHOT.jar"/> + <include name="tuscany-policy-security-1.6-SNAPSHOT.jar"/> + <include name="tuscany-policy-security-http-1.6-SNAPSHOT.jar"/> + <include name="tuscany-policy-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-policy-xml-ws-1.6-SNAPSHOT.jar"/> + <include name="tuscany-sca-api-1.6-SNAPSHOT.jar"/> + <include name="tuscany-sca-api-extension-1.6-SNAPSHOT.jar"/> + <include name="tuscany-web-javascript-1.6-SNAPSHOT.jar"/> + <include name="tuscany-workspace-1.6-SNAPSHOT.jar"/> + <include name="tuscany-workspace-impl-1.6-SNAPSHOT.jar"/> + <include name="tuscany-workspace-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-xsd-1.6-SNAPSHOT.jar"/> + <include name="tuscany-xsd-xml-1.6-SNAPSHOT.jar"/> + </fileset> + <fileset id="3rdparty.jars" dir="../../lib"> + <include name="XmlSchema-1.4.2.jar"/> + <include name="abdera-client-0.4.0-incubating.jar"/> + <include name="abdera-core-0.4.0-incubating.jar"/> + <include name="abdera-extensions-html-0.4.0-incubating.jar"/> + <include name="abdera-extensions-json-0.4.0-incubating.jar"/> + <include name="abdera-extensions-main-0.4.0-incubating.jar"/> + <include name="abdera-i18n-0.4.0-incubating.jar"/> + <include name="abdera-parser-0.4.0-incubating.jar"/> + <include name="abdera-server-0.4.0-incubating.jar"/> + <include name="activation-1.1.jar"/> + <include name="annogen-0.1.0.jar"/> + <include name="asm-all-3.1.jar"/> + <include name="axiom-api-1.2.7.jar"/> + <include name="axiom-dom-1.2.7.jar"/> + <include name="axiom-impl-1.2.7.jar"/> + <include name="axis-ant-1.4.jar"/> + <include name="axis2-adb-1.4.1.jar"/> + <include name="axis2-codegen-1.4.1.jar"/> + <include name="axis2-java2wsdl-1.4.1.jar"/> + <include name="axis2-kernel-1.4.1.jar"/> + <include name="axis2-mtompolicy-1.4.1.jar"/> + <include name="backport-util-concurrent-3.1.jar"/> + <include name="bcprov-jdk13-132.jar"/> + <include name="cglib-nodep-2.2.jar"/> + <include name="commons-codec-1.3.jar"/> + <include name="commons-collections-3.1.jar"/> + <include name="commons-discovery-0.2.jar"/> + <include name="commons-fileupload-1.2.jar"/> + <include name="commons-httpclient-3.1.jar"/> + <include name="commons-io-1.4.jar"/> + <include name="commons-logging-1.1.1.jar"/> + <include name="derby-10.3.1.4.jar"/> + <include name="geronimo-activation_1.1_spec-1.0.1.jar"/> + <include name="geronimo-javamail_1.4_spec-1.2.jar"/> + <include name="geronimo-jms_1.1_spec-1.1.jar"/> + <include name="geronimo-stax-api_1.0_spec-1.0.1.jar"/> + <include name="htmlparser-1.0.5.jar"/> + <include name="httpcore-4.0-beta1.jar"/> + <include name="httpcore-nio-4.0-beta1.jar"/> + <include name="jaxb-api-2.1.jar"/> + <include name="jaxb-impl-2.1.7.jar"/> + <include name="jaxen-1.1.1.jar"/> + <include name="jaxws-api-2.1.jar"/> + <include name="jettison-1.0.1.jar"/> + <include name="jetty-6.1.7.jar"/> + <include name="jetty-util-6.1.7.jar"/> + <include name="json-rpc-1.0.jar"/> + <include name="jsr181-api-1.0-MR1.jar"/> + <include name="jsr250-api-1.0.jar"/> + <include name="junit-4.5.jar"/> + <include name="log4j-1.2.15.jar"/> + <include name="mail-1.4.jar"/> + <include name="mex-1.41-impl.jar"/> + <include name="neethi-2.0.4.jar"/> + <include name="opensaml-1.1.jar"/> + <include name="rampart-core-1.4.jar"/> + <include name="rampart-policy-1.4.jar"/> + <include name="rampart-trust-1.4.jar"/> + <include name="servlet-api-2.5.jar"/> + <include name="stax-api-1.0-2.jar"/> + <include name="woden-api-1.0M8.jar"/> + <include name="woden-impl-dom-1.0M8.jar"/> + <include name="wsdl4j-1.6.2.jar"/> + <include name="wss4j-1.5.4.jar"/> + <include name="wstx-asl-3.2.4.jar"/> + <include name="xalan-2.7.0.jar"/> + <include name="xercesImpl-2.8.1.jar"/> + <include name="xml-apis-1.3.03.jar"/> + <include name="xmlParserAPIs-2.6.0.jar"/> + <include name="xmlsec-1.4.2.jar"/> + </fileset> + +</project> diff --git a/sandbox/travelsample/contrib/chapter-09/node/pom.xml b/sandbox/travelsample/contrib/chapter-09/node/pom.xml new file mode 100644 index 0000000000..8deb76212c --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/node/pom.xml @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>1.6-SNAPSHOT</version> + <!--relativePath>../../pom.xml</relativePath--> + </parent> + <artifactId>scatours-chapter-09-node</artifactId> + <name>Apache Tuscany SCA Tours Chapter 09 Node</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-api</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-launcher</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-domain-manager</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-node-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-widget-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-resource-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-atom-abdera</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-jsonrpc-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-http-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-axis2</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-sca-axis2</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derby</artifactId> + <version>10.3.1.4</version> + <scope>runtime</scope> + </dependency> + + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <plugins> + <plugin> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-maven-ant-generator</artifactId> + <version>1.6-SNAPSHOT</version> + <executions> + <execution> + <configuration> + <mainClass>scatours.LaunchNode</mainClass> + </configuration> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/sandbox/travelsample/contrib/chapter-09/node/src/main/java/scatours/LaunchNode.java b/sandbox/travelsample/contrib/chapter-09/node/src/main/java/scatours/LaunchNode.java new file mode 100644 index 0000000000..7ed9b0d126 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/node/src/main/java/scatours/LaunchNode.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package scatours; + +import java.io.IOException; + +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +public class LaunchNode { + public static void main(String[] args) throws Exception { + LaunchNode.launchFromFileSystemDir(); + } + + // OK for development but you must launch the node from this module + public static void launchFromFileSystemDir(){ + SCANode node = null; + + try { + node = SCANodeFactory.newInstance().createSCANode("scatours.composite", + new SCAContribution("common", "../../shared-contributions/common-contribution/target/classes"), + new SCAContribution("currency", "../../shared-contributions/currency-contribution/target/classes"), + new SCAContribution("hotel", "../../shared-contributions/hotel-contribution/target/classes"), + new SCAContribution("flight", "../../shared-contributions/flight-contribution/target/classes"), + new SCAContribution("car", "../../shared-contributions/car-contribution/target/classes"), + new SCAContribution("trip", "../../shared-contributions/trip-contribution/target/classes"), + new SCAContribution("tripbooking", "../../shared-contributions/tripbooking-contribution/target/classes"), + new SCAContribution("travelcatalog", "../../shared-contributions/travelcatalog-contribution/target/classes"), + new SCAContribution("payment", "../payment-contribution/target/classes"), + new SCAContribution("emailgateway", "../../shared-contributions/emailgateway-contribution/target/classes"), + new SCAContribution("shoppingcart", "../../shared-contributions/shoppingcart-contribution/target/classes"), + new SCAContribution("scatours", "../../shared-contributions/scatours-contribution/target/classes"), + new SCAContribution("ui", "../ui-contribution/target/classes")); + node.start(); + + System.out.println("Node started - Press enter to shutdown."); + try { + System.in.read(); + } catch (IOException e) {} + + node.stop(); + + } catch (Exception ex) { + System.out.println(ex.toString()); + } + } +} diff --git a/sandbox/travelsample/contrib/chapter-09/payment-contribution/pom.xml b/sandbox/travelsample/contrib/chapter-09/payment-contribution/pom.xml new file mode 100644 index 0000000000..d642fa3d17 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/payment-contribution/pom.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>1.6-SNAPSHOT</version> + <!--relativePath>../../pom.xml</relativePath--> + </parent> + <artifactId>scatours-chapter-09-payment-contribution</artifactId> + <name>Apache Tuscany SCA Tours Chapter 09 Payment Contribution</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-embedded</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-jsonrpc-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-axis2</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-jetty</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + + </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> + </build> +</project> diff --git a/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/java/payment/Payment.java b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/java/payment/Payment.java new file mode 100644 index 0000000000..f1a45cb031 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/java/payment/Payment.java @@ -0,0 +1,26 @@ +/* + * 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; + +public interface Payment { + + public String makePaymentMember(String customerId, + float amount); +} diff --git a/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/java/payment/PaymentImpl.java b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/java/payment/PaymentImpl.java new file mode 100644 index 0000000000..aa8f3cd01a --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/java/payment/PaymentImpl.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package payment; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import payment.creditcard.CreditCardDetailsType; +import payment.creditcard.CreditCardPayment; +import payment.creditcard.CreditCardTypeType; +import payment.creditcard.ObjectFactory; +import payment.creditcard.PayerType; + +/** + * + */ +@Service(Payment.class) +public class PaymentImpl implements Payment { + + @Reference + protected CreditCardPayment creditCardPayment; + + public String makePaymentMember(String customerId, float amount) { + + ObjectFactory objectFactory = new ObjectFactory(); + CreditCardDetailsType ccDetails = objectFactory.createCreditCardDetailsType(); + ccDetails.setCreditCardType(CreditCardTypeType.fromValue("Visa")); + PayerType ccOwner = objectFactory.createPayerType(); + ccOwner.setName(customerId); + ccDetails.setCardOwner(ccOwner); + + String status = creditCardPayment.authorize(ccDetails, amount); + + return status; + } + +} diff --git a/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/resources/CreditCardPayment.wsdl b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/resources/CreditCardPayment.wsdl new file mode 100644 index 0000000000..b40c341389 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/resources/CreditCardPayment.wsdl @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions name="CreditCardPayment"
+ targetNamespace="http://www.example.org/CreditCardPayment/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://www.example.org/CreditCardPayment/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
+ xmlns:plnk="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
+ <wsdl:types>
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.example.org/CreditCardPayment/"
+ xmlns:tns="http://www.example.org/CreditCardPayment/">
+
+ <xsd:element name="authorize" type="tns:AuthorizeType"/>
+ <xsd:complexType name="AuthorizeType">
+ <xsd:sequence>
+ <xsd:element name="CreditCard" type="tns:CreditCardDetailsType"></xsd:element>
+ <xsd:element name="Amount" type="xsd:float"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="authorizeResponse" type="tns:AuthorizeResponseType"/>
+ <xsd:complexType name="AuthorizeResponseType">
+ <xsd:sequence>
+ <xsd:element name="Status" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="CreditCardDetailsType">
+ <xsd:sequence>
+ <xsd:element name="CreditCardType" type="tns:CreditCardTypeType" minOccurs="0" />
+ <xsd:element name="CreditCardNumber" type="xsd:string" minOccurs="0" />
+ <xsd:element name="ExpMonth" type="xsd:int" minOccurs="0" />
+ <xsd:element name="ExpYear" type="xsd:int" minOccurs="0" />
+ <xsd:element name="CardOwner" type="tns:PayerType" minOccurs="0" />
+ <xsd:element name="CVV2" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:simpleType name="CreditCardTypeType">
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="Visa" />
+ <xsd:enumeration value="MasterCard" />
+ <xsd:enumeration value="Discover" />
+ <xsd:enumeration value="Amex" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ <xsd:complexType name="PayerType">
+ <xsd:sequence>
+ <xsd:element name="Name" type="xsd:string" />
+ <xsd:element name="Address" type="tns:AddressType" />
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AddressType">
+ <xsd:sequence>
+ <xsd:element name="Street" type="xsd:string" />
+ <xsd:element name="City" type="xsd:string" />
+ <xsd:element name="State" type="xsd:string" />
+ <xsd:element name="ZipCode" type="xsd:string" />
+ <xsd:element name="HomePhone" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types> + <wsdl:message name="AuthorizeRequest">
+ <wsdl:part name="parameters" element="tns:authorize"></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="AuthorizeResponse">
+ <wsdl:part name="parameters" element="tns:authorizeResponse"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="CreditCardPayment">
+ <wsdl:operation name="authorize">
+ <wsdl:input message="tns:AuthorizeRequest"></wsdl:input>
+ <wsdl:output message="tns:AuthorizeResponse"></wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CreditCardPaymentBinding" type="tns:CreditCardPayment">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="authorize">
+ <soap:operation soapAction="http://www.example.org/CreditCardPayment/authorize" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CreditCardPaymentService">
+ <wsdl:port name="CreditCardPaymentPort" binding="tns:CreditCardPaymentBinding">
+ <soap:address location="http://localhost:8080/CreditCardPayment" />
+ </wsdl:port>
+ </wsdl:service>
+
+ <plnk:partnerLinkType name="CreditCardPaymentLinkType">
+ <plnk:role name="forward" portType="tns:CreditCardPayment"/>
+ </plnk:partnerLinkType>
+</wsdl:definitions>
\ No newline at end of file diff --git a/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..d22f4816ab --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"> + <export.java package="payment.creditcard"/> + <export.java package="payment.creditcard.impl"/> + <export.java package="payment.creditcard.ws"/> + <export.java package="payment.creditcard.ws.impl"/> +</contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/test/java/payment/PaymentTestCase.java b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/test/java/payment/PaymentTestCase.java new file mode 100644 index 0000000000..21bf6ff428 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/test/java/payment/PaymentTestCase.java @@ -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 payment; + +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.Test; + +/** + * + */ +public class PaymentTestCase { + private static SCANode node; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANodeFromClassLoader("payment.composite", Payment.class.getClassLoader()); + node.start(); + } + + @Test + public void testCreditCardPayment() { + SCAClient client = (SCAClient) node; + Payment payment = client.getService(Payment.class, "PaymentComponent"); + System.out.println(payment.makePaymentMember("Fred Bloggs", 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; + } + } + +} diff --git a/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentImpl.java b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentImpl.java new file mode 100644 index 0000000000..b7d44c1abe --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/test/java/payment/creditcard/CreditCardPaymentImpl.java @@ -0,0 +1,44 @@ +/* + * 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.osoa.sca.annotations.Service; + +/** + * + */ +@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"; + } +} diff --git a/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/test/resources/payment.composite b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/test/resources/payment.composite new file mode 100644 index 0000000000..90665e86e0 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/payment-contribution/src/test/resources/payment.composite @@ -0,0 +1,34 @@ +<?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://scatours" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0" + xmlns:c="http://scatours" + name="payment"> + + <component name="PaymentComponent"> + <implementation.java class="payment.PaymentImpl" /> + <reference name="creditCardPayment" target="CreditCardPaymentComponent"/> + </component> + + <component name="CreditCardPaymentComponent"> + <implementation.java class="payment.creditcard.CreditCardPaymentImpl" /> + </component> +</composite>
\ No newline at end of file diff --git a/sandbox/travelsample/contrib/chapter-09/pom.xml b/sandbox/travelsample/contrib/chapter-09/pom.xml new file mode 100644 index 0000000000..7d7bee30ff --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>1.5-SNAPSHOT</version> + <!--relativePath>../pom.xml</relativePath--> + </parent> + <artifactId>tuscany-scatours-chapter-09</artifactId> + <packaging>pom</packaging> + <name>Apache Tuscany SCA Tours Chapter 09 Examples</name> + + <profiles> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <modules> + <module>node</module> + <module>ui-contribution</module> + <module>payment-contribution</module> + <module>creditcard-payment-sdo-contribution</module> + </modules> + </profile> + + </profiles> + +</project> diff --git a/sandbox/travelsample/contrib/chapter-09/ui-contribution/build.xml b/sandbox/travelsample/contrib/chapter-09/ui-contribution/build.xml new file mode 100644 index 0000000000..9bb124b5d0 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/ui-contribution/build.xml @@ -0,0 +1,108 @@ +<!-- + * 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="scatours-chapter-05-ui-contribution" default="compile"> + + <target name="compile"> + <mkdir dir="target/classes"/> + <javac destdir="target/classes" debug="on" source="1.5" target="1.5"> + <src path="src"/> + <classpath> + <fileset refid="tuscany.jars"/> + <fileset refid="3rdparty.jars"/> + </classpath> + </javac> + <copy todir="target/classes"> + <fileset dir="." excludes="**/*.java, pom.xml, build.xml, target"/> + </copy> + <jar destfile="target/scatours-chapter-05-ui-contribution.jar" basedir="target/classes"> + <manifest> + <attribute name="Main-Class" value="launch.LaunchTutorialAdmin"/> + </manifest> + </jar> + </target> + + <target name="package" depends="compile"/> + + <target name="run"> + <java classname="launch.LaunchTutorialAdmin" fork="true"> + <classpath> + <pathelement location="target/scatours-chapter-05-ui-contribution.jar"/> + <fileset refid="tuscany.jars"/> + <fileset refid="3rdparty.jars"/> + </classpath> + </java> + </target> + + <target name="clean"> + <delete includeemptydirs="true"> + <fileset dir="target"/> + </delete> + </target> + + <fileset id="tuscany.jars" dir="../../modules"> + <include name="tuscany-assembly-1.6-SNAPSHOT.jar"/> + <include name="tuscany-assembly-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-assembly-xsd-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-sca-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-sca-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-impl-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-java-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-namespace-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-core-1.6-SNAPSHOT.jar"/> + <include name="tuscany-core-databinding-1.6-SNAPSHOT.jar"/> + <include name="tuscany-core-spi-1.6-SNAPSHOT.jar"/> + <include name="tuscany-databinding-1.6-SNAPSHOT.jar"/> + <include name="tuscany-databinding-jaxb-1.6-SNAPSHOT.jar"/> + <include name="tuscany-definitions-1.6-SNAPSHOT.jar"/> + <include name="tuscany-definitions-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-endpoint-1.6-SNAPSHOT.jar"/> + <include name="tuscany-extensibility-1.6-SNAPSHOT.jar"/> + <include name="tuscany-host-embedded-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-node-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-jaxws-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-monitor-1.6-SNAPSHOT.jar"/> + <include name="tuscany-node-api-1.6-SNAPSHOT.jar"/> + <include name="tuscany-node-impl-1.6-SNAPSHOT.jar"/> + <include name="tuscany-policy-1.6-SNAPSHOT.jar"/> + <include name="tuscany-policy-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-sca-api-1.6-SNAPSHOT.jar"/> + <include name="tuscany-sca-api-extension-1.6-SNAPSHOT.jar"/> + <include name="tuscany-xsd-1.6-SNAPSHOT.jar"/> + </fileset> + <fileset id="3rdparty.jars" dir="../../lib"> + <include name="XmlSchema-1.6-SNAPSHOT.2.jar"/> + <include name="activation-1.1.jar"/> + <include name="asm-all-3.1.jar"/> + <include name="cglib-nodep-2.2.jar"/> + <include name="jaxb-api-2.1.jar"/> + <include name="jaxb-impl-2.1.7.jar"/> + <include name="jaxws-api-2.1.jar"/> + <include name="jsr181-api-1.0-MR1.jar"/> + <include name="jsr250-api-1.0.jar"/> + <include name="stax-api-1.0-2.jar"/> + <include name="wstx-asl-3.2.4.jar"/> + </fileset> + +</project> diff --git a/sandbox/travelsample/contrib/chapter-09/ui-contribution/pom.xml b/sandbox/travelsample/contrib/chapter-09/ui-contribution/pom.xml new file mode 100644 index 0000000000..958aed8d7b --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/ui-contribution/pom.xml @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>1.6-SNAPSHOT</version> + <!--relativePath>../../pom.xml</relativePath--> + </parent> + <artifactId>scatours-chapter-09-ui-contribution</artifactId> + <name>Apache Tuscany SCA Tours Chapter 09 User Interface Contribution</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-embedded</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-axis2</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-tomcat</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + </build> +</project> diff --git a/sandbox/travelsample/contrib/chapter-09/ui-contribution/scatours.odg b/sandbox/travelsample/contrib/chapter-09/ui-contribution/scatours.odg Binary files differnew file mode 100644 index 0000000000..8ca8fbf133 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/ui-contribution/scatours.odg diff --git a/sandbox/travelsample/contrib/chapter-09/ui-contribution/scatours.png b/sandbox/travelsample/contrib/chapter-09/ui-contribution/scatours.png Binary files differnew file mode 100644 index 0000000000..f68cd84704 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/ui-contribution/scatours.png diff --git a/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..764030c28e --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,37 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + xmlns:scatours="http://scatours"> + <deployable composite="scatours:scatours"/> + <import.java package="scatours.common"/> + <import.java package="scatours.currencyconverter"/> + <import.java package="scatours.hotel"/> + <import.java package="scatours.flight"/> + <import.java package="scatours.car"/> + <import.java package="scatours.trip"/> + <import.java package="scatours.tripbooking"/> + <import.java package="scatours.travelcatalog"/> + <import.java package="payment.creditcard.ws.impl"/> + <import.java package="scatours.emailgateway"/> + <import.java package="scatours.paymentprocess"/> + <import.java package="scatours.shoppingcart"/> + <import.java package="scatours"/> + <import namespace="http://www.example.org/PaymentProcess/"/> +</contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/scatours.composite b/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/scatours.composite new file mode 100644 index 0000000000..53fac26d3e --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/scatours.composite @@ -0,0 +1,178 @@ +<?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://scatours" + xmlns:scatours="http://scatours" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + xmlns:pp="http://www.example.org/PaymentProcess" + name="scatours"> + + <component name="UserInterfaceComponent"> + <tuscany:implementation.widget location="scatours.html"/> + <service name="Widget"> + <tuscany:binding.http uri="/scatours"/> + </service> + <reference name="scaToursCatalog" target="SCAToursComponent/SCAToursSearch"> + <tuscany:binding.jsonrpc/> + </reference> + <reference name="scaToursBooking" target="SCAToursComponent/SCAToursBooking"> + <tuscany:binding.jsonrpc/> + </reference> + <reference name="scaToursCart" target="SCAToursComponent/SCAToursCart"> + <tuscany:binding.jsonrpc/> + </reference> + </component> + + <component name="SCAToursComponent"> + <implementation.java class="scatours.SCAToursImpl"/> + <service name="SCAToursSearch"> + <tuscany:binding.jsonrpc/> + </service> + <service name="SCAToursBooking"> + <tuscany:binding.jsonrpc/> + </service> + <service name="SCAToursCart"> + <tuscany:binding.jsonrpc/> + </service> + <reference name="travelCatalogSearch" target="TravelCatalogComponent/TravelCatalogSearch"/> + <reference name="tripBooking" target="TripBookingComponent/TripBooking"/> + <reference name="shoppingCart" target="ShoppingCartComponent/ShoppingCart"/> + </component> + + <component name="TravelCatalogComponent"> + <implementation.java class="scatours.travelcatalog.TravelCatalogImpl"/> + <service name="TravelCatalogSearch"/> + <reference name="hotelSearch" target="HotelComponent/Search"> + <binding.sca/> + </reference> + <reference name="flightSearch"> + <interface.java interface="scatours.common.Search" + callbackInterface="scatours.common.SearchCallback"/> + <binding.ws uri="http://localhost:8080/Flight/Search"/> + <callback> + <binding.ws uri="http://localhost:8080/Flight/SearchCallback"/> + </callback> + </reference> + <reference name="carSearch" target="CarComponent/Search"> + <binding.sca/> + </reference> + <reference name="tripSearch" target="TripComponent/Search"> + <binding.sca/> + </reference> + <reference name="currencyConverter" target="CurrencyConverterComponent"> + </reference> + <property name="quoteCurrencyCode">GBP</property> + </component> + + <component name="TripBookingComponent"> + <implementation.java class="scatours.tripbooking.TripBookingImpl"/> + <service name="TripBooking"/> + <reference name="hotelBook" target="HotelComponent/Book"/> + <reference name="flightBook" target="TripComponent/Book"/> + <reference name="carBook" target="CarComponent/Book"/> + <reference name="tripBook" target="TripComponent/Book"/> + <reference name="shoppingCart" target="ShoppingCartComponent/ShoppingCart"/> + </component> + + <component name="HotelComponent"> + <implementation.java class="scatours.hotel.HotelImpl"/> + <service name="Search"> + <binding.sca/> + <tuscany:binding.jsonrpc/> + </service> + <service name="Book"/> + </component> + + <component name="FlightComponent"> + <implementation.java class="scatours.flight.FlightImpl"/> + <service name="Search"> + <interface.java interface="scatours.common.Search" + callbackInterface="scatours.common.SearchCallback"/> + <binding.ws uri="http://localhost:8080/Flight/Search"/> + <tuscany:binding.jsonrpc/> + <callback> + <binding.ws uri="http://localhost:8080/Flight/SearchCallback"/> + </callback> + </service> + <service name="Book"/> + </component> + + <component name="CarComponent"> + <implementation.java class="scatours.car.CarImpl"/> + <service name="Search"> + <binding.sca/> + <tuscany:binding.jsonrpc/> + </service> + <service name="Book"/> + </component> + + <component name="TripComponent"> + <implementation.java class="scatours.trip.TripImpl"/> + <service name="Search"> + <binding.sca/> + <tuscany:binding.jsonrpc/> + </service> + <service name="Book"/> + </component> + + <component name="CurrencyConverterComponent"> + <implementation.java class="scatours.currencyconverter.CurrencyConverterImpl"/> + <service name="CurrencyConverter"> + </service> + </component> + + <component name="ShoppingCartComponent"> + <implementation.java class="scatours.shoppingcart.ShoppingCartImpl"/> + <service name="ShoppingCart"> + </service> + <!--reference name="paymentProcess"> + <binding.ws uri="http://localhost:8083/PaymentProcess" /> + </reference--> + </component> + + <!--component name="PaymentProcessComponent"> + <implementation.bpel process="pp:PaymentProcess"/> + <service name="paymentProcessPartnerLink"> + <interface.wsdl interface="http://www.example.org/PaymentProcess/#wsdl.interface(PaymentProcess)" /> + <binding.ws uri="http://localhost:8080/PaymentProcess" wsdlElement="http://www.example.org/PaymentProcess/#wsdl.service(PaymentProcessService)"/> + </service> + <reference name="creditCardPaymentPartnerLink"> + <binding.ws uri="http://localhost:8081/CreditCardPayment"/> + </reference> + <reference name="emailGatewayPartnerLink"> + <binding.ws uri="http://localhost:8082/EmailGateway"/> + </reference> + </component> + + <component name="CreditCardPaymentWS"> + <implementation.java class="payment.creditcard.ws.impl.CreditCardPaymentWSImpl" /> + <service name="CreditCardPayment"> + <binding.ws uri="http://localhost:8081/CreditCardPayment" /> + </service> + </component> + + <component name="EmailGateway"> + <implementation.java class="scatours.emailgateway.EmailGatewayImpl" /> + <service name="EmailGateway"> + <binding.ws uri="http://localhost:8082/EmailGateway" /> + </service> + </component--> + +</composite> diff --git a/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/scatours.html b/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/scatours.html new file mode 100644 index 0000000000..f4206548c0 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/scatours.html @@ -0,0 +1,390 @@ +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<html> +<head> +<title>SCA Tours</title> + +<link rel="stylesheet" type="text/css" href="style.css" /> + +<script type="text/javascript" src="scatours.js"></script> + +<script language="JavaScript"> + + //@Reference + var scaToursCatalog = new Reference("scaToursCatalog"); + + //@Reference + var scaToursBooking = new Reference("scaToursBooking"); + + //@Reference + var scaToursCart = new Reference("scaToursCart"); + + //local state + var packagedItems; + var bespokeItems; + var cartId; + + //the constructor for trip leg beans + function TripLegType(id, + fromLocation, + toLocation, + fromDate, + toDate, + noOfPeople) { + this.id = id; + this.fromLocation = fromLocation; + this.toLocation = toLocation; + this.fromDate = fromDate; + this.toDate = toDate; + this.noOfPeople = noOfPeople; + } + + function getTripLeg(){ + return new TripLegType(cartId, + document.searchForm.fromLocation.value, + document.searchForm.toLocation.value, + document.searchForm.fromDate.value, + document.searchForm.toDate.value, + document.searchForm.noOfPeople.value); + } + + //the constructor for bespoke trip beans + function TripType() { + this.id = cartId; + this.type = "Bespoke"; + this.tripItems = new Array(); + // json databinding can't tolerate having a class hint set as the + // databinding transformer is not in the right classloader to load + // the class pointed to by the hint + //this.javaClass = "scatours.common.TripItem"; + } + + function getTrip(){ + return new TripType(); + } + + // remove class hint from the trip object + // can also be used to limit the amount of + // data returned to the server + function copyTrip(trip){ + var tripCopy = new TripType(); + + tripCopy.id = trip.id; + tripCopy.tripId = trip.tripId; + tripCopy.type = trip.type; + tripCopy.name = trip.name; + tripCopy.description = trip.description; + tripCopy.location = trip.location; + tripCopy.fromDate = trip.fromDate; + tripCopy.toDate = trip.toDate; + tripCopy.price = trip.price; + tripCopy.currency = trip.currency; + tripCopy.link = trip.link; + + return tripCopy; + } + + function init() { + try { + newCart(); + } + catch(e) { + alert(e); + } + } + + function reset() { + document.getElementById('packagedTripItems').innerHTML = ""; + document.getElementById('bespokeTripItems').innerHTML = ""; + document.getElementById('cartItems').innerHTML = ""; + document.getElementById('cartPrice').innerHTML = ""; + packagedItems = new Array(); + bespokeItems = new Array(); + } + + function newCart() { + scaToursCart.newCart(newCart_response); + reset(); + } + + function newCart_response(newCartId, exception) { + if(exception){ + alert(exception.javaStack); + return; + } + cartId = newCartId + } + + function searchTravelCatalog() { + scaToursCatalog.search(getTripLeg(), search_response); + } + + function search_response(items, exception) { + if(exception){ + alert(exception.javaStack); + return; + } + + var packagedHTML = '<h3>Packaged Trip Items</h3>'; + packagedHTML += '<table border="0">'; + packagedHTML += '<tr>'; + packagedHTML += '<td>Select</td><td>Name</td><td>Description</td><td>Location</td><td>From - To</td><td>Price</td>'; + packagedHTML += '</tr>'; + + var bespokeHTML = '<h3>Bespoke Trip Items</h3>'; + bespokeHTML += '<table border="0">'; + bespokeHTML += '<tr>'; + bespokeHTML += '<td>Select</td><td>Name</td><td>Description</td><td>Location</td><td>From - To</td><td>Price</td>'; + bespokeHTML += '</tr>'; + + for (var i=0; i<items.length; i++) { + if (items[i].type == "Trip") { + packagedHTML += '<tr>'; + packagedHTML += '<td><input onClick="processPackagedSelection()" name="packagedTripItemSelection" type="checkbox" value="' + items[i].id + '"></td>' + packagedHTML += '<td>' + items[i].name + '</td>'; + packagedHTML += '<td>' + items[i].description + '</td>'; + packagedHTML += '<td>' + items[i].location + '</td>'; + packagedHTML += '<td>' + items[i].fromDate + ' - ' + items[i].toDate +'</td>'; + packagedHTML += '<td>' + items[i].price + ' ' + items[i].currency + '</td>'; + packagedHTML += '</tr>'; + packagedItems.push(items[i]); + } else { + bespokeHTML += '<tr>'; + bespokeHTML += '<td><input onClick="processBespokeSelection()" name="bespokeTripItemSelection" type="checkbox" value="' + items[i].id + '"></td>' + bespokeHTML += '<td>' + items[i].name + '</td>'; + bespokeHTML += '<td>' + items[i].description + '</td>'; + bespokeHTML += '<td>' + items[i].location + '</td>'; + bespokeHTML += '<td>' + items[i].fromDate + ' - ' + items[i].toDate +'</td>'; + bespokeHTML += '<td>' + items[i].price + ' ' + items[i].currency + '</td>'; + bespokeHTML += '</tr>'; + bespokeItems.push(items[i]); + } + } + + packagedHTML += '</table>'; + packagedHTML += '<input type="button" onClick="bookPackagedTrip()" value="Book Packaged Trip">'; + + bespokeHTML += '<tr><td/><td/><td>Total Price</td><td/><td/><td><div id="bespokeTripPrice"></div> </td></tr>'; + bespokeHTML += '</table>'; + bespokeHTML += '<input type="button" onClick="bookBespokeTrip()" value="Book Bespoke Trip">'; + + if (packagedItems.length > 0){ + document.getElementById('packagedTripItems').innerHTML = packagedHTML; + } + + if (bespokeItems.length > 0){ + document.getElementById('bespokeTripItems').innerHTML = bespokeHTML; + } + } + + function processPackagedSelection() { + // do nothing at the moment + } + + function processBespokeSelection() { + // calculate total price + var items = document.getElementsByName("bespokeTripItemSelection"); + var totalPrice = 0.0; + for (var i=0; i<items.length; i++) { + + // find the items that are checked + if (items[i].checked == true) { + totalPrice = totalPrice + bespokeItems[i].price; + } + } + document.getElementById('bespokeTripPrice').innerHTML = totalPrice + ' ' + bespokeItems[0]. currency; + } + + function bookPackagedTrip() { + // find first selected trip item + var trip = null; + var items = document.getElementsByName("packagedTripItemSelection"); + for (var i=0; i<items.length; i++) { + + // find the items that are checked + if (items[i].checked == true) { + trip = copyTrip(packagedItems[i]); + break; + } + } + + if (trip != null) { + // book trip + scaToursBooking.bookTrip(cartId, trip); + + // reset the display + reset(); + + // re-populate the cart with all entries + getCartTrips(); + } else { + alert ("Please select a trip") + } + } + + function bookBespokeTrip() { + // create a trip object + var trip = getTrip(); + + // add selected trip items to trip + var items = document.getElementsByName("bespokeTripItemSelection"); + for (var i=0; i<items.length; i++) { + + // find the items that are checked + if (items[i].checked == true) { + trip.tripItems.push(copyTrip(bespokeItems[i])); + } + } + + if (trip.tripItems.length > 0) { + // book trip + scaToursBooking.bookTrip(cartId, trip); + + // reset the display + reset(); + + // re-populate the cart with all entries + getCartTrips(); + } else { + alert ("Please select some trip items!") + } + } + + function getCartTrips() { + scaToursCart.getTrips(cartId, getCartTrips_response); + } + + function getCartTrips_response(trips, exception) { + if(exception){ + alert(exception.javaStack); + return; + } + var itemsHTML = ''; + var totalPrice = 0.0; + + for (var x=0; x<trips.length; x++){ + itemsHTML += '<h3>Trip - ' + trips[x].id + '</h3>'; + itemsHTML += '<table border="0">'; + itemsHTML += '<tr>'; + itemsHTML += '<td>Booking Ref</td><td>Name</td><td>Description</td><td>Location</td><td>From - To</td><td>Price</td>'; + itemsHTML += '</tr>'; + + if (trips[x].type == "Trip") { + itemsHTML += '<tr>'; + itemsHTML += '<td>' + trips[x].bookingCode + '</td>'; + itemsHTML += '<td>' + trips[x].name + '</td>'; + itemsHTML += '<td>' + trips[x].description + '</td>'; + itemsHTML += '<td>' + trips[x].location + '</td>'; + itemsHTML += '<td>' + trips[x].fromDate + ' - ' + trips[x].toDate +'</td>'; + itemsHTML += '<td>' + trips[x].price + ' ' + trips[x].currency + '</td>'; + itemsHTML += '</tr>'; + totalPrice = totalPrice + trips[x].price; + + } else { + var tripItems = trips[x].tripItems; + + for (var i=0; i<tripItems.length; i++) { + itemsHTML += '<tr>'; + itemsHTML += '<td>' + tripItems[i].bookingCode + '</td>'; + itemsHTML += '<td>' + tripItems[i].name + '</td>'; + itemsHTML += '<td>' + tripItems[i].description + '</td>'; + itemsHTML += '<td>' + tripItems[i].location + '</td>'; + itemsHTML += '<td>' + tripItems[i].fromDate + ' - ' + tripItems[i].toDate +'</td>'; + itemsHTML += '<td>' + tripItems[i].price + ' ' + tripItems[i].currency + '</td>'; + itemsHTML += '</tr>'; + totalPrice = totalPrice + tripItems[i].price; + } + } + + itemsHTML += '</table>'; + } + + document.getElementById('cartItems').innerHTML = itemsHTML; + document.getElementById('cartPrice').innerHTML = totalPrice + ' ' + trips[0].currency; + } + + function checkout() { + scaToursCart.checkout(cartId); + + document.getElementById('searchResponse').innerHTML = ""; + document.getElementById('cartItems').innerHTML = "Thank you for shopping with SCA Tours"; + document.getElementById('cartPrice').innerHTML = ""; + searchResponseItems = null; + tripItems = null; + } + + function purchase() { + } + +</script> + +</head> + +<body onload="init()" background=""> + <img src="scatours.png" border="0" /> + <div id="scatours"> + <form name="searchForm"> + <h3>Search for trips, hotels, flights and cars</h3> + <br/> + <table border="0"> + <tr> + <td>From Location:</td> + <td><input type="text" name="fromLocation" value="LGW"></td> + <td>To Location:</td> + <td><input type="text" name="toLocation" value="FLR"></td> + </tr> + <tr> + <td>Start Date:</td> + <td><input type="text" name="fromDate" value="06/12/09"></td> + <td>End Date:</td> + <td><input type="text" name="toDate" value="13/12/09"></td> + </tr> + <tr> + <td>Number of people:</td> + <td><select name="noOfPeople"> + <option>1 + <option selected>2 + <option>3 + <option>4 + </select></td> + <td/> + <td/> + </tr> + </table> + <br/> + <input type="button" onClick="searchTravelCatalog()" value="Search"> + </form> + <form name="packagedTripForm"> + <div id="packagedTripItems"></div> + </form> + <form name="bespokeTripForm"> + <div id="bespokeTripItems"></div> + </form> + <form name="cartForm"> + <h3>Shopping Cart</h3> + <div id="cartItems"></div> + <br/> + Total Price: <div id="cartPrice"></div> + <br/> + <input type="button" onClick="checkout()" value="Checkout"> + </form> + </div> + +</body> +</html> diff --git a/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/style.css b/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/style.css new file mode 100644 index 0000000000..6e17c2747b --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-09/ui-contribution/src/main/resources/style.css @@ -0,0 +1,135 @@ +/* + * 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. + */ + + + +/*******************************************/ + +p,table,li,h1,h2,h3 +{ +font-family: verdana, arial, 'sans serif'; +} + +p, h1, h2, h3, table, li, hr +{ +margin-left: 10pt; +} + +table +{ +border-color: black; +border-collapse: separate; +border-spacing: 0px 1px; + +margin-right: 10pt; +margin-left: 10pt; +width: 800px; +} + +.sourceDetailsTable +{ +width: 600px; +} + +tr, td +{ +margin-left: 0pt; +margin-right: 0pt; +padding-left: 10pt; +font-size: 90%; +} + +p,li,th +{ +font-size: 90%; +margin-left: 10pt; +} + +pre +{ +margin-left: 10pt; +} + +body +{ +#ffffff; +} + +h1,h2,h3,hr +{ +color: firebrick; +} + +a:link {COLOR: firebrick;} +a:visited {COLOR: firebrick;} +a:active {COLOR: navy;} + +.link +{ +COLOR: firebrick; +text-decoration: underline; +} + +.clickable +{ +cursor: pointer +} + +.unread_title +{ +font-weight: bold; +} + +.read_title +{ +font-weight: normal; +} + +.summary +{ +color: DimGrey; +} + +.hidden +{ +display: none; +} + +.source_name +{ +width: 600px; +} + +.alert_text +{ +width: 600px; +} + +.alert_data +{ +margin-left: 10px; +width: 800px; +height: 800px; +} + +.source_0 +{ +background-color: LightGreen; +} + |