summaryrefslogtreecommitdiffstats
path: root/sandbox/rfeng
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-22 05:09:35 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-22 05:09:35 +0000
commit5b1331d035f2960f5fdd6b45c10a0ae6f45a2501 (patch)
treec1ee4bd9052520909c19f5c0acf507aa97d7671d /sandbox/rfeng
parentab50db936a5cb3105bb0696b6e26fdca05b5ebc2 (diff)
Add a OSGi RFC 119 demo for the CreditCardPayment
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@777368 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/rfeng')
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/META-INF/MANIFEST.MF23
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/pom.xml166
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentActivator.java40
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java47
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/CreditCardPayment.wsdl116
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/META-INF/sca-contribution.xml22
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/OSGI-INF/sca/bundle.componentType41
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/OSGI-INF/sca/bundle.composite46
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/creditcard.composite34
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/CreditCardPaymentOSGiTestCase.java120
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/CreditCardPaymentTestCase.java75
-rw-r--r--sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/OSGiTestUtils.java105
12 files changed, 835 insertions, 0 deletions
diff --git a/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/META-INF/MANIFEST.MF b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..e38749adf6
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Private-Package: calculator;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: SCATours CreditCard Payment
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Eclipse-LazyStart: false
+Bundle-Version: 1.0.0
+Bnd-LastModified: 1223949424781
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Calculator OSGi Sample
+Import-Package: javax.jws,
+ javax.xml.bind,
+ javax.xml.bind.annotation,
+ javax.xml.ws,
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.osgi.framework;version="1.4"
+Bundle-SymbolicName: scatours.creditcard.payment
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Bundle-Activator: payment.creditcard.impl.CreditCardPaymentActivator
diff --git a/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/pom.xml b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/pom.xml
new file mode 100644
index 0000000000..e9537280fc
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/pom.xml
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>scatours-creditcard-payment-dosgi</artifactId>
+ <name>SCATours CreditCard Payment OSGi</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.1.200-v20071203</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Equinox Declarative Services -->
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>ds</artifactId>
+ <version>1.0.0-v20080427-0830</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>util</artifactId>
+ <version>1.0.0-v20080414</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <buildcommands>
+ <buildcommand>org.eclipse.pde.ManifestBuilder</buildcommand>
+ <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
+ </buildcommands>
+ <projectnatures>
+ <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+ <projectnature>org.eclipse.pde.PluginNature</projectnature>
+ </projectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+ </classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <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/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentActivator.java b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentActivator.java
new file mode 100644
index 0000000000..43a7c3519b
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentActivator.java
@@ -0,0 +1,40 @@
+/*
+ * 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.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+import payment.creditcard.CreditCardPayment;
+
+/**
+ *
+ */
+public class CreditCardPaymentActivator implements BundleActivator {
+
+ public void start(BundleContext context) throws Exception {
+ System.out.println("Registering CreditCardPayment service...");
+ context.registerService(CreditCardPayment.class.getName(), new CreditCardPaymentImpl(), null);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ }
+
+}
diff --git a/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/java/payment/creditcard/impl/CreditCardPaymentImpl.java
new file mode 100644
index 0000000000..1ddf5be7d6
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-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.oasisopen.sca.annotation.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/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/CreditCardPayment.wsdl b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/CreditCardPayment.wsdl
new file mode 100644
index 0000000000..dbf89924cc
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-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.tuscanyscatours.com/CreditCardPayment/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://www.tuscanyscatours.com/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.tuscanyscatours.com/CreditCardPayment/"
+ xmlns:tns="http://www.tuscanyscatours.com/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.tuscanyscatours.com/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/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..f8ce8b7af7
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/META-INF/sca-contribution.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+ <export.java package="payment.creditcard"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/OSGI-INF/sca/bundle.componentType b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/OSGI-INF/sca/bundle.componentType
new file mode 100644
index 0000000000..70852d88a9
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/OSGI-INF/sca/bundle.componentType
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1">
+ <!-- The service elment defines an SCA view of the OSGi service -->
+ <service name="CreditCardPayment">
+ <!-- The interface will be mapped into the OSGi service class -->
+ <interface.java interface="payment.creditcard.CreditCardPayment"/>
+ <!-- The list of OSGi properties -->
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+
+ <!-- The reference elment defines an SCA proxy to a remote OSGi service -->
+ <!--
+ <reference name="currencyConverter">
+ <interface.java interface="currency.CurrencyConverter"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ -->
+
+</componentType>
diff --git a/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/OSGI-INF/sca/bundle.composite b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/OSGI-INF/sca/bundle.composite
new file mode 100644
index 0000000000..071cff731d
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/OSGI-INF/sca/bundle.composite
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://creditcard"
+ name="CreditCardPaymentComposite">
+
+ <component name="CreditCardPaymentComponent">
+ <tuscany:implementation.osgi bundleSymbolicName="scatours.creditcard.payment" bundleVersion="1.0.0" />
+ <service name="CreditCardPayment">
+ <binding.ws uri="http://localhost:8086/CreditCardPayment"/>
+ </service>
+ <!--
+ <reference name="currencyConverter">
+ <tuscany:binding.rmi uri="rmi://localhost:8085/CurrencyConverter"/>
+ </reference>
+ -->
+ </component>
+
+ <component name="CreditCardPaymentJavaComponent">
+ <implementation.java class="payment.creditcard.impl.CreditCardPaymentImpl" />
+ <service name="CreditCardPayment">
+ <binding.ws uri="http://localhost:8087/CreditCardPayment" />
+ <binding.sca/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/creditcard.composite b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/creditcard.composite
new file mode 100644
index 0000000000..9c69035a10
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/main/resources/creditcard.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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://creditcard"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:c="http://creditcard"
+ name="creditcard">
+
+ <component name="CreditCardPaymentComponent">
+ <implementation.java class="payment.creditcard.impl.CreditCardPaymentImpl" />
+ <service name="CreditCardPayment">
+ <binding.ws uri="http://localhost:8086/CreditCardPayment" />
+ <binding.sca/>
+ </service>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/CreditCardPaymentOSGiTestCase.java b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/CreditCardPaymentOSGiTestCase.java
new file mode 100644
index 0000000000..122e380164
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/CreditCardPaymentOSGiTestCase.java
@@ -0,0 +1,120 @@
+/*
+ * 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.test;
+
+import static payment.creditcard.test.OSGiTestUtils.bundleStatus;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+
+import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+
+/**
+ *
+ */
+public class CreditCardPaymentOSGiTestCase {
+ private static EquinoxHost host;
+ private static BundleContext context;
+ private static Bundle ccBundle;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ try {
+ host = new EquinoxHost();
+ context = host.start();
+
+ for (Bundle b : context.getBundles()) {
+ System.out.println(b);
+ if (b.getSymbolicName().equals("org.eclipse.equinox.ds") || b.getSymbolicName()
+ .startsWith("org.apache.tuscany.sca.")) {
+ try {
+ if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null) {
+ // Start the non-fragment bundle
+ b.start();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println(bundleStatus(b, false));
+ }
+ if ("scatours.creditcard.payment".equals(b.getSymbolicName())) {
+ ccBundle = b;
+ }
+ }
+
+ if (ccBundle != null) {
+ ccBundle.start();
+ System.out.println(bundleStatus(ccBundle, false));
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @Test
+ /**
+ * Test the Web service exposed by the Calculator
+ */
+ public void testWS() throws Exception {
+ URL url = new URL("http://localhost:8086/CreditCardPayment?wsdl");
+ InputStream is = url.openStream();
+ Reader reader = new InputStreamReader(is);
+ char[] content = new char[10240]; // 10k
+ int len = 0;
+ while (true) {
+ int size = reader.read(content, len, content.length - len);
+ if (size < 0) {
+ break;
+ }
+ len += size;
+ }
+ Assert.assertTrue(len > 0);
+ String str = new String(content, 0, len);
+ System.out.println(str);
+ Assert.assertTrue(str.indexOf("<wsdl:definitions") != -1);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (host != null) {
+ host.stop();
+ host = null;
+ context = null;
+ }
+ }
+
+}
diff --git a/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/CreditCardPaymentTestCase.java b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/CreditCardPaymentTestCase.java
new file mode 100644
index 0000000000..5149aac90d
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/CreditCardPaymentTestCase.java
@@ -0,0 +1,75 @@
+/*
+ * 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.test;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import payment.creditcard.CreditCardDetailsType;
+import payment.creditcard.CreditCardPayment;
+import payment.creditcard.CreditCardTypeType;
+import payment.creditcard.ObjectFactory;
+import payment.creditcard.PayerType;
+
+/**
+ *
+ */
+public class CreditCardPaymentTestCase {
+ private static Node node;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+ node = factory.createNode("creditcard.composite", CreditCardPayment.class.getClassLoader());
+ node.start();
+ }
+
+ @Test
+ public void testCreditCardPayment() {
+ CreditCardPayment cc = node.getService(CreditCardPayment.class, "CreditCardPaymentComponent/CreditCardPayment");
+
+ ObjectFactory objectFactory = new ObjectFactory();
+ CreditCardDetailsType ccDetails = objectFactory.createCreditCardDetailsType();
+ ccDetails.setCreditCardType(CreditCardTypeType.fromValue("Visa"));
+ PayerType ccOwner = objectFactory.createPayerType();
+ ccOwner.setName("Fred");
+ ccDetails.setCardOwner(ccOwner);
+
+ System.out.println(cc.authorize(ccDetails, 100.00f));
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (node != null) {
+ node.stop();
+ node = null;
+ }
+ }
+
+}
diff --git a/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/OSGiTestUtils.java b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/OSGiTestUtils.java
new file mode 100644
index 0000000000..1fe64b80a4
--- /dev/null
+++ b/sandbox/rfeng/scatours-creditcard-payment-dosgi-contribution/src/test/java/payment/creditcard/test/OSGiTestUtils.java
@@ -0,0 +1,105 @@
+/*
+ * 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.test;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * Utility class to create OSGi bundles
+ *
+ * @version $Rev: 758877 $ $Date: 2009-03-26 14:51:19 -0700 (Thu, 26 Mar 2009) $
+ */
+public class OSGiTestUtils {
+ private static class InvocationHandlerImpl implements InvocationHandler {
+ private Object instance;
+
+ public InvocationHandlerImpl(Object instance) {
+ super();
+ this.instance = instance;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ Method m = instance.getClass().getMethod(method.getName(), method.getParameterTypes());
+ return m.invoke(instance, args);
+ }
+
+ }
+
+ /**
+ * Returns a string representation of the given bundle.
+ *
+ * @param b
+ * @param verbose
+ * @return
+ */
+ public static String bundleStatus(Bundle bundle, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(bundle.getBundleId()).append(" ").append(bundle.getSymbolicName());
+ int s = bundle.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ if (verbose) {
+ sb.append(" ").append(bundle.getLocation());
+ sb.append(" ").append(bundle.getHeaders());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * A utility to cast the object to the given interface. If the class for the object
+ * is loaded by a different classloader, a proxy will be created.
+ *
+ * @param <T>
+ * @param obj
+ * @param cls
+ * @return
+ */
+ public static <T> T cast(Object obj, Class<T> cls) {
+ if (cls.isInstance(obj)) {
+ return cls.cast(obj);
+ } else {
+ return cls.cast(Proxy.newProxyInstance(cls.getClassLoader(),
+ new Class<?>[] {cls},
+ new InvocationHandlerImpl(obj)));
+ }
+ }
+}