Author: sadeep
Date: Sat Jul 27 13:15:56 2013
New Revision: 1507632
URL: http://svn.apache.org/r1507632
Log:
SYNAPSE-838: Adding documentation for the samples.
Added:
synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/samples/sample470.xml
Added:
synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/samples/sample470.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/samples/sample470.xml?rev=1507632&view=auto
==============================================================================
---
synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/samples/sample470.xml
(added)
+++
synapse/trunk/java/modules/documentation/src/site/xdoc/userguide/samples/sample470.xml
Sat Jul 27 13:15:56 2013
@@ -0,0 +1,197 @@
+<?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 470</title>
+ </properties>
+ <body>
+ <section name="Sample 470: Introduction to the EJB Mediator I -
Invoking Stateless Session Beans">
+ <div class="xmlConf"><definitions
xmlns="http://ws.apache.org/ns/synapse">
+ <proxy name="StoreLocatorProxy" transports="https
http" startOnLoad="true" trace="disable">
+ <target>
+ <!-- First call StoreLocator#getClosestStore(), then call
StoreRegistry#getStoreById() with the result. -->
+ <inSequence>
+ <bean action="CREATE"
class="samples.bean.Location" var="loc"/>
+ <bean action="SET_PROPERTY" var="loc"
property="latitude" value="{//m:latitude}"
xmlns:m="http://services.samples"/>
+ <bean action="SET_PROPERTY" var="loc"
property="longitude" value="{//m:longitude}"
xmlns:m="http://services.samples"/>
+ <ejb class="samples.ejb.StoreLocator"
beanstalk="demo" method="getClosestStore"
target="store_id" jndiName="StoreLocatorBean/remote">
+ <args>
+ <arg
value="{get-property('loc')}"/>
+ </args>
+ </ejb>
+ <ejb class="samples.ejb.StoreRegistry"
beanstalk="demo" method="getStoreById"
target="store" jndiName="StoreRegistryBean/remote">
+ <args>
+ <arg
value="{get-property('store_id')}"/>
+ </args>
+ </ejb>
+ <!-- Prepare the response. -->
+ <enrich>
+ <source type="inline"
clone="true">
+ <getClosestStoreResponse xmlns="">
+ <store>
+ <name>?</name>
+ <address>?</address>
+ <phone>?</phone>
+ </store>
+ </getClosestStoreResponse>
+ </source>
+ <target type="body"/>
+ </enrich>
+ <bean action="GET_PROPERTY" var="store"
property="name" target="{//store/name/text()}"/>
+ <bean action="GET_PROPERTY" var="store"
property="address" target="{//store/address/text()}"/>
+ <bean action="GET_PROPERTY" var="store"
property="phoneNo" target="{//store/phone/text()}"/>
+ <!-- Send the response back to the client of the ESB. -->
+ <header name="To" action="remove"/>
+ <property name="RESPONSE"
value="true"/>
+ <send/>
+ </inSequence>
+ </target>
+ </proxy>
+</definitions></div>
+ <subsection name="Objective">
+ <p>
+ Demonstrate the usage of the EJB mediator for invoking EJB
Stateless
+ Session Beans hosted on a remote EJB Container.
+ </p>
+ </subsection>
+ <subsection name="Pre-requisites">
+ <p>
+ <ul>
+ <li>
+ Build the backend EJB jar to be hosted on the EJB
Container by changing
+ the directory to
SYNAPSE_HOME/samples/axis2Server/src/EJBSampleBeans
+ and invoking: <div class="command">mvn clean
install</div>
+ </li>
+ <li>
+ Deploy the built EJB jar
+
(SYNAPSE_HOME/samples/axis2Server/src/EJBSampleBeans/target/synapse-samples-ejb-1.0.0.jar)
+ in an EJB Container such as JBoss or GlassFish.
+ </li>
+ <li>
+ Add minimal client JARs of your EJB Container to
SYNAPSE_HOME/lib.
+ E.g. If you are using JBoss 7, it is sufficient to
add the
+ jboss-client.jar file.
+ </li>
+ <li>
+ Add the synapse-samples-ejb-1.0.0.jar to
SYNAPSE_HOME/lib. (Note: adding
+ only the remote interfaces of the EJBs will
suffice. Here we are using
+ the complete jar file for simplicity.)
+ </li>
+ <li>
+ Configure a beanstalk named 'demo' in
+ SYNAPSE_HOME/repository/conf/synapse.properties.
You will need to
+ specify the JNDI properties of your EJB Container
in this configuration.
+ Some example configurations are shown below. <br/>
+ For JBoss 7:
+ <div
class="consoleOutput">synapse.beanstalks=demo,foo
+# JNDI properties
+synapse.beanstalks.demo.java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
+# Cache settings
+synapse.beanstalks.demo.cache.warn.limit.stateless=256
+synapse.beanstalks.demo.cache.warn.limit.stateful=256
+synapse.beanstalks.demo.cache.timeout.stateless=30
+synapse.beanstalks.demo.cache.timeout.stateful=30
+</div>
+ <br/>
+ For JBoss 6:
+ <div
class="consoleOutput">synapse.beanstalks=demo,foo
+# JNDI properties
+synapse.beanstalks.demo.java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+synapse.beanstalks.demo.java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+synapse.beanstalks.demo.java.naming.provider.url=localhost:1099
+# Cache settings
+synapse.beanstalks.demo.cache.warn.limit.stateless=256
+synapse.beanstalks.demo.cache.warn.limit.stateful=256
+synapse.beanstalks.demo.cache.timeout.stateless=30
+synapse.beanstalks.demo.cache.timeout.stateful=30
+</div>
+ </li>
+ <li>
+ If the JNDI names assigned to the EJBs by your EJB
Container differ from
+ the JNDI names specified in the sample 470
configuration file
+ (repository/conf/sample/synapse_sample_470.xml),
edit 'jndiName'
+ attribute of all < ejb /> mediator
invocations in the
+ synapse_sample_470.xml accordingly.
+ </li>
+ <li>
+ Start Synapse using the configuration numbered 470
+ (repository/conf/sample/synapse_sample_470.xml):
+ <div class="command">
+ Unix/Linux: sh synapse.sh -sample 470<br/>
+ Windows: synapse.bat -sample 470
+ </div>
+ </li>
+ </ul>
+ </p>
+ </subsection>
+ <subsection name="Executing the Client">
+ <p>
+ Send the following request to
http://localhost:8280/services/StoreLocatorProxy
+ using a tool such at <a
href="http://ws.apache.org/tcpmon/">TCPMon</a> or curl.
+ </p>
+<div class="xmlConf"><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soapenv:Body>
+ <getClosestStore xmlns="http://services.samples">
+ <latitude>78</latitude>
+ <longitude>8</longitude>
+ </getClosestStore>
+ </soapenv:Body>
+</soapenv:Envelope>
+</div>
+ <p>
+ When the <i>StoreLocatorProxy</i> receives the request, it
first creates an instance of
+ <i>samples.bean.Location</i> using the Bean mediator.
+ Then, it sets the properties of the newly created bean
with the values
+ extracted from the incoming SOAP message, again using the
Bean mediator.
+ </p>
+ <p>
+ The subsequent EJB mediator invokes the
<i>getClosestStore()</i> method on the remote stateless
+ session bean, <i>StoreLocator</i>, with the previously
populated
+ Location object as an argument and stores the result in
the <i>store_id</i> message context
+ property. Another EJB mediator that follows calls the
<i>getStoreById()</i> method
+ on a second stateless session bean,<i>StoreRegistry</i>,
to obtain store details encapsulated in
+ a JavaBean (an instance of samples.bean.Store) and stores
this resulting bean in a message context
+ property named <i>store</i>. The <i>demo</i> beanstalk
provides all necessary configurations
+ needed for the two remote EJB invocations.
+ </p>
+ <p>
+ Finally, Enrich and Bean mediators are used to build the
response message extracting properties from
+ the JavaBean stored in the <i>store</i> property.
+ </p>
+ <p>A sample response is shown below.</p>
+
+<div class="xmlConf"><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soapenv:Body>
+ <getClosestStoreResponse>
+ <store>
+ <name>Kadawatha</name>
+ <address>253, Kandy Road, Kadawatha</address>
+ <phone>0112990789</phone>
+ </store>
+ </getClosestStoreResponse>
+ </soapenv:Body>
+</soapenv:Envelope>
+</div>
+ </subsection>
+ </section>
+ <p><a href="../samples.html">Back to Catalog</a></p>
+ </body>
+</document>
\ No newline at end of file