Author: sadeep
Date: Sun Jul 21 08:40:00 2013
New Revision: 1505307
URL: http://svn.apache.org/r1505307
Log:
SYNAPSE-838: Adding the EJB sample.
Added:
synapse/trunk/java/repository/conf/sample/synapse_sample_470.xml
synapse/trunk/java/repository/conf/sample/synapse_sample_471.xml
Added: synapse/trunk/java/repository/conf/sample/synapse_sample_470.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/repository/conf/sample/synapse_sample_470.xml?rev=1505307&view=auto
==============================================================================
--- synapse/trunk/java/repository/conf/sample/synapse_sample_470.xml (added)
+++ synapse/trunk/java/repository/conf/sample/synapse_sample_470.xml Sun Jul 21
08:40:00 2013
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<!-- Invoking remote EJB Stateless Session Beans from Synapse. -->
+<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="loc_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('loc_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()}"/>
+ <header name="To" action="remove"/>
+ <property name="RESPONSE" value="true"/>
+ <send/>
+ </inSequence>
+ </target>
+ </proxy>
+
+</definitions>
Added: synapse/trunk/java/repository/conf/sample/synapse_sample_471.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/repository/conf/sample/synapse_sample_471.xml?rev=1505307&view=auto
==============================================================================
--- synapse/trunk/java/repository/conf/sample/synapse_sample_471.xml (added)
+++ synapse/trunk/java/repository/conf/sample/synapse_sample_471.xml Sun Jul 21
08:40:00 2013
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<!-- Invoking remote EJB Stateful Session Beans from Synapse. -->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <proxy name="BuyAllProxy" transports="https http" startOnLoad="true"
trace="disable">
+ <target>
+
+ <!-- Iterate over all items in the request and call addItem() on
the ShoppingCart EJB for each item. -->
+ <inSequence>
+ <property name="SESSION_ID"
expression="get-property('MessageID')"/>
+ <iterate xmlns:m0="http://services.samples"
preservePayload="false"
+ expression="//m0:buyItems/m0:items/m0:item">
+ <target>
+ <sequence>
+
+ <!-- You might want to change the jndiName,
depending on your EJB container. -->
+ <ejb class="samples.ejb.ShoppingCart"
beanstalk="demo" method="addItem" sessionId="{get-property('SESSION_ID')}"
jndiName="ShoppingCartBean/remote">
+ <args>
+ <arg value="{//m:item//m:id}"
xmlns:m="http://services.samples"/>
+ <arg value="{//m:item//m:quantity}"
xmlns:m="http://services.samples"/>
+ </args>
+ </ejb>
+ <sequence key="collector"/>
+ </sequence>
+ </target>
+ </iterate>
+ </inSequence>
+ </target>
+ </proxy>
+
+ <!-- Prepare the response once all addItem() calls are finished. -->
+ <sequence name="collector">
+ <aggregate>
+ <onComplete>
+ <ejb class="samples.ejb.ShoppingCart" beanstalk="demo"
method="getItemCount" sessionId="{get-property('SESSION_ID')}"
target="ITEM_COUNT"/>
+ <ejb class="samples.ejb.ShoppingCart" beanstalk="demo"
method="getTotal" sessionId="{get-property('SESSION_ID')}" target="TOTAL"
remove="true"/>
+ <payloadFactory>
+ <format>
+ <buyAllResponse xmlns="">
+ <itemCount>$1</itemCount>
+ <total>$2</total>
+ </buyAllResponse>
+ </format>
+ <args>
+ <arg expression="get-property('ITEM_COUNT')"/>
+ <arg expression="get-property('TOTAL')"/>
+ </args>
+ </payloadFactory>
+ <property name="RESPONSE" value="true"/>
+ <header name="To" action="remove"/>
+ <send/>
+ </onComplete>
+ </aggregate>
+ </sequence>
+
+</definitions>