Apache Tuscany > implementation.script User List | Dev List | Issue Tracker  

<implementation.script>

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

Any language that supports the "Scripting for Java" APIs defined by JSR-223 is supported, this includes Groovy, JavaScript, JRuby, Jython, and many others.

To use these languages the SCA assembly SCDL is extended with an "implementation.script" element which has the following options:

<implementation.script [ script="" | language="" ] >
     [inline src]
</implementation.script>

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 <implementation.script> element.

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.

Some examples:

A Ruby program defined in a file 'myScript.rb' in a folder named 'test':

<implementation.script script="test/myScript.rb"/>

A JavaScript program defined inline:

<implementation.script language="js">
      function sayHello(name) {
         return "Hello " + name;
      }
</implementation.script>

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:

<implementation.script language="js"><![CDATA[
      function sayHello(inXML) {
         return <sayHelloResponse>Hello { inXML..name }</sayHelloResponse>;
      }
]]></implementation.script>