<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more 
	contributor license agreements. See the NOTICE file ~ distributed with this 
	work for additional information ~ regarding copyright ownership. The ASF 
	licenses this file ~ to you under the Apache License, Version 2.0 (the ~ 
	"License"); you may not use this file except in compliance ~ with the License. 
	You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 
	~ ~ Unless required by applicable law or agreed to in writing, ~ software 
	distributed under the License is distributed on an ~ * "AS IS" BASIS, WITHOUT 
	WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the 
	License for the ~ specific language governing permissions and limitations 
	~ under the License. -->

<document>
	<properties>
		<title>Apache Synapse - Script Setup Guide</title>
	</properties>
	<body>
        <section name="Script Setup Guide">
            <p>
                Apache Synapse ships with a set of scripting samples. This document explains
                how to setup the necessary script engines for these samples. In addition this
                guide describes how to setup the JSON message builder and formatter for JSON
                mediation samples.
            </p>
        </section>
		<section name="Contents">
			<ul>
				<li>
					<a href="#intro">Introduction</a>
				</li>
				<li>
					<a href="#javaScript">JavaScripts Support</a>
				</li>
				<li>
					<a href="#ruby">Ruby Support</a>
				</li>
                <li>
					<a href="#python">Python Support</a>
				</li>
				<li>
					<a href="#json-syn3">JSON Support on Synapse 3.0.0</a>
				</li>
				<li>
					<a href="#json">JSON Support Prior to Synapse 3.0.0</a>
				</li>
			</ul>
		</section>
		<section name="Configuring Synapse for Script Mediator Support"
			id="intro">
			<p>
				The Synapse Script Mediator is a Synapse extension, and thus all
				prerequisites are not bundled by default with the Synapse
				distribution.Before you use some script mediators you may need to
				manually add the required jar files to the Synapse lib directory, and
				optionally 	perform other installation tasks as may be required by the
				individual scripting language. This is explained in the following
				sections.
			</p>
			<subsection name="JavaScript Support" id="javaScript">

				<p>
					The JavaScript/E4X support is enabled by default and comes
					ready-to-use with the Synapse distribution.
				</p>
			</subsection>
			<subsection name="Ruby Support" id="ruby">
				<p>
					For Ruby support you need to download the 'jruby-complete.jar'
					from the Maven repository for JRuby, and copy it into the 'lib'
					folder of Synapse . The JRuby JAR can be downloaded from
					<a class="externalLink"
						href="http://repo2.maven.org/maven2/org/jruby/jruby-complete/1.3.0/jruby-complete-1.3.0.jar">
						here
					</a>
				</p>
			</subsection>
			<subsection name="Python Support" id="python">
				<p>
					For Python support you need to download the 'jython.jar'
					from the Maven repository for Jython, and copy it into the 'lib'
					folder of Synapse . The Jython JAR can be downloaded from
					<a class="externalLink"
						href="http://central.maven.org/maven2/org/python/jython/2.2.1/jython-2.2.1.jar">
						here
					</a>
				</p>
			</subsection>

			<subsection name="JSON Support on Synapse 3.0.0" id="json-syn3">
				<p>
					<a class="externalLink" href="http://json.org">JSON</a>
					is a lightweight data-interchange format.
					It can be used as an alternative to XML or SOAP. From Synapse 3.0.0 onward, there are no additional
					steps required to enable JSON.

				</p>
			</subsection>

			<subsection name="JSON Support Prior to Synapse 3.0.0" id="json">
				<p>
					To enable JSON
					support on Synpase versions prior to 3.0.0, the following two jar files should be deployed into the 'lib'
					directory of Synapse.
				</p>
				<ul>
					<li>
						<a class="externalLink" href="http://repo1.maven.org/maven2/org/apache/axis2/axis2-json">axis2-json.jar</a>
					</li>
					<li>
						<a class="externalLink" href="http://central.maven.org/maven2/org/codehaus/jettison/jettison/">jettison.jar</a>
					</li>
				</ul>
                <p>
                    Jettison 1.1 is recommended.
                </p>
				<p>
      			Having deployed the necessary libraries you should now register the JSON message
      			builder and formatter with Synapse. Open up 'repository/conf/axis2.xml' file
      			of Synapse and add the following two entries under the 'messageBuilders' and
      			'messageFormatters' sections respectively.
    			</p>
    			<div class="xmlConf">&lt;messageBuilder contentType=&quot;application/json&quot;
    class=&quot;org.apache.axis2.json.JSONOMBuilder&quot;/&gt;

&lt;messageFormatter contentType=&quot;application/json&quot;
    class=&quot;org.apache.axis2.json.JSONMessageFormatter&quot;/&gt;</div>
    			<p>
                    If you are planning to run <a href="../sample158.html">sample 158</a>, you should also add the above two entries
                    to the 'samples/axis2Client/client_repo/conf/axis2.xml' file.
    			</p>
			</subsection>

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