Author: rajika Date: Wed Jul 1 01:26:28 2009 New Revision: 40488 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=40488
Log: Fixed docs. Modified: branches/esb/java/2.1/product/docs/xdoc/mediators/class.xml branches/esb/java/2.1/product/docs/xdoc/mediators/send.xml Modified: branches/esb/java/2.1/product/docs/xdoc/mediators/class.xml URL: http://wso2.org/svn/browse/wso2/branches/esb/java/2.1/product/docs/xdoc/mediators/class.xml?rev=40488&r1=40487&r2=40488&view=diff ============================================================================== --- branches/esb/java/2.1/product/docs/xdoc/mediators/class.xml (original) +++ branches/esb/java/2.1/product/docs/xdoc/mediators/class.xml Wed Jul 1 01:26:28 2009 @@ -69,7 +69,104 @@ </ul> <h3>Example</h3> +<pre xml:space="preserve"><definitions xmlns="http://ws.apache.org/ns/synapse"> + <sequence name="fault"> + <makefault> + <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/> + <reason value="Mediation failed."/> + </makefault> + <send/> + </sequence> + + <sequence name="main" onError="fault"> + <in> + <send> + <endpoint name="stockquote"> + <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> + </endpoint> + </send> + </in> + <out> + <class name="samples.mediators.SimpleClassMediator"> + <property name="varible1" value="10"/> + <property name="varible2" value="5"/> + </class> + <send/> + </out> + </sequence> + +</definitions></pre> + +<p>In this configuration, ESB hands over the request message to the specified endpoint, which sends it to the + Axis2 server running on port 9000. But the response message is passed through the class mediator before sending it + back to the client. Two parameters named "varible1" and "varible2" are passed to the instance mediator + implementation class(SimpleClassMediator). Look at the following sample class mediator. Note how the + SynapseMessageContext and to the full Synapse API in there. </p> +<p>A simple class mediator implementaion. </p> + +<pre xml:space="preserve">package samples.mediators; + +import org.apache.synapse.MessageContext; +import org.apache.synapse.Mediator; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.xml.namespace.QName; + +public class SimpleClassMediator implements Mediator { + + private static final Log log = LogFactory.getLog(DiscountQuoteMediator.class); + + private String varible1="10"; + + private String varible2="10"; + + private int varible3=0; + + public DiscountQuoteMediator(){} + + public boolean mediate(MessageContext mc) { + // Do somthing useful.. + // Note the access to the Synapse Message context + return true; + } + + public String getType() { + return null; + } + + public void setTraceState(int traceState) { + traceState = 0; + } + + public int getTraceState() { + return 0; + } + + public void setvarible1(String newValue) { + varible1=newValue; + } + + public String getvarible1() { + return varible1; + } + + public void setvarible2(String newValue){ + varible2=newValue; + } + + public String getvarible2(){ + return varible2; + } +}</pre> + +<p>A fully working sample is availble. See synapase configuration lanaguge guide for detailed(under + section called class mediator) working sample.</p> </body> </html> Modified: branches/esb/java/2.1/product/docs/xdoc/mediators/send.xml URL: http://wso2.org/svn/browse/wso2/branches/esb/java/2.1/product/docs/xdoc/mediators/send.xml?rev=40488&r1=40487&r2=40488&view=diff ============================================================================== --- branches/esb/java/2.1/product/docs/xdoc/mediators/send.xml (original) +++ branches/esb/java/2.1/product/docs/xdoc/mediators/send.xml Wed Jul 1 01:26:28 2009 @@ -81,7 +81,7 @@ accessed from the Manage-> Mediation-> Endpoints menu from the left hand side bar.</em> -<h3>Usage Scenario</h3> +<h3>Example</h3> <p>Send mediator used in in-path and out path</p> <pre xml:space="preserve"><definitions xmlns="http://ws.apache.org/ns/synapse"> _______________________________________________ Esb-java-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev
