You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by hi...@apache.org on 2010/11/28 04:45:44 UTC

svn commit: r1039828 - in /synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples: sample7.xml sample8.xml

Author: hiranya
Date: Sun Nov 28 03:45:43 2010
New Revision: 1039828

URL: http://svn.apache.org/viewvc?rev=1039828&view=rev
Log:
Sample 7, 8


Modified:
    synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample7.xml
    synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample8.xml

Modified: synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample7.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample7.xml?rev=1039828&r1=1039827&r2=1039828&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample7.xml (original)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample7.xml Sun Nov 28 03:45:43 2010
@@ -23,7 +23,7 @@
         <title>Apache Synapse - Sample 7</title>
     </properties>
     <body>
-        <section name="Sample 7: ">
+        <section name="Sample 7: Introduction to Local Registry Entries and Using Schema Validation">
             <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
 
     &lt;sequence name="main"&gt;
@@ -65,7 +65,8 @@
 &lt;/definitions&gt;</div>
             <subsection name="Objective">
                 <p>
-
+                    Demonstrating the usage of the validate mediator for XML schema validation
+                    and using local registry (local entries) for storing configuration metadata.
                 </p>
             </subsection>
             <subsection name="Pre-requisites">
@@ -85,11 +86,29 @@
                 </p>
             </subsection>
             <subsection name="Executing the Client">
+                <p>
+                    This example shows how a static XML fragment could be stored in the the
+                    Synapse local registry. Resources defined in the local registry are static
+                    (i.e. never changes over the lifetime of the configuration) and may be
+                    specified as a source URL, in-line text or in-line xml. In this example the
+                    schema is made available under the key 'validate_schema'.
+                </p>
+                <p>
+                    The validate mediator by default operates on the first child element of the
+                    SOAP body. You may specify an XPath expression using the 'source' attribute
+                    to override this behaviour. The validate mediator in this sample uses the 'validate_schema'
+                    resource to validate the incoming message, and if the message validation fails
+                    it invokes the 'on-fail' sequence of mediators.
+                </p>
+                <p>
+                    If you send a stockquote request using the 'ant stockquote ...' command as follows
+                    you will get a fault back with the message 'Invalid custom quote request' as
+                    the schema validation fails. This is because the schema used in the example
+                    expects a slightly different message than what is created by the stock quote
+                    client. (i.e. expects a 'stocksymbol' element instead of 'symbol' to specify
+                    the stock symbol)
+                </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>
             </subsection>
         </section>
         <p><a href="../samples.html">Back to Catalog</a></p>        

Modified: synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample8.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample8.xml?rev=1039828&r1=1039827&r2=1039828&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample8.xml (original)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample8.xml Sun Nov 28 03:45:43 2010
@@ -23,7 +23,7 @@
         <title>Apache Synapse - Sample 8</title>
     </properties>
     <body>
-        <section name="Sample 8: ">
+        <section name="Sample 8: Introduction to Static and Dynamic Registry Resources, and Using XSLT Transformations">
             <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
 
     &lt;!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) --&gt;
@@ -53,7 +53,9 @@
 &lt;/definitions&gt;</div>
             <subsection name="Objective">
                 <p>
-
+                    Demonstrating the usage of the XSLT mediator for transforming message content
+                    and using local registry and remote registry for storing configuration
+                    metadata.
                 </p>
             </subsection>
             <subsection name="Pre-requisites">
@@ -73,11 +75,73 @@
                 </p>
             </subsection>
             <subsection name="Executing the Client">
-                <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 the XSLT mediator to perform transformations, and the xslt
+                    transformations are specified as registry resources. The first resource
+                    'xslt-key-req' is specified as a 'local' registry entry. Local entries do not
+                    place the resource on the registry, but simply make it available to the local
+                    configuration. If a local entry is defined with a key that already exists in
+                    the remote registry, the local entry will get higher precedence over the remote
+                    resource.
+                </p>
+                <p>
+                    In this example you will notice the new 'registry' definition. Synapse comes
+                    with a simple URL based registry implementation (SimpleURLRegistry). During
+                    initialization of the registry, the SimpleURLRegistry expects to find a property
+                    named 'root', which specifies a prefix for the registry keys used later.
+                    When the SimpleURLRegistry is used, this root is prefixed to the entry keys to
+                    form the complete URL of the resource being looked up. The registry caches a
+                    resource once requested, and stores it internally for a specified duration.
+                    Once this period expires, it will reload the meta information about the resource
+                    and reloads its cached copy if necessary, the next time the resource is requested.
+                </p>
+                <p>
+                    Hence the second XSLT resource key 'transform/transform_back.xslt' concatenated
+                    with the 'root' of the SimpleURLRegistry 'file:repository/conf/sample/resources/'
+                    forms the complete URL of the resource as
+                    'file:repository/conf/sample/resources/transform/transform_back.xslt' and caches
+                    its value for a period of 15000 ms. 
+                </p>
+                <p>
+                    Execute the custom quote client as follows and analyze the the Synapse debug
+                    log output.
+                </p>
+                <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dmode=customquote</div>
+                <p>
+                    The incoming message is transformed into a standard stock quote request by the
+                    XSLT mediator. The XSLT mediator uses Xalan-J to perform the transformations.
+                    It is possible to configure the underlying transformation engine using properties
+                    when necessary. The response from the SimpleStockQuoteService is converted back
+                    into the custom format as expected by the client during the out message processing.
+                </p>
+                <p>
+                    During the response processing you could see the SimpleURLRegistry fetching the
+                    resource as shown by the log message below.
+                </p>
+                <div class="consoleOutput">[HttpClientWorker-1] DEBUG SimpleURLRegistry ==&gt; Repository fetch of resource with key : transform/transform_back.xslt</div>
+                <p>
+                    If you run the client again immediately (i.e within 15 seconds of the first
+                    request) you will not see the resource being reloaded by the registry as the
+                    cached value would be still valid.
+                </p>
+                <p>
+                    However if you leave the system idle for 15 seconds or more and then retry the
+                    same request, you will now notice that the registry notices the cached resource
+                    has expired and will reload the meta information about the resource to check if
+                    the resource has changed and will require a fresh fetch from the source URL.
+                    If the meta data / version number indicates that a reload of the cached resource
+                    is not necessary (i.e. unless the resource itself actually changed) the updated
+                    meta information is used and the cache lease extended as appropriate.
+                </p>
+                <div class="consoleOutput">[HttpClientWorker-1] DEBUG AbstractRegistry - Cached object has expired for key : transform/transform_back.xslt
+[HttpClientWorker-1] DEBUG SimpleURLRegistry - Perform RegistryEntry lookup for key : transform/transform_back.xslt
+[HttpClientWorker-1] DEBUG AbstractRegistry - Expired version number is same as current version in registry
+[HttpClientWorker-1] DEBUG AbstractRegistry - Renew cache lease for another 15s</div>
+                <p>
+                    Thus the SimpleURLRegistry allows resource to be cached, and updates are detected
+                    so that the configuration changes could be reloaded without restarting the
+                    Synapse instance.
+                </p>
             </subsection>
         </section>
         <p><a href="../samples.html">Back to Catalog</a></p>