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
|
Notification Producer Binding Sample
===============================
This sample illustrates the use of <binding.notification/> with a
remote producer.
The README in the samples directory (the directory above this) provides
general instructions about building and running samples. Take a look there
first.
Sample Overview
---------------
This sample illustrates the use of a notification producer that is located in a
separate (and remote) composite with respect to any consumers. As such, this sample
is run in conjunction with the binding-notification-consumer sample, the
binding-notification-broker sample, or both. Take a look at the composite file
or the .svg file which shows the composite file in pictorial form. The composite
reference, referred to by the notification component, has a <binding.notification/>
that handles the remote communication. This binding includes an 'ntm' attribute
that refers to the notification type manager, which manages the connectivity of
producers, consumers and brokers, and which (for this sample) is assumed to be
running on http://localhost:8083. The ntm is a system component that is included in
and runs as part of the binding-notification module.
This sample also illustrates the use of a wsdl interface in the notification
component's <implementation.notification/>. This allows messages sent and received
via <binding.notification/> to be transported as literal xml over http.
Building And Running The Sample Using Ant
-----------------------------------------
With the binary distribution the sample can be built and run using Ant as
follows
cd binding-notification-producer
ant compile
ant run
You should see the following output from the run target.
run:
[java] Sep 14, 2007 10:31:45 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping
[java] INFO: Added Servlet mapping: http://localhost:8083/ntm/trafficAdvisory
[java] Sep 14, 2007 10:31:45 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping
[java] INFO: Added Servlet mapping: http://localhost:8083/producer/trafficAdvisory
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 binding-notification-producer
mvn
You should see the following output from the test phase.
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running notification.producer.TrafficAdvisoryTestCase
Only instantiating and closing domain ...
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.252 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
This shows that the Junit test cases have run successfully.
Sample Usage
------------
This sample is run using the tuscany binary distribution. To run it, navigate to this sample's directory and
on Wondows, use following command:
java -Dnotification.httpPort=8083 -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-binding-notification-producer.jar notification.producer.TrafficAdvisoryServer
on *nix, use following command:
java -Dnotification.httpPort=8083 -cp ../../lib/tuscany-sca-manifest.jar:target/sample-binding-notification-producer.jar notification.producer.TrafficAdvisoryServer
this should bring up the following prompt:
Send a report value, ^C or <end> to end
at this point you should be able to type a message to send, for instance:
Traffic congestion
Notice that before you try to send any message, you should bring up the
consumer sample or the broker sample. When you have finished using this
sample, type 'end' or ^C to end.
Also notice that '-Dnotification.httpPort=8083' is used in the java command.
This indicates the port the sample should use. This also says that this server
is going to play the role of ntm, given our previous assumption. It is important
that the first one of the producer, consumer or broker sample that is run be the
one that uses '-Dnotification.httpPort=8083', otherwise there is no ntm to talk
to and an exception will be thrown.
Sample directory structure:
---------------------------
binding-notification-producer/
src/
main/
java/
notification.producer/
TestCaseProducer.java - interface for the producer component
TrafficAdvisory.java - remote interface referred to by the producer component
TrafficAdvisoryProducer.java - implementation for the producer component
TrafficAdvisoryServer.java - server class including main entry point
resources/
wsdl/
TrafficAdvisory.wsdl - remote interface for the notification component
TrafficAdvisoryNotification.componentType - the component type referred to by
<implementation.notification/>
TrafficAdvisoryNotification.composite - the main composite including producer and
notification components, and composite reference
test/
java/
notification.producer/
TrafficAdvisoryTestCase.java - JUnit test case
resources/
wsdl/
TrafficAdvisory.wsdl - remote interface for the notification component
TrafficAdvisoryNotification.componentType - the component type referred to by
<implementation.notification/>
TrafficAdvisoryNotification.composite - the main composite including producer and
notification components, and composite reference
binding-notification-producer.png - a pictorial representation of the sample .composite file
build.xml - the Ant build file
pom.xml - the Maven build file
|