Tuscany Supply Chain Sample using OSGi

Overview

The Tuscany OSGi supply chain sample shows using the Tuscany SCA runtime in a J2SE environment executing the SCA asynchronous API with OSGi and Java implementation types.

Location

This sample is located  in the samples\osgi-supplychain directory.

Setup

This sample depends on the Tuscany runtime and the sample jar, both of these must be available on the classpath to run the sample.

Running

In the directory samples\osgi-supplychain use the JDK 1.5 java command to run the class supplychain.SupplyChainClient
Linux:   java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-osgi-supplychain.jar supplychain.SupplyChainClient
Windows: java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-osgi-supplychain.jar supplychain.SupplyChainClient

Results

The sample when run should simply display on the standard output some startup messages followed by:

Work thread Thread[Thread-1,5,main] - Order, submitted, fulfilled, shipped

Code Overview

The source files are physically organized as shown below:
src
+---main
    +---java
    ¦   +---supplychain
    ¦          OSGiBundleImpl.java
    ¦          SupplyChainClient.java
    ¦         +---customer
    ¦                Customer.java
    ¦                JavaCustomerComponentImpl.java
    ¦                OSGiCustomerComponentImpl.java
    ¦                OSGiCustomerImpl.java
    ¦         +---retailer
    ¦                Retailer.java
    ¦                JavaRetailerComponentImpl.java
    ¦                OSGiRetailerComponentImpl.java
    ¦                OSGiRetailerImpl.java
    ¦         +---shipper
    ¦                Shipper.java
    ¦                JavaShipperComponentImpl.java
    ¦                OSGiShipperComponentImpl.java
    ¦                OSGiShipperImpl.java
    ¦         +---warehouse
    ¦               Warehouse.java
    ¦               JavaWarehouseComponentImpl.java
    ¦               OSGiWarehouseComponentImpl.java
    ¦               OSGiWarehouseImpl.java
    ¦
    +---resources
    ¦   +---osgi
    ¦          Customer.mf
    ¦          Retailer.mf
    ¦          Shipper.mf
    ¦          Warehouse.mf
    ¦        +---ds
    ¦               Customer.mf
    ¦               Retailer.mf
    ¦               Shipper.mf
    ¦               Warehouse.mf
    ¦               Customer.xml
    ¦               Retailer.xml
    ¦               Shipper.xml
    ¦               Warehouse.xml
    ¦      Customer.componentType
    ¦      Retailer.componentType
    ¦      Shipper.componentType
    ¦      Warehouse.componentType
    ¦      supplychain.composite
    ¦      supplychain.ds.composite
  


Customer.java Defines the Java interface implemented by the Customer component.
JavaCustomerComponentImpl.java POJO Implementation of the SCA Customer component.
OSGiCustomerComponentImpl.java OSGi Declarative Services Implementation of the SCA Customer component.
OSGiCustomerImpl.java OSGi Procedural Services Implementation of the SCA Customer component.
Retailer.java Defines the Java interface implemented by the Retailer component.
JavaRetailerComponentImpl.java POJO Implementation of  the SCA RetailerComponent component.
OSGiRetailerComponentImpl.java OSGi Declarative Services Implementation of the SCA Retailer component.
OSGiRetailerImpl.java OSGi Procedural Services Implementation of the SCA Retailer component.
Shipper.java Defines the Java interface implemented by the Shipper component
JavaShipperComponentImpl.java POJO Implementation of the SCA ShipperComponent component.
OSGiShipperComponentImpl.java OSGi Declarative Services Implementation of the SCA Shipper component.
OSGiShipperImpl.java OSGi Procedural Services Implementation of the SCA Shipper component.
Warehouse.java Defines the Java interface implemented by the Warehouse component.
JavaWarehouseComponentImpl.java POJO Implementation of the SCA WarehouseComponent component.
OSGiWarehouseComponentImpl.java OSGi Declarative Services Implementation of the SCA Warehouse component.
OSGiWarehouseImpl.java OSGi Procedural Services Implementation of the SCA Warehouse component.
OSGiBundleImpl.java
Common code for OSGi Procedural Services Implementation of the SCA components
SupplyChainClient.java SupplyChainClient.java loads SCA runtime
SupplyChainClientTestCase.java JUnit test for this sample
resources/osgi/*.mf
Manifest files for OSGi bundles for OSGi procedural services implementation
resources/osgi/ds/*.mf Manifest files for OSGi bundles for OSGi declarative services implementation
resources/osgi/ds/*.xml OSGi Declarative services component xml files
resources/*.componentType
Component types used by OSGi implementation provider for SCA
resources/supplychain.composite
Composite file using OSGi and Java implementation types
resources/supplychain.ds.composite Composite file using OSGi (declarative services) and Java implementation types