summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/javascaimplementationscript.html
blob: 9200c6f45390e65f49c202cdefc53e8dec3d3f7b (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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
    <HEAD>
        <LINK type="text/css" rel="stylesheet" href="http://people.apache.org/~svkrish/tuscanySite/style/default.css">
        <LINK rel="SHORTCUT ICON" href="http://cwiki.apache.org/confluence/pages/$images/favicon.ico">   
        <TITLE>Java+SCA+implementation.script : Apache Tuscany</TITLE>
    <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
    
    <BODY onload="init()">
        
            <TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://people.apache.org/~svkrish/tuscanySite/images/TuscanyLogoNEW_Text_120px_bg.jpg">
        <TR>
            <TD valing="top" align="left">
                <A href="http://cwiki.apache.org/confluence/pages/$siteroot"><IMG src="http://people.apache.org/~svkrish/tuscanySite/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="http://cwiki.apache.org/confluence/pages/editpage.action?pageId=55156">
                    <IMG src="http://people.apache.org/~svkrish/tuscanySite/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
                </DIV>
            </TD>

        </TR>
    </TABLE>

            <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="" title="Java+SCA+implementation.script">Java+SCA+implementation.script</A>
            </TD>
            
            <TD align="left" valign="middle" class="topBarDiv" nowrap="true">
            <A href="http://mail-archives.apache.org/mod_mbox/ws-tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/ws-tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
            </TD>
        </TR>
    </TABLE>

        <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
            <TR>
                <TD align="left" valign="top">
                        <DIV id="PageContent">
                
        <DIV class="pagecontent">
            <DIV class="wiki-content">
                <TABLE class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><TBODY><TR>
<TD class="confluenceTd" valign="top" width="15%">
<DIV class="panel" style="border-style: solid; border-color: #b4b4b5; "><DIV class="panelHeader" style="border-bottom-style: solid; border-bottom-color: #b4b4b5; background-color: #C3CDA1; "><B>General</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="sca-downloads.html" title="SCA Downloads">Downloads</A><BR>
<A href="sca-java-whats-new.html" title="SCA Java Whats New">What's New?</A></P>
</DIV></DIV>

<DIV class="panel" style="border-style: solid; border-color: #b4b4b5; "><DIV class="panelHeader" style="border-bottom-style: solid; border-bottom-color: #b4b4b5; background-color: #C3CDA1; "><B>Guides</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-extension-guide.html" title="SCA Java Extension Guide">Extension Guide</A><BR>
<A href="java-sca-architecture-guide.html" title="Java SCA Architecture Guide">Architecture Guide</A><BR>
<A href="sca-java-development.html" title="SCA Java Development">Developer Guide</A><BR>
<A href="java-sca-extension-developer-guide.html" title="Java SCA Extension Developer Guide">Extension Developer Guide</A></P>
</DIV></DIV>

<DIV class="panel" style="border-style: solid; border-color: #b4b4b5; "><DIV class="panelHeader" style="border-bottom-style: solid; border-bottom-color: #b4b4b5; background-color: #C3CDA1; "><B>Development</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1; ">
<P><SPAN class="nobr"><A href="http://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANY&title=SCA%20Java%20Doc&linkCreation=true&fromPageId=47581" title="Create Page: SCA Java Doc" class="createlink">Java Doc<SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/plus.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN><BR>
<SPAN class="nobr"><A href="https://svn.apache.org/repos/asf/incubator/tuscany/java/sca" title="Visit page outside Confluence" rel="nofollow">Java SCA Source <SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></P>
</DIV></DIV></TD>
<TD class="confluenceTd" valign="top" width="85%">

<H3><A name="Java%2BSCA%2Bimplementation.script-%3Cimplementation.script%3E"></A>&lt;implementation.script&gt;</H3>

<P>The Tuscany Java SCA runtime supports implementing SCA components in a wide variety of dynamic or scripting languages by using the &lt;implementation.script&gt; SCDL extension.</P>

<P>Any language that supports the &quot;Scripting for Java&quot; APIs defined by JSR-223 is supported, this includes Groovy, JavaScript, JRuby, Jython, and many others.</P>

<P>To use these languages the SCA assembly SCDL is extended with an &quot;implementation.script&quot; element which has the following options:</P>


<DIV class="code"><DIV class="codeContent">
<PRE class="code-java">&lt;implementation.script [ script=<SPAN class="code-quote">&quot;&quot; | language=&quot;</SPAN>&quot; ] &gt;
     [inline src]
&lt;/implementation.script&gt;</PRE>
</DIV></DIV>

<P>The source code for the script maybe defined in a seperate file pointed to by the 'script=' attribute, or the source code maybe embedded within the SCDL inline inside the &lt;implementation.script&gt; element.</P>

<P>The 'language=' attribute defines the language of the program. The language attribute is optional when the source code is in a separate file in which case the file extension of the file is used to determine the language.</P>

<H4><A name="Java%2BSCA%2Bimplementation.script-Someexamples%3A"></A>Some examples:</H4>


<P>A Ruby program defined in a file 'myScript.rb' in a folder named 'test':</P>

<DIV class="code"><DIV class="codeContent">
<PRE class="code-java">&lt;implementation.script script=<SPAN class="code-quote">&quot;test/myScript.rb&quot;</SPAN>/&gt;</PRE>
</DIV></DIV>


<P>A JavaScript program defined inline:</P>

<DIV class="code"><DIV class="codeContent">
<PRE class="code-java">&lt;implementation.script language=<SPAN class="code-quote">&quot;js&quot;</SPAN>&gt;
      function sayHello(name) {
         <SPAN class="code-keyword">return</SPAN> <SPAN class="code-quote">&quot;Hello &quot;</SPAN> + name;
      }
&lt;/implementation.script&gt;</PRE>
</DIV></DIV>


<P>When using inline scripts which contain special characters such as XML markup you may need to enclose the source within a CDATA region, for example:</P>

<DIV class="code"><DIV class="codeContent">
<PRE class="code-java">&lt;implementation.script language=<SPAN class="code-quote">&quot;js&quot;</SPAN>&gt;&lt;![CDATA[
      function sayHello(inXML) {
         <SPAN class="code-keyword">return</SPAN> &lt;sayHelloResponse&gt;Hello { inXML..name }&lt;/sayHelloResponse&gt;;
      }
]]&gt;&lt;/implementation.script&gt;</PRE>
</DIV></DIV>

</TD></TR></TBODY></TABLE>
            </DIV>
        </DIV>
    </DIV>
                </TD>
            </TR>
        </TABLE>

            <DIV class="footer">
        Copyright &copy; 2003-2007, The Apache Software Foundation&nbsp;&nbsp;
    </DIV>

    </BODY>
</HTML>