summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/java-sca-implementationscript.html
diff options
context:
space:
mode:
Diffstat (limited to 'site/trunk/site-publish/java-sca-implementationscript.html')
-rw-r--r--site/trunk/site-publish/java-sca-implementationscript.html170
1 files changed, 170 insertions, 0 deletions
diff --git a/site/trunk/site-publish/java-sca-implementationscript.html b/site/trunk/site-publish/java-sca-implementationscript.html
new file mode 100644
index 0000000000..e8b5125f81
--- /dev/null
+++ b/site/trunk/site-publish/java-sca-implementationscript.html
@@ -0,0 +1,170 @@
+
+<!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/display/TUSCANY/$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/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://people.apache.org/~svkrish/tuscanySite/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
+ </TD>
+ <TD>
+ <A href="http://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$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="home.html" title="Home">Home</A>&nbsp;&gt;&nbsp;<A href="java-sca-subproject.html" title="Java SCA Subproject">Java SCA Subproject</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="" 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: #C3CDA1; "><DIV class="panelHeader" style="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>
+<SPAN class="nobr"><A href="http://www.apache.org/licenses/LICENSE-2.0.html" title="Visit page outside Confluence" rel="nofollow">License <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><BR>
+<A href="tuscany-downloads.html" title="Tuscany Downloads">Downloads</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>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>
+<SPAN class="nobr"><A href="http://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANY&title=Java%20SCA%20Documentation&linkCreation=true&fromPageId=55228" title="Create Page: Java SCA Documentation" class="createlink">Documentation <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">Source Code<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="JavaSCAimplementation.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="JavaSCAimplementation.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>
+
+<P>The previous example demonstrated using JavaScript's <SPAN class="nobr"><A href="http://www.ecma-international.org/publications/standards/Ecma-357.htm" title="Visit page outside Confluence" rel="nofollow">E4X<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> language extension for manipulating XML. Many dynamic languages have enhanced XML capabilities like this which can make working with XML much easier than in a more traditional language such as Java. For example, along with JavaScript's E4X, Ruby has ReXML and Groovy has its markup builders. </P>
+
+<P>Tuscany tries to simplify this for the script program developer and will try to automatically ensure arguments are in the native XML format of the language when the component is wired to a WSDL interface. </P>
+
+<P>As an example of this the following shows a composite that can replace the Tuscany helloworld-ws-service sample and requires no other files other than the asscociated WSDL document packaged with the contribution:</P>
+
+<DIV class="code"><DIV class="codeContent">
+<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">//helloworld&quot;</SPAN>
+</SPAN> xmlns:hw=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//helloworld&quot;</SPAN>
+</SPAN> name=<SPAN class="code-quote">&quot;helloworldws&quot;</SPAN>&gt;
+
+ &lt;service name=<SPAN class="code-quote">&quot;HelloWorldService&quot;</SPAN> promote=<SPAN class="code-quote">&quot;HelloWorldServiceComponent&quot;</SPAN>&gt;
+ &lt;<SPAN class="code-keyword">interface</SPAN>.wsdl <SPAN class="code-keyword">interface</SPAN>=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//helloworld#wsdl.<SPAN class="code-keyword">interface</SPAN>(HelloWorld)&quot;</SPAN> /&gt;
+</SPAN> &lt;binding.ws uri=&quot;&quot;/&gt;
+ &lt;/service&gt;
+
+ &lt;component name=<SPAN class="code-quote">&quot;HelloWorldServiceComponent&quot;</SPAN>&gt;
+ &lt;implementation.script language=<SPAN class="code-quote">&quot;js&quot;</SPAN>&gt;&lt;![CDATA[
+
+ function getGreetings(xmlIn) {
+ <SPAN class="code-keyword">return</SPAN> &lt;ns1:getGreetings xmlns:ns1=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//helloworld&quot;</SPAN>&gt;
+</SPAN> &lt;ns1:name&gt;Hello { xmlIn..name }&lt;/ns1:name&gt;
+ &lt;/ns1:getGreetings&gt;
+ }
+
+ ]]&gt;&lt;/implementation.script&gt;
+ &lt;/component&gt;
+
+&lt;/composite&gt;</PRE>
+</DIV></DIV>
+
+<TABLE cellpadding="5" width="85%" cellspacing="8px" class="noteMacro" border="0" align="center"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD><B class="strong">Best practice?</B><BR>
+<P>Using inline scripts can make creating simple components very easier however there are issues around whether or not this is good practice. <BR>
+Depending on the circumstance consideration should be given as to if it would be better to define the script in a seperate file.</P></TD></TR></TABLE>
+
+<TABLE cellpadding="5" width="85%" cellspacing="8px" class="noteMacro" border="0" align="center"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD><B class="strong">0.90</B><BR>
+<P>In release 0.90 and before, inline scripts are not supported and scripts require an associated .componentType side file</P></TD></TR></TABLE>
+
+</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> \ No newline at end of file