summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.1/samples/osgi-supplychain/README
blob: 11fecf2ae8fcee2c2ab456e3f11177560681cb1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
osgi-supplychain Sample
=======================

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.

If you just want to run it to see what happens open a command prompt, navigate
to this sample directory and do:

ant run

OR if you don't have ant, on Windows do

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


Sample Overview
---------------

The sample provides a Customer service with a purchaseGoods operation
and a notifyShipment operation annotated with the SCA @OneWay annotation.
The SupplyChainClient exercises this interface by calling the
purchaseGoods operation. This results in messages passing to 
the Retailer, Warehouse, and Shipper components and the result returned
to the Customer service on a separate callback thread. The Customer
and Shipper components are implemented as OSGi bundles which use
implementation.osgi, while the Retailer and Warehouse components are
implemented using implementation.java.


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
   

  build.xml                            - the Ant build file
  pom.xml                              - the Maven build file   

Understanding OSGI implementation files
---------------------------------------
Some of the files introduced by OSGI implementation are explained below.

OSG files related to customer. java are:
OSGiCustomerComponentImpl.java: OSGi Declarative Services Implementation of the SCA Customer component. 
OSGiCustomerImpl.java: OSGi Procedural Services Implementation of the SCA Customer component. 

You notice the same pattern for shipper.java, retailer.java, SupplyChainClient.java.

The rest of OSGI related files are:
OSGiBundleImpl.java: Common code for OSGi Procedural Services Implementation of the SCA components
 
resources/osgi/*.mf: Manifest files for OSGi bundles for OSGi procedural services implementation
 
resources/osgi/ds/*.m:f 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 
 
Building And Running The Sample Using Ant
-----------------------------------------
cd osgi-supplychain
ant compile 
ant run

you should see: 
Buildfile: build.xml

run:
     [java] Main thread Thread[main,5,main]
     [java] Started OSGi bundle with activator OSGiCustomerImpl
     [java] Started OSGi bundle with activator OSGiShipperImpl
     [java] Main thread sleeping ...
     [java] Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfi
lled, shipped
     [java] Stop OSGi bundle with activator OSGiShipperImpl
     [java] Stop OSGi bundle with activator OSGiCustomerImpl


Building And Running The Sample Using Maven 
-------------------------------------------
With either the binary or source distributions the sample can be built and run 
using Maven as follows. 

cd osgi-supplychain
mvn

You should see the following output from the test phase.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running supplychain.SupplyChainClientTestCase
Started OSGi bundle with activator OSGiCustomerImpl
Started OSGi bundle with activator OSGiShipperImpl
Sleeping ...
Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfilled, shippe
d
Test complete
Stop OSGi bundle with activator OSGiShipperImpl
Stop OSGi bundle with activator OSGiCustomerImpl
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.062 sec

This shows that the Junit test cases have run successfully.