Author: antelder
Date: Sat Dec  2 09:45:46 2006
New Revision: 481584

URL: http://svn.apache.org/viewvc?view=rev&rev=481584
Log:
Add more on scripting to the samples doc

Modified:
    incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html

Modified: incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html?view=diff&rev=481584&r1=481583&r2=481584
==============================================================================
--- incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html 
(original)
+++ incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html Sat 
Dec  2 09:45:46 2006
@@ -91,9 +91,17 @@
   </li>
   <li><a href="#ScriptMediators">Script Mediators</a>
     <ul>
+      <li><a href="#ScriptSetup">Setting up Script Mediator support in 
Synapse</a></li>
+      <ul>
+        <li><a href="#ScriptSetupJavaScript">JavaScript</a></li>
+        <li><a href="#ScriptSetupRuby">Ruby</a></li>
+      </ul>
+    </ul>
+    <ul>
       <li><a href="#Sample500">Sample 500: Introduction to script
         mediators</a></li>
       <li><a href="#Sample501">Sample 501: In-line script mediators</a></li>
+      <li><a href="#Sample503">Sample 503: Ruby script mediators</a></li>
     </ul>
   </li>
 </ul>
@@ -1039,6 +1047,47 @@
 manipulation capabilities, for example JavaScript E4X or Ruby REXML, so this
 makes them well suited for use in the Synapse mediation environment.</p>
 
+<h2><a name="ScriptSetup">Configuring Synapse for Script Mediator 
support</a></h2>
+
+<p>The Synapse Script Mediator is a Synapse extension so all its pre-reqs are
+not installed by default. Before you use script mediators you need to manually
+add the required jars to the Synapse lib directory and do any other 
installation 
+that may be required by the individual scripting languages. This is detailed 
in the
+following sections. 
+</p>
+
+<h3><a name="ScriptSetupJavaScript">JavaScript support</a></h3>
+
+<p>For JavaScript/E4X support you need to copy the following jars to the 
Synapse lib directory:</p>
+
+    <ul>
+      <li><a 
href="http://repo1.maven.org/maven2/bsf/bsf/2.4.0/bsf-2.4.0.jar";>Apache 
BSF</a></li>
+      <li><a 
href="http://repo1.maven.org/maven2/rhino/js/1.6R5/js-1.6R5.jar";>Mozilla 
Rhino</a></li>
+      <li><a 
href="http://repo1.maven.org/maven2/xmlbeans/xbean/2.2.0/xbean-2.2.0.jar";>XmlBeans
 xbean</a></li>
+    </ul>
+
+<p>(Note: You should be able to right click on those links and save the jars 
directly to your Synapse lib directory)</p>
+
+<h3><a name="ScriptSetupRuby">Ruby support</a></h3>
+
+<p>For Ruby support you need to copy the following jars to the Synapse lib 
directory:</p>
+
+    <ul>
+      <li><a 
href="http://repo1.maven.org/maven2/bsf/bsf/2.4.0/bsf-2.4.0.jar";>Apache 
BSF</a></li>
+      <li><a 
href="http://repo1.maven.org/maven2/org/jruby/jruby/0.9.1/jruby-0.9.1.jar";>JRuby</a></li>
+    </ul>
+
+<p>(Note: You should be able to right click on those links and save the jars 
directly to your Synapse lib directory)</p>
+
+<p>In addition to those jars, to use the REXML capabilities of Ruby requires a 
complete JRuby installation. 
+Download and install JRuby from <a 
href="http://dist.codehaus.org/jruby/";>JRuby Home</a>.
+Once installed you need to tell Synapse about the instalation by setting a 
system property when starting Synapse.
+Right now this requires manually editing the Synapse startup script (this will 
be improved in
+a future Synapse release). Edit the bin\synapse.bat file and at the bottom 
find the line starting 
+""%_JAVACMD%" %_SYNAPSE_XML%" and insert the system property 
-Djruby.home="&lt;path to your JRuby install directory&gt;". 
+Note the quote characters around the JRuby directory which are required.
+</P>  
+
 <h2><a name="Sample500">Sample 500:</a></h2>
 
 <p><strong>Objective: Introduction to script mediators</strong></p>
@@ -1048,17 +1097,10 @@
 
 <p><strong>Pre-Requisites:</strong></p>
 
-<p>This sample uses JavaScript/E4X which requires the Mozilla Rhino
-JavaScript interpreter and Apache XmlBeans xbean be installed into your
-Synapse distribution. If you've built Synapse from the src distribution these
-two jars will be in your local Maven repository, otherwise you can download
-them manualy by right clicking on the following links and choosing 'save link
-as...': <a
-href="http://repo1.maven.org/maven2/rhino/js/1.6R3/js-1.6R3.jar";>rhino</a>
-and <a
-href="http://repo1.maven.org/maven2/xmlbeans/xbean/2.2.0/xbean-2.2.0.jar";>xbean</a>.
-Once you've got the two jars copy them to the lib directory of your Synapse
-installation.</p>
+<p>
+This sample uses JavaScript/E4X so first setup support for this in Synapse 
+as described at <a href="#ScriptSetupJavaScript">Configuring JavaScript</a>.
+</p>
 
 <p>Start the Synapse configuration numbered 500: i.e. synapse -sample 500<br>
 Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps
@@ -1095,17 +1137,10 @@
 
 <p><strong>Pre-Requisites:</strong></p>
 
-<p>This sample uses JavaScript/E4X which requires the Mozilla Rhino
-JavaScript interpreter and Apache XmlBeans xbean be installed into your
-Synapse distribution. If you've built Synapse from the src distribution these
-two jars will be in your local Maven repository, otherwise you can download
-them manualy by right clicking on the following links and choosing 'save link
-as...': <a
-href="http://repo1.maven.org/maven2/rhino/js/1.6R3/js-1.6R3.jar";>rhino</a>
-and <a
-href="http://repo1.maven.org/maven2/xmlbeans/xbean/2.2.0/xbean-2.2.0.jar";>xbean</a>.
-Once you've got the two jars copy them to the lib directory of your Synapse
-installation.</p>
+<p>
+This sample uses JavaScript/E4X so first setup support for this in Synapse 
+as described at <a href="#ScriptSetupJavaScript">Configuring JavaScript</a>.
+</p>
 
 <p>Start the Synapse configuration numbered 501: i.e. synapse -sample 501<br>
 Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps
@@ -1125,5 +1160,45 @@
 to perform the transformations. The response from the SimpleStockQuoteService
 is converted into the custom format as expected by the client during the out
 message processing.</p>
+
+<h2><a name="Sample503">Sample 503:</a></h2>
+
+<p><strong>Objective: Script mediators using Ruby</strong></p>
+
+<p>This sample is similar to sample 500 but instead of using JavaScript the
+script language is Ruby using the JRuby interpreter.</p>
+
+<p><strong>Pre-Requisites:</strong></p>
+
+<p>
+This sample uses Ruby so first setup support for this in Synapse 
+as described at <a href="#ScriptSetupRuby">Configuring JRuby</a>.
+</p>
+
+<p>Start the Synapse configuration numbered 503: i.e. bin/synapse -sample 
503<br>
+Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps
+above)</p>
+
+<p>The Ruby script is in a separate file which the Synapse xml
+references by using a static property named 'stockquoteScript'. The script
+has two functions, 'transformRequest' and 'transformResponse', and the
+Synapse xml script element uses the function attribute to specify which
+function to use for the in and out rules.</p>
+
+<p>Execute the custom quote client as 'ant customquote' and check analyze the
+the Synapse debug log output as shown below</p>
+<pre>DEBUG XSLTMediator - Transformation source :&lt;m0:CheckPriceRequest 
xmlns:m0=http://www.apache-synapse.org/test&gt;
+&lt;m0:Code&gt;IBM&lt;/m0:Code&gt;&lt;/m0:CheckPriceRequest&gt;
+DEBUG XSLTMediator - Transformation result :
+&lt;m:getQuote xmlns:m=http://services.samples/xsd&gt;
+&lt;m:request&gt;&lt;m:symbol&gt;IBM&lt;/m:symbol&gt;&lt;/m:request&gt;&lt;/m:getQuote&gt;</pre>
+
+<p>The incoming message is now transformed into a standard stock quote
+request as expected by the SimpleStockQuoteService deployed on the local
+Axis2 instance by the Ruby mediator. The Ruby mediator uses REXML to perform
+XML transformations. The response from the SimpleStockQuoteService
+is converted into the custom format as expected by the client during the out
+message processing.</p>
+
 </body>
 </html>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to