summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/distributed-sca-domain.html
blob: 7aa99478f9bdbd86fda72e327bccfbd01081d4ea (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!--

    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.
-->


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
    <HEAD>
		<!-- generateKeywords macro -->
	    <META name="description" content="Apache Tuscany">
        <META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture,  sca, service component architecture, das, sdo, csa, ruby, opensource">
		<!-- generateKeywords macro end -->
		
        <LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
        <LINK rel="SHORTCUT ICON" href="https://cwiki.apache.org/confluence/display/TUSCANY/$images/favicon.ico">   
        <TITLE>Apache Tuscany : Distributed SCA Domain</TITLE>
    <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
    
    <BODY onload="init()">
        <!-- topNav macro -->
		<TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg">
			<TR>
				<TD valing="top" align="left">
					<A href="https://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
				</TD>
				<TD>
					<A href="http://tuscany.apache.org/"><IMG src="http://tuscany.apache.org/images/TuscanyLogo.jpg" border="0"></A>
				</TD>
				
				<TD width="100%">
					&nbsp;
				</TD>

				<!-- Adds the edit page link to the top banner-->
				<TD valign="bottom">
					<DIV style="padding: 2px 10px; margin: 0px;">
						<A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=66885">
						<IMG src="http://tuscany.apache.org/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
					</DIV>
				</TD>

			</TR>
		</TABLE>
        <!-- topNav macro end -->

		<!-- breadCrumbs macro -->
		<TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
			<TR class="topBar">
				<TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
					&nbsp;<A href="home.html" title="Apache Tuscany">Apache Tuscany</A>&nbsp;&gt;&nbsp;<A href="home.html" title="Home">Home</A>&nbsp;&gt;&nbsp;<A href="sca-overview.html" title="SCA Overview">SCA Overview</A>&nbsp;&gt;&nbsp;<A href="sca-java.html" title="SCA Java">SCA Java</A>&nbsp;&gt;&nbsp;<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Java SCA Documentation Menu</A>&nbsp;&gt;&nbsp;<A href="sca-java-user-guide.html" title="SCA Java User Guide">SCA Java User Guide</A>&nbsp;&gt;&nbsp;<A href="" title="Distributed SCA Domain">Distributed SCA Domain</A>
				</TD>
				
				<TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
				<A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
				</TD>
			</TR>
		</TABLE>
		<!-- breadCrumbs macro end -->


        <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
            <TR>
                <TD align="left" valign="top">

					<!-- pageContent macro -->
					<DIV id="PageContent">
												
						<DIV class="pagecontent">
							<DIV class="wiki-content">
								<TABLE class="sectionMacroWithBorder" border="0" cellpadding="5" cellspacing="0" width="100%"><TBODY><TR>
<TD class="confluenceTd" valign="top" width="15%">
<DIV class="panel" style="background-color: #ECF4D1;border-color: #C3CDA1;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #C3CDA1;background-color: #C3CDA1;"><B>General</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="home.html" title="Home">Home</A><BR>
<A href="http://www.apache.org/licenses/LICENSE-2.0.html" class="external-link" rel="nofollow">License </A><BR>
<A href="sca-java-get-involved.html" title="SCA Java Get Involved">Get Involved</A><BR>
<A href="sca-java-found-a-bug.html" title="SCA Java Found A Bug">Found a Bug?</A></P>
</DIV></DIV>

<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="sca-java.html" title="SCA Java">SCA Java Home</A><BR>
<A href="tuscany-dashboard.html" title="Tuscany Dashboard">SCA Dashboard</A><BR>
<A href="java-sca-tools.html" title="Java SCA Tools">Tools </A><BR>
<A href="tuscany-sca-java-faq.html" title="Tuscany SCA Java - FAQ">FAQ</A></P>
</DIV></DIV>

<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java 1.x</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="sca-java-releases.html" title="SCA Java Releases">Downloads</A><BR>
<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Documentation</A><BR>
<A href="https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk/" class="external-link" rel="nofollow">1.x Source Code</A><BR>
<A href="http://tinyurl.com/8rlxd3" class="external-link" rel="nofollow">Roadmap</A></P>
</DIV></DIV>

<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java 2.x</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="sca-java-2x-releases.html" title="SCA Java 2.x Releases">Downloads</A><BR>
<A href="http://tuscany.apache.org/documentation-2x/" class="external-link" rel="nofollow">Documentation</A><BR>
<A href="https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/" class="external-link" rel="nofollow">2.x Source Code</A><BR>
<A href="http://tinyurl.com/8rlxd3" class="external-link" rel="nofollow">Roadmap</A></P>
</DIV></DIV>


<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>Documentation</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="sca-java-user-guide.html" title="SCA Java User Guide">User Guide</A><BR>
<A href="sca-java-architecture-guide.html" title="SCA Java Architecture Guide">Architecture Guide</A><BR>
<A href="sca-java-development-guide.html" title="SCA Java Development Guide">Developer Guide</A><BR>
<A href="sca-java-extension-development-guide.html" title="SCA Java Extension Development Guide">Extension Developer Guide</A></P>
</DIV></DIV>

<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>Resources</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="tuscany-sca-java-faq.html" title="Tuscany SCA Java - FAQ">FAQ</A><BR>
<A href="https://svn.apache.org/repos/asf/incubator/tuscany/java/sca" class="external-link" rel="nofollow">Source Code</A></P>
</DIV></DIV>
</TD>
<TD class="confluenceTd" valign="top" width="85%">

<H1><A name="DistributedSCADomain-CreateADistributedApplication"></A>Create A Distributed Application</H1>

<P>An SCA assembly can be run in a single or multi-node environment. Here we introduce the Tuscany node and SCA domain and explain how the calculator example can be distributed across multiple nodes. </P>

<H2><A name="DistributedSCADomain-Nodes"></A>Nodes</H2>

<P>Node is a Tuscany specific term (you won't find it in the OASIS SCA specifications). The node wraps the Tuscany SCA runtime. The runtime comprises the modules that are present in the modules directory of the Tuscany SCA Java distribution. As you might expect there are functions that read XML, create an in memory model of the SCA assembly, create the components and wire them together ready to process incoming messages. </P>

<P>A node runs an SCA assembly described by one or more composite files. A node runs in a single JVM. You can start more than one node in a single JVM if you need to but we only tend to do this for testing purposes. In the first section of the user guide we built a <A href="http://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/samples/calculator/" class="external-link" rel="nofollow">calculator sample</A> that included Calculator, Add, Subtract, Multiply and Divide components included in a single composite. </P>

<P><SPAN class="image-wrap" style="display: block; text-align: center"><IMG src="distributed-sca-domain.data/calculator2.png" style="border: 0px solid black"></SPAN></P>

<P>The composite was run using the following API;</P>

<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
        node = SCANodeFactory.newInstance().createSCANodeFromClassLoader(<SPAN class="code-quote">&quot;Calculator.composite&quot;</SPAN>, getClass().getClassLoader());
        node.start();
</PRE>
</DIV></DIV>

<P>This loads the named composite, and any associated resources, and then starts the node to start up all of the components within the composite. </P>

<H3><A name="DistributedSCADomain-ConfiguringNodes"></A>Configuring Nodes</H3>

<P>Creating a node in code is straightforward. For example,</P>

<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
SCANode2 node = SCANodeFactory.newInstance().createSCANodeFromClassLoader(<SPAN class="code-quote">&quot;calculator.composite&quot;</SPAN>, <SPAN class="code-keyword">null</SPAN>);
</PRE>
</DIV></DIV>
<P>Here the &quot;null&quot; parameter means that the node factory uses the current class' classloader to locate the named composite file. The location of the composite file is assumed to be the location of the SCA contribution. The assumption here is that only one contribution is required. </P>

<P>If more contributions must be loaded by the node the following interface can be used.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
SCANode2  node = SCANodeFactory.newInstance().createSCANode(<SPAN class="code-quote">&quot;file:/C:/CalculatorContribution1/Calculator.composite&quot;</SPAN>,
        		                               <SPAN class="code-keyword">new</SPAN> SCAContribution(<SPAN class="code-quote">&quot;CalculatorContribution1&quot;</SPAN>,
        		                                                               <SPAN class="code-quote">&quot;file:/C:/CalculatorContribution1&quot;</SPAN>),
                                                       <SPAN class="code-keyword">new</SPAN> SCAContribution(<SPAN class="code-quote">&quot;CalculatorContribution2&quot;</SPAN>,
        		                                                               <SPAN class="code-quote">&quot;file:/C:/CalculatorContribution2&quot;</SPAN>));
</PRE>
</DIV></DIV>
<P>Where</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
<SPAN class="code-quote">&quot;file:/C:/CalculatorContribution1/Calculator.composite&quot;</SPAN>
</PRE>
</DIV></DIV>
<P>Is the explicit location of the composite file to be run and</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
<SPAN class="code-keyword">new</SPAN> SCAContribution(<SPAN class="code-quote">&quot;CalculatorContribution1&quot;</SPAN>,
                    <SPAN class="code-quote">&quot;file:/C:/CalculatorContribution1&quot;</SPAN>)
</PRE>
</DIV></DIV>
<P>Shows how to provide contribution details. The first parameter &quot;CalculatorContribution1&quot; gives a name for the contribution. The second parameter tells the node where to find the contribution. As this second parameter is a URL the contribution can be read from disk or directly from the network. </P>

<P>Using multiple contributions can be useful if, for example, you have chosen to separate common artifacts from those specific to this composite. The contribution containing common artifacts can then be used in other SCA applications without change.</P>

<H3><A name="DistributedSCADomain-StartingaNode"></A>Starting a Node</H3>

<P>Once the node is created it is configured and ready to be started. It can be started as follows.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
node.start();
</PRE>
</DIV></DIV>

<H3><A name="DistributedSCADomain-LocatingServices"></A>Locating Services</H3>

<P>If the node has been created from within a piece of Java code using the node fatory interface a local service reference can be retrieved in the following way.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
calculatorService = ((SCAClient)node).getService(CalculatorService.class, <SPAN class="code-quote">&quot;CalculatorServiceComponent&quot;</SPAN>);
</PRE>
</DIV></DIV>

<P>One a node has been started all of its remote bindings will be active so you can also access the component services that the node contains via any remote bindings that they define. </P>

<H3><A name="DistributedSCADomain-StoppingaNode"></A>Stopping a Node</H3>

<P>If you are done with the node or need to stop it processing messages use the following.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
node.stop();
</PRE>
</DIV></DIV>


<H2><A name="DistributedSCADomain-SCADomain"></A>SCA Domain</H2>

<P>When running standalone a node defines the scope of component services that references can target by name. SCA defines the term SCA Domain to describe this scope. Section 10 of the SCA Assembly specification actually describes an SCA Domain as defining &quot;the boundary of visibility for all SCA mechanisms&quot;.</P>

<P>In a standalone node a reference can only target services that are running within the same node. However nodes running in separate JVMs can be configured to run an SCA assembly in a distributed fashion. In this way components running on one node can reference components running on a separate node. To make this configuration work the nodes must be running as part of the same distributed SCA domain. In Tuscany a distributed SCA domain is represented using a separate domain manager process. </P>

<H3><A name="DistributedSCADomain-Creatingcompositestorunacrossmultiplenodes."></A>Creating composites to run across multiple nodes. </H3>
<P>From the <A href="http://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/samples/calculator/" class="external-link" rel="nofollow">calculator sample</A> you can see that the wires between the component references and services, formed by adding a target component name to a reference, are resolved inside an SCA domain comprising a single node. </P>

<P><SPAN class="image-wrap" style="display: block; text-align: center"><IMG src="distributed-sca-domain.data/calculator2.png" style="border: 0px solid black"></SPAN></P>

<P>For example, this section of the calculator composite file shows how the CalcuatorServiceComponent targets the AddServiceComponent.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
&lt;composite xmlns=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//www.osoa.org/xmlns/sca/1.0&quot;</SPAN>
</SPAN>           targetNamespace=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//sample&quot;</SPAN>
</SPAN>           xmlns:sample=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//sample&quot;</SPAN>
</SPAN>           name=<SPAN class="code-quote">&quot;Calculator&quot;</SPAN>&gt;
    &lt;component name=<SPAN class="code-quote">&quot;CalculatorServiceComponent&quot;</SPAN>&gt;
        &lt;implementation.java class=<SPAN class="code-quote">&quot;calculator.CalculatorServiceImpl&quot;</SPAN>/&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;addService&quot;</SPAN> target=<SPAN class="code-quote">&quot;AddServiceComponent&quot;</SPAN> /&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;subtractService&quot;</SPAN> target=<SPAN class="code-quote">&quot;SubtractServiceComponent&quot;</SPAN> /&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;multiplyService&quot;</SPAN> target=<SPAN class="code-quote">&quot;MultiplyServiceComponent&quot;</SPAN> /&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;divideService&quot;</SPAN> target=<SPAN class="code-quote">&quot;DivideServiceComponent&quot;</SPAN> /&gt;
    &lt;/component&gt;

    &lt;component name=<SPAN class="code-quote">&quot;AddServiceComponent&quot;</SPAN>&gt;
        &lt;implementation.java class=<SPAN class="code-quote">&quot;calculator.AddServiceImpl&quot;</SPAN>/&gt;
    &lt;/component&gt;
 
    ...
&lt;/composite&gt;
</PRE>
</DIV></DIV>
<P>The target=&quot;AddServiceComponent&quot; of the CalculatorServiceComponent's addService reference refers to the AddServiceComponent defined later on in this composite. A single composite must run on a single node so to distribute this application we need to separate it into more than one composite.</P>

<P>In the <A href="http://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/samples/calculator-distributed/" class="external-link" rel="nofollow">distributed calculator</A> sample the composite defines the calculator component but not the add component;</P>

<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
&lt;composite xmlns=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//www.osoa.org/xmlns/sca/1.0&quot;</SPAN>
</SPAN>           targetNamespace=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//sample&quot;</SPAN>
</SPAN>           xmlns:sample=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//sample&quot;</SPAN>
</SPAN>           name=<SPAN class="code-quote">&quot;Calculator&quot;</SPAN>&gt;
    &lt;component name=<SPAN class="code-quote">&quot;CalculatorServiceComponent&quot;</SPAN>&gt;
        &lt;implementation.java class=<SPAN class="code-quote">&quot;calculator.CalculatorServiceImpl&quot;</SPAN>/&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;addService&quot;</SPAN> target=<SPAN class="code-quote">&quot;AddServiceComponent&quot;</SPAN> /&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;subtractService&quot;</SPAN> target=<SPAN class="code-quote">&quot;SubtractServiceComponent&quot;</SPAN> /&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;multiplyService&quot;</SPAN> target=<SPAN class="code-quote">&quot;MultiplyServiceComponent&quot;</SPAN> /&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;divideService&quot;</SPAN> target=<SPAN class="code-quote">&quot;DivideServiceComponent&quot;</SPAN> /&gt;
    &lt;/component&gt;
 
    ...
&lt;/composite&gt;
</PRE>
</DIV></DIV>

<P>Another composite defines the add component. </P>

<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
&lt;composite xmlns=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//www.osoa.org/xmlns/sca/1.0&quot;</SPAN>
</SPAN>           targetNamespace=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//sample&quot;</SPAN>
</SPAN>           xmlns:sample=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//sample&quot;</SPAN>
</SPAN>           name=<SPAN class="code-quote">&quot;Add&quot;</SPAN>&gt;

    &lt;component name=<SPAN class="code-quote">&quot;AddServiceComponent&quot;</SPAN>&gt;
        &lt;implementation.java class=<SPAN class="code-quote">&quot;calculator.AddServiceImpl&quot;</SPAN>/&gt;
    &lt;/component&gt;
 
    ...
&lt;/composite&gt;
</PRE>
</DIV></DIV>

<P>These two composites are run by separate nodes within the context of a single domain and the calculator addService reference </P>

<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
&lt;reference name=<SPAN class="code-quote">&quot;addService&quot;</SPAN> target=<SPAN class="code-quote">&quot;AddServiceComponent&quot;</SPAN> /&gt;
</PRE>
</DIV></DIV>

<P>is still be able to find the add component running on a separate node. </P>

<P><SPAN class="image-wrap" style="display: block; text-align: center"><IMG src="distributed-sca-domain.data/calculator3.png" style="border: 0px solid black"></SPAN></P>

<P>So a distributed SCA domain can consist of more than one node/composite and wires can run between components defined in the separate composites. </P>

<H3><A name="DistributedSCADomain-StartingADomain"></A>Starting A Domain</H3>

<P>There is a launcher that has a mainline for starting the domain. For example, </P>

<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
    <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> void main(<SPAN class="code-object">String</SPAN>[] args) <SPAN class="code-keyword">throws</SPAN> Exception {
        DomainManagerLauncher.main(args);
    }
</PRE>
</DIV></DIV>

<P>In the <A href="http://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/samples/calculator-distributed/" class="external-link" rel="nofollow">calculator-distributed</A> sample this code is contained in the class node.LaunchDomain.java. Runing this will run the domain mananger. </P>

<P>This <A href="http://www.ibm.com/developerworks/webservices/library/ws-sca-tuscany/index.html?S_TACT=105AGX04&S_CMP=EDU" class="external-link" rel="nofollow">article</A> that is hosted outside of Tuscany provides a step by step instruction for how to use the Tuscany web-based domain manager UI to administer an SCA domain and how to use the domain administrative UI to deploy an SOA solution comprised of SCA components.</P>

<H3><A name="DistributedSCADomain-ConfiguringADomainThroughTheDomainManagerWebInterface"></A>Configuring A Domain Through The Domain Manager Web Interface</H3>

<P>Once the domain manager is running you can get to the web interface of the default domain by pointing your browser at <A href="http://localhost:9990/ui" class="external-link" rel="nofollow">http://localhost:9990/ui</A>. This provides a number of different pages allowing you to </P>

<UL>
	<LI>Add contributions to the domain</LI>
	<LI>Add node configurations to the domain</LI>
	<LI>Configure composites to run on specific nodes</LI>
	<LI>Start local node instances to test the configuration</LI>
</UL>


<P>When you start the domain manager for the distributed calculator sample you will see the pages already populated with the information needed to execture the sample. </P>

<H3><A name="DistributedSCADomain-ConfiguringaDomainThroughTheFileSystem"></A>Configuring a Domain Through The File System</H3>

<P>Behind the domain manager web application there are three files where the configuration information is stored. </P>

<P><B>workspace.xml</B> - stores the ID and location of each contribution that has been added to the domain.</P>

<P><B>domain.composite</B> - the virtual domain composite. This is an SCA composite that represents the virtual domain which includes all of the composites that will run in the domain. A URI is provided which indicates which contribution each composite comes from. Ultimately an SCANode instance will be started for each composite included in the virtual domain. Each SCANode instance can be running on separate/distributed processors. So the virtual domain is a consolidated description of you distributed SCA application</P>

<P><B>cloud.composite</B> - describes the compute cloud (the set of distributed SCANode instances) being used to run the SCA application. Each node is assigned a composite and also has details of the configuration of bindings when they run on that node, for example, the root URI is set. It's possibly slightly confusing that this file is in SCA composite format also but this is a convenience because firstly we didn't have to create a new file format and secondly there may be some benefit in the future of representing this network of nodes as a network of SCA services for management purposes although we don't do that yet.</P>

<P>These files are updated when you make changes to the domain through the domain manager interface but they have a fairly simple XML format and can be edited manually or new utilities could be constructed to edit them automatically. In the distributed calculator sample you can find these files in the root directory. </P>

<H3><A name="DistributedSCADomain-ConnectiontononSCAservices"></A>Connection to non-SCA services</H3>

<P>To connect to services outside of the SCA Domain (whether they be services provided by SCA or by other means) you can still configure an explicit binding, for example,  lets now assume that the DivideServiceComponent is a non-sca web service out there on the network somewhere. As this is outside the SCA domain we can use an explicit remote binding to talk to it.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
&lt;component name=<SPAN class="code-quote">&quot;CalculatorServiceComponent&quot;</SPAN>&gt;
		&lt;implementation.java class=<SPAN class="code-quote">&quot;calculator.CalculatorServiceImpl&quot;</SPAN>/&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;addService&quot;</SPAN> &gt;&lt;/reference&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;subtractService&quot;</SPAN> target=<SPAN class="code-quote">&quot;SubtractServiceComponent&quot;</SPAN>&gt;&lt;/reference&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;multiplyService&quot;</SPAN> target=<SPAN class="code-quote">&quot;MultiplyServiceComponent&quot;</SPAN>&gt;&lt;/reference&gt;
        &lt;reference name=<SPAN class="code-quote">&quot;divideService&quot;</SPAN> target=<SPAN class="code-quote">&quot;DivideServiceComponent&quot;</SPAN>&gt;
            &lt;binding.ws uri=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//localhost:8080/sample-calculator-ws-webapp/AddServiceComponent&quot;</SPAN>/&gt;
</SPAN>        &lt;/reference&gt;
    &lt;/component&gt;
</PRE>
</DIV></DIV>

<H3><A name="DistributedSCADomain-StartingNodesInADistributedDomain"></A>Starting Nodes In A Distributed Domain</H3>

<P>The domain manager is used to pre-process each composited prior to the composites being deployed to nodes for running. Contributions (containing the composites) are added to the domain manager. Configuration must be provided which tells the domain manager where the nodes are that are going to run the composites and which composites they will run. Based on this information the domain manager makes an atom feed available for each composite that is deployed to a node. The node to which the composite is assigned must read the correct atom feed in order to configure itself by downloading the composite to run and the contributions required provide the artifacts required by the composite. There is a Node API that takes as input the URL of an atom feed exposed by the domain manager as follows. </P>

<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
SCANode2 node = SCANodeFactory.newInstance().createSCANodeFromURL(<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//localhost:9990/node-config/NodeA&quot;</SPAN>);</SPAN>
</PRE>
</DIV></DIV>

<P>The URL <A href="http://localhost:9990/node-config/NodeA" class="external-link" rel="nofollow">http://localhost:9990/node-config/NodeA</A> is the URL of the atom feed that the domain manager provides.</P>

<P>The domain manager processes all the relationships between all composite components and provides a fully configured composite to each node, i.e. all of the binding URIs are filled out correctly so it's basically a pre-processing step.</P>

<P>In the <A href="http://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/samples/calculator-distributed/" class="external-link" rel="nofollow">calculator-distributed</A> sample java classes are provided which are set up ready to start the required nodes. Look at the files.</P>

<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
node.LaunchCalculatorNodeA
node.LaunchCalculatorNodeB
node.LaunchCalculatorNodeC
</PRE>
</DIV></DIV>

<P>The README provided with the samples gives more detailed instruction on how to run the sample.</P>
</TD></TR></TBODY></TABLE>
							</DIV>
						</DIV>
					</DIV>	
		            <!-- pageContent macro end -->
					
                </TD>
            </TR>
        </TABLE>

		<!-- footer macro -->
				<SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
		</SCRIPT>
		<SCRIPT type="text/javascript">
		   _uacct = "UA-1174707-5";
		   urchinTracker();
		</SCRIPT>
		
				<A href="http://www.statcounter.com/" target="_blank"><IMG src="http://c26.statcounter.com/counter.php?sc_project=2619156&java=0&security=94bd7e7d&invisible=0" alt="website stats" border="0"></A>    

		<DIV class="footer">
			Copyright � 2003-2012, The Apache Software Foundation&nbsp;&nbsp;</BR>
                        Apache Tuscany and the Apache Tuscany project logo are trademarks of The Apache Software Foundation.
		</DIV>
		<!-- footer macro end -->

    </BODY>
</HTML>