summaryrefslogtreecommitdiffstats
path: root/sandbox/ant/container.script/doc/sca-java-container-script.xml
blob: ec100de245cfe1e381bf462f3ee78beb5aa7e82c (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
<?xml version="1.0" encoding="UTF-8"?>
<document>

    <properties>
       <title>Tuscany</title>
       <bannertitle>Tuscany SCA Java Scripting Language Implementation</bannertitle>
    </properties>

    <body>

<section name="Scripting Language Implementation">

<p>
The Tuscany Java SCA runtime has a script container allowing SCA components to be implemented with a variety of scripting languages.
</p>
<p>
To use the script container you use the &lt;implementation.script&gt; element in the component SCDL. The &lt;implementation.script&gt; element has two attributes, 'script' and 'class'. The 'script' attribute is required and defines the location of the script program. The 'class' attribute is optional and enables specifying the class or prototype to be used if the script language  supports such concepts.
</p>
<p>
The language the script is implemented in is defined by the suffix of the script attribute value. For example, the '.js' suffix indicates a JavaScript program, or '.py' indicates a Python program. The script container uses the <a href='http://jakarta.apache.org/bsf/' target='_blank'>Apache BSF script engine</a>, so any script language supported by BSF can be used as an SCA component implementation.  
</p>

<p>
</p>

<p>
</p>

<p>
</p>

<p>
</p>

<p>
The following example shows the files necessary to implement a simple HelloWorld style SCA component using the script container and a JavaScript program.
</p>

<p>
The composite SCDL:
</p>
<p>
<table width="100%" class="ex" cellspacing="0" bgcolor="#f4f4f4">
<tr><td>
<pre>
&lt;composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
    name="HelloWorldComposite"&gt;

    &lt;component name="HelloWorldComponent"&gt;
        &lt;implementation.script script="HelloWorld.js"/&gt;
    &lt;/component&gt;

&lt;/composite&gt;
</pre>
</td></tr>
</table>
</p>

<p>
and the associated JavaScript program, 'HelloWorld.js':
</p>
<p>
<table width="100%" class="ex" cellspacing="0" bgcolor="#f4f4f4">
<tr><td>
<pre>
function sayHello(s) {
    return "Hello " + s;
}
</pre>
</td></tr>
</table>
</p>

<p>
This next example shows a HelloWorld program using the Ruby language, and the use of the &lt;implementation.script&gt; element 'class' attribute to specifying the class of the component implementation:
</p>
<p>
The composite SCDL:
</p>
<p>
<table width="100%" class="ex" cellspacing="0" bgcolor="#f4f4f4">
<tr><td>
<pre>
&lt;composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
    name="HelloWorldComposite"&gt;

    &lt;component name="HelloWorldComponent"&gt;
        &lt;implementation.script script="HelloWorld.rb" class="Helloworld"/&gt;
    &lt;/component&gt;

&lt;/composite&gt;
</pre>
</td></tr>
</table>
</p>

<p>
and the associated Ruby program, 'HelloWorld.rb':
</p>
<p>
<table width="100%" class="ex" cellspacing="0" bgcolor="#f4f4f4">
<tr><td>
<pre>
class Helloworld

   def sayHello(s) 
      return "Hello to " + s + " from the Ruby World!"
   end

end
</pre>
</td></tr>
</table>
</p>


        </section>
    </body>
</document>