summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/README
blob: 384c8774f4868fd1cb8ddc4a93b81db90d205e33 (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
Calculator CORBA Reference Sample
=================================

This sample illustrates the use of the Tuscany CORBA Binding to reference 
services that are hosted as CORBA services.  

The README in the samples directory (the directory above this) provides 
general instructions about building and running samples. Take a look there 
first. 

If you just want to run it to see what happens open a command prompt, first 
navigate to the calculator-corba-service sample and do:

ant run

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

java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-corba-service.jar calculator.CalculatorCORBAServer

and on *nix do

java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-corba-service.jar calculator.CalculatorCORBAServer

Now you have the server running you need to open another command prompt, navigate
to this sample directory and do:

ant run

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

java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-corba-reference.jar calculator.CalculatorClient

and on *nix do

java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-corba-reference.jar calculator.CalculatorClient

Sample Overview
---------------
This sample extends the calculator sample by replacing the local wired 
connections with CORBA bindings. Instead of local add, subtract, multiply and 
divide components, a CORBA service implementation now provides the
add, subtract, multiply and divide interfaces and is hosted as an CORBA object. 
References specified in the .composite file include a CORBA binding which targets
this CORBA object. The name service which is used in CORBA communication is
provided in the test case class - CalculatorCORBAReferenceTestCase.java.

This sample adds a number of classes to the basic calculator sample:

calculator-corba-reference/
  src/
    main/
      java/
        calculator/
          CalculatorService.java  - as calculator sample
          AddService.java         - as calculator sample
          SubtractService.java    - as calculator sample
          MultiplyService.java    - as calculator sample
          DivideService.java      - as calculator sample
          CalculatorClient.java   - as calculator sample
          CalculatorServiceImpl.java - calls the CORBA service
                                    that provides the target for the 
                                    CORBA bindings in the composite 
      resources/
        CalculatorCORBAReference.composite - the SCA assembly for this sample
    test/
      java/
        calculator/
          CalculatorCORBAReferenceTestCase.java - JUnit test case
          CalculatorCORBAServant.java - CORBA service implementation
          idl/                        - contains files generated 
                                        from the IDL file. Files are 
                                        used to create a CORBA object which
                                        will be consumed by SCA references.
            _CalculatorCORBAServiceImplBase.java
            CalculatorCORBAService.java
            CalculatorCORBAServiceOperations.java
      resources/
        CalculatorCORBA.idl       - IDL description for CORBA object
  pom.xml                         - the Maven build file   
  
Note. As this test creates and uses local network connections you may need to 
configure your firewall, if you are running one, to allow the test to run
successfully.         

Building And Running The Sample Using Ant
-----------------------------------------
With the binary distribution the sample can be built and run using Ant. 

The calculator-corba-service sample provides a CORBA server that acts as a target
for the SCA CORBA binding. Start a new console and use the following commands.

cd calculator-corba-service
ant compile
ant run

This will run up the server and display the following.

run:
     [java] Calculator CORBA server started (press enter to shutdown)
     
The client is very similar to the calculator sample. It starts the SCA runtime
and calls each of the calculator operations. In doing this the CORBA binding
makes calls out to the CORBA server you started in the previous step. Start
a new console and use the following commands. 

cd calculator-corba-reference
ant compile
ant run

You should see the following output from the run target.

run:
     [java] 3 + 2=5.0
     [java] 3 - 2=1.0
     [java] 3 * 2=6.0
     [java] 3 / 2=1.5
     
If you now return to the console window running the server and press enter the 
server should stop.     

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 calculator-corba-reference
mvn

You should see the following output from the test phase.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running calculator.CalculatorCORBAReferenceTestCase
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.308 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

This shows that the Junit test cases have run successfully.