Author: hiranya
Date: Sat Nov 27 20:21:57 2010
New Revision: 1039750

URL: http://svn.apache.org/viewvc?rev=1039750&view=rev
Log:
sample 2, 3

Added:
    
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample2.xml
    
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample3.xml
      - copied, changed from r1039730, 
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/template.xml
Modified:
    synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml

Modified: 
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml
URL: 
http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml?rev=1039750&r1=1039749&r2=1039750&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml 
(original)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml 
Sat Nov 27 20:21:57 2010
@@ -39,8 +39,8 @@
                     <ul>
                         <li><a href="samples/sample0.html">Sample 0: 
Introduction to Synapse</a></li>
                         <li><a href="samples/sample1.html">Sample 1: Simple 
content based routing (CBR) of messages</a></li>
-                        <li><a href="">Sample 2: CBR with the Switch-case 
mediator, using message properties</a></li>
-                        <li><a href="">Sample 3: Local Registry entry 
definitions, reusable endpoints and sequences</a></li>
+                        <li><a href="samples/sample2.html">Sample 2: CBR with 
the Switch-case mediator, using message properties</a></li>
+                        <li><a href="samples/sample3.html">Sample 3: Local 
Registry entry definitions, reusable endpoints and sequences</a></li>
                         <li><a href="">Sample 4: Introduction to error 
handling</a></li>
                         <li><a href="">Sample 5: Creating SOAP fault messages 
and changing the direction of a message</a></li>
                         <li><a href="">Sample 6: Manipulating SOAP headers, 
and filtering incoming and outgoing messages</a></li>

Added: 
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample2.xml
URL: 
http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample2.xml?rev=1039750&view=auto
==============================================================================
--- 
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample2.xml
 (added)
+++ 
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample2.xml
 Sat Nov 27 20:21:57 2010
@@ -0,0 +1,104 @@
+<?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 - Sample 2</title>
+    </properties>
+    <body>
+        <section name="Sample 2: CBR with Switch Case Mediator">
+            <div class="xmlConf">&lt;definitions 
xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;sequence name="main"&gt;
+        &lt;switch source="//m0:getQuote/m0:request/m0:symbol" 
xmlns:m0="http://services.samples"&gt;
+            &lt;case regex="IBM"&gt;
+                &lt;!-- the property mediator sets a local property on the 
*current* message --&gt;
+                &lt;property name="symbol" value="Great stock - IBM"/&gt;
+            &lt;/case&gt;
+            &lt;case regex="MSFT"&gt;
+                &lt;property name="symbol" value="Are you sure? - MSFT"/&gt;
+            &lt;/case&gt;
+            &lt;default&gt;
+                &lt;!-- it is possible to assign the result of an XPath 
expression as well --&gt;
+                &lt;property name="symbol" expression="fn:concat('Normal Stock 
- ', //m0:getQuote/m0:request/m0:symbol)"/&gt;
+            &lt;/default&gt;
+        &lt;/switch&gt;
+        &lt;log level="custom"&gt;
+            &lt;!-- the get-property() XPath extension function allows the 
lookup of local message properties
+                        as well as properties from the Axis2 or Transport 
contexts (i.e. transport headers) --&gt;
+            &lt;property name="symbol" expression="get-property('symbol')"/&gt;
+            &lt;!-- the get-property() function supports the implicit message 
headers To/From/Action/FaultTo/ReplyTo --&gt;
+            &lt;property name="epr" expression="get-property('To')"/&gt;
+        &lt;/log&gt;
+        &lt;!-- Send the messages where they are destined to (i.e. the 'To' 
EPR of the message) --&gt;
+        &lt;send/&gt;
+    &lt;/sequence&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Introduction to the switch-case mediator and manipulating 
properties set on the
+                    messages.
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample 
Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 2 
(repository/conf/sample/synapse_sample_2.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 2<br/>
+                                Windows: synapse.bat -sample 2
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    Execute the sample Axis2 client in the smart client using 
different symbols
+                    such as IBM, MSFT and SUN.
+                </p>
+                <div class="command">ant stockquote 
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService 
-Dtrpurl=http://localhost:8280/ -Dsymbol=IBM</div>
+                <div class="command">ant stockquote 
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService 
-Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT</div>
+                <div class="command">ant stockquote 
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService 
-Dtrpurl=http://localhost:8280/ -Dsymbol=SUN</div>
+
+                <p>
+                    When the symbol IBM is requested, viewing the mediation 
logs you will see that
+                    the switch mediator's first case for 'IBM' is executed and 
a local property named
+                    'symbol' is set to 'Great stock - IBM'. Subsequently this 
local property value
+                    is looked up by the log mediator and logged using the 
'get-property()' XPath
+                    extension function.
+                </p>
+                <div class="consoleOutput">INFO LogMediator - symbol = Great 
stock - IBM, epr = 
http://localhost:9000/axis2/services/SimpleStockQuoteService</div>
+
+                <p>
+                    Similarly for the symbol 'MSFT' the second case statement 
in the switch mediator
+                    will be executed which will result in the following log.
+                </p>
+                <div class="consoleOutput">INFO LogMediator - symbol = Are you 
sure? - MSFT, epr = 
http://localhost:9000/axis2/services/SimpleStockQuoteService</div>              
  
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>
+    </body>
+</document>
\ No newline at end of file

Copied: 
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample3.xml
 (from r1039730, 
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/template.xml)
URL: 
http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample3.xml?p2=synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample3.xml&p1=synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/template.xml&r1=1039730&r2=1039750&rev=1039750&view=diff
==============================================================================
--- 
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/template.xml
 (original)
+++ 
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample3.xml
 Sat Nov 27 20:21:57 2010
@@ -20,16 +20,47 @@
 
 <document>
     <properties>
-        <title>Apache Synapse - Sample X</title>
+        <title>Apache Synapse - Sample 3</title>
     </properties>
     <body>
-        <section name="Sample X: ">
-            <div class="xmlConf">
+        <section name="Sample 3: Local Registry Entries, Reusable Endpoints 
and Sequences">
+            <div class="xmlConf">&lt;definitions 
xmlns="http://ws.apache.org/ns/synapse"&gt;
+    &lt;!-- define a string resource entry to the local registry --&gt;
+    &lt;localEntry key="version"&gt;0.1&lt;/localEntry&gt;
+    &lt;!-- define a reuseable endpoint definition --&gt;
+    &lt;endpoint name="simple"&gt;
+        &lt;address 
uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+    &lt;/endpoint&gt;
 
-            </div>
+    &lt;!-- define a reusable sequence --&gt;
+    &lt;sequence name="stockquote"&gt;
+        &lt;!-- log the message using the custom log level. illustrates custom 
properties for log --&gt;
+        &lt;log level="custom"&gt;
+            &lt;property name="Text" value="Sending quote request"/&gt;
+            &lt;property name="version" 
expression="get-property('version')"/&gt;
+            &lt;property name="direction" 
expression="get-property('direction')"/&gt;
+        &lt;/log&gt;
+        &lt;!-- send message to real endpoint referenced by key "simple" 
endpoint definition --&gt;
+        &lt;send&gt;
+            &lt;endpoint key="simple"/&gt;
+        &lt;/send&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="main"&gt;
+        &lt;in&gt;
+            &lt;property name="direction" value="incoming"/&gt;
+            &lt;sequence key="stockquote"/&gt;
+        &lt;/in&gt;
+        &lt;out&gt;
+            &lt;send/&gt;
+        &lt;/out&gt;
+    &lt;/sequence&gt;
+&lt;/definitions&gt;</div>
             <subsection name="Objective">
                 <p>
-
+                    Demonstrates how to define local registry entries, 
sequences and endpoints in a
+                    reusable manner so that they can be used for mediation by 
referencing them by
+                    names.
                 </p>
             </subsection>
             <subsection name="Pre-requisites">
@@ -39,21 +70,50 @@
                             Deploy the SimpleStockQuoteService in the sample 
Axis2 server and start Axis2
                         </li>
                         <li>
-                            Start Synapse using the configuration numbered X 
(repository/conf/sample/synapse_sample_X.xml)
+                            Start Synapse using the configuration numbered 3 
(repository/conf/sample/synapse_sample_3.xml)
                             <div class="command">
-                                Unix/Linux: sh synapse.sh -sample X<br/>
-                                Windows: synapse.bat -sample X
+                                Unix/Linux: sh synapse.sh -sample 3<br/>
+                                Windows: synapse.bat -sample 3
                             </div>
                         </li>
                     </ul>
                 </p>
             </subsection>
             <subsection name="Executing the Client">
+                <p>
+                    Execute the sample client as follows.
+                </p>
                 <div class="command">ant stockquote 
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService 
-Dtrpurl=http://localhost:8280/</div>
-
-                <div class="consoleOutput">Sat Nov 18 21:01:23 IST 2006 
SimpleStockQuoteService :: Generating quote for : IBM</div>
-
-                <div class="consoleOutput">Standard :: Stock price = 
$95.26454380258552</div>
+                <p>
+                    This example uses a sequence named  'main' that specifies 
the main mediation
+                    rules to be executed. Following through the mediation logs 
you will notice
+                    that the sequence named 'main' is executed on receiving 
the requests (The main 
+                    sequence acts as the default entry point for messages 
received by Synapse). Then
+                    for the incoming message flow the 'in' mediator executes, 
and it calls the sequence
+                    named 'stockquote'.
+                </p>
+                <div class="consoleOutput">DEBUG SequenceMediator - Sequence 
mediator &lt;main&gt; :: mediate()
+DEBUG InMediator - In mediator mediate()
+DEBUG SequenceMediator - Sequence mediator &lt;stockquote&gt; :: 
mediate()</div>
+                <p>
+                    As the 'stockquote' sequence executes, the log mediator 
dumps a simple text/string
+                    property, result of an XPath evaluation, that picks up the 
key named 'version',
+                    and a second result of an XPath evaluation that picks up a 
local message property
+                    set previously by the property mediator. The 
get-property() XPath extension
+                    function is able to read message properties local to the 
current message, local
+                    or remote registry entries, Axis2 message context 
properties as well as transport
+                    headers. The local entry definition for 'version' defines 
a simple text/string
+                    registry entry which is visible to all messages that pass 
through Synapse.
+                </p>
+                <div class="consoleOutput">[HttpServerWorker-1] INFO  
LogMediator - Text = Sending quote request, version = 0.1, direction = incoming
+[HttpServerWorker-1] DEBUG SendMediator - Send mediator :: mediate()
+[HttpServerWorker-1] DEBUG AddressEndpoint - Sending To: 
http://localhost:9000/services/SimpleStockQuoteService </div>
+                <p>
+                    Responses from the Axis2 server will also get dispatched 
to the main sequence.
+                    But because they are responses the in mediator will not be 
executed on them.
+                    Only the out mediator will execute on these messages which 
simply sends them
+                    back to the client using a send mediator.
+                </p>
             </subsection>
         </section>
         <p><a href="../samples.html">Back to Catalog</a></p>        


Reply via email to