Author: jeff.yuchang
Date: 2008-07-15 14:01:27 -0400 (Tue, 15 Jul 2008)
New Revision: 171
Added:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java
Removed:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetVariableAction.java
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java
cdl/trunk/samples/jbossesb/README.txt
cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml
cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/jboss-esb.xml
cdl/trunk/samples/jbossesb/broker/src/main/resources/jbmq-queue-service.xml
cdl/trunk/samples/jbossesb/client/src/com/acme/services/buyer/BrokerClient.java
Log:
* Separating the 'ScheduleStateAction' from 'PerformAction' in same
service.
* Rename the 'SetVariableAction' to 'SetStateAction'.
* Add one more service for 'ScheduleStateAction'.
* Update the README file.
Modified:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java 2008-07-15
14:39:41 UTC (rev 170)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/ConversationAction.java 2008-07-15
18:01:27 UTC (rev 171)
@@ -289,6 +289,12 @@
protected void addScheduleItemToDeliver(String category, String name) {
+ for (ScheduleItem si : scheduleItems) {
+ if (category.equals(si.getCategory()) && name.equals(si.getName())) {
+ logger.error("Add duplicated schedule item of " + category + "/"
+ name);
+ return;
+ }
+ }
ScheduleItem si = new ScheduleItem(category, name);
scheduleItems.add(si);
}
Added:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java
(rev 0)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetStateAction.java 2008-07-15
18:01:27 UTC (rev 171)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ */
+package org.jboss.soa.overlord.jbossesb.actions;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.overlord.conversation.ClassLoaderUtil;
+import org.jboss.soa.overlord.conversation.Session;
+import org.jboss.soa.overlord.conversation.SessionManager;
+import org.jboss.soa.overlord.jbossesb.util.XMLUtils;
+import org.mvel.MVEL;
+import org.w3c.dom.Element;
+
+/**
+ * @author jeffyu
+ *
+ */
+public class SetStateAction extends ConversationAction {
+
+ private Logger logger = Logger.getLogger(SetStateAction.class);
+
+ public SetStateAction(ConfigTree config) {
+ super(config);
+ }
+
+
+ @Override
+ public Message handle(Message message) throws Exception {
+ String variable = getConfig().getAttribute("variable");
+ String stateExpression = getConfig().getAttribute("stateExpression");
+ String messageExpression = getConfig().getAttribute("messageExpression");
+
+ Session session = getSession(message);
+ Object bstate = session.getBusinessObject();
+ logger.info("Set value to the variable of " + variable);
+
+ while (variable.startsWith("parent.")) {
+ variable = variable.substring(7);
+ session = session.getParent();
+ if (session.getPojoID() != 0) {
+ Class<?> pojoClass = ClassLoaderUtil.loadClass(session.getPojoClass());
+ Object pojo = SessionManager.getObject(session.getPojoID(), pojoClass);
+ session.setBusinessObject(pojo);
+ }
+ }
+
+ if (stateExpression != null) {
+ Object result = MVEL.eval(stateExpression, bstate);
+ MVEL.setProperty(session.getBusinessObject(), variable, result);
+ logger.info("The Variable is: " + variable + "; stateExpression is:
" + stateExpression);
+ } else if (messageExpression != null) {
+ String xmlBody = (String) message.getBody().get();
+ Element element = (Element) XMLUtils.getNode(xmlBody);
+ String result = XMLUtils.executeXpath(element, messageExpression);
+ MVEL.setProperty(session.getBusinessObject(), variable, result);
+ logger.info("The Variable is: " + variable + "; messageExpression is:
" + messageExpression);
+ }
+
+ SessionManager.updateObject(bstate);
+
+ return message;
+ }
+
+
+}
Deleted:
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetVariableAction.java
===================================================================
---
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetVariableAction.java 2008-07-15
14:39:41 UTC (rev 170)
+++
cdl/trunk/runtime/jbossesb/src/main/java/org/jboss/soa/overlord/jbossesb/actions/SetVariableAction.java 2008-07-15
18:01:27 UTC (rev 171)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2008,
- */
-package org.jboss.soa.overlord.jbossesb.actions;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.overlord.conversation.ClassLoaderUtil;
-import org.jboss.soa.overlord.conversation.Session;
-import org.jboss.soa.overlord.conversation.SessionManager;
-import org.jboss.soa.overlord.jbossesb.util.XMLUtils;
-import org.mvel.MVEL;
-import org.w3c.dom.Element;
-
-/**
- * @author jeffyu
- *
- */
-public class SetVariableAction extends ConversationAction {
-
- private Logger logger = Logger.getLogger(SetVariableAction.class);
-
- public SetVariableAction(ConfigTree config) {
- super(config);
- }
-
-
- @Override
- public Message handle(Message message) throws Exception {
- String variable = getConfig().getAttribute("variable");
- String stateExpression = getConfig().getAttribute("stateExpression");
- String messageExpression = getConfig().getAttribute("messageExpression");
-
- Session session = getSession(message);
- Object bstate = session.getBusinessObject();
- logger.info("Set value to the variable of " + variable);
-
- while (variable.startsWith("parent.")) {
- variable = variable.substring(7);
- session = session.getParent();
- if (session.getPojoID() != 0) {
- Class<?> pojoClass = ClassLoaderUtil.loadClass(session.getPojoClass());
- Object pojo = SessionManager.getObject(session.getPojoID(), pojoClass);
- session.setBusinessObject(pojo);
- }
- }
-
- if (stateExpression != null) {
- Object result = MVEL.eval(stateExpression, bstate);
- MVEL.setProperty(session.getBusinessObject(), variable, result);
- logger.info("The Variable is: " + variable + "; stateExpression is:
" + stateExpression);
- } else if (messageExpression != null) {
- String xmlBody = (String) message.getBody().get();
- Element element = (Element) XMLUtils.getNode(xmlBody);
- String result = XMLUtils.executeXpath(element, messageExpression);
- MVEL.setProperty(session.getBusinessObject(), variable, result);
- logger.info("The Variable is: " + variable + "; messageExpression is:
" + messageExpression);
- }
-
- SessionManager.updateObject(bstate);
-
- return message;
- }
-
-
-}
Modified: cdl/trunk/samples/jbossesb/README.txt
===================================================================
--- cdl/trunk/samples/jbossesb/README.txt 2008-07-15 14:39:41 UTC (rev 170)
+++ cdl/trunk/samples/jbossesb/README.txt 2008-07-15 18:01:27 UTC (rev 171)
@@ -1,38 +1,83 @@
-The Purchasing example.
+Instructions for examples running:
+=================================
Required to run the Purchasing example:
-- ANT
-- Maven
-- JBoss AS 4.2.2 or higher with the JBoss ESB SAR deployment (jbossesb.sar).
+---------------------------------------
+- ANT 1.6.5 or higher
+- Maven 2.0.8 or higher
+- JBoss AS 4.2.2.GA or higher with the JBoss ESB SAR deployment (jbossesb.sar).
+- JBossESB 4.3.GA
+Folder directories:
+-------------------
+- client
+- broker
+- purchasing
+
Settings required to edit before running:
+========================================
-File: purchasing/pom.xml
+File: purchasing/pom.xml, broker/pom.xml for purchasing example and broker's
respectively.
- Update the "deploy.dir" variable to your JBossAS server directory.
--- Notice Before jbossesb-rosetta.jar and jbossesb-config-model.jar get published in
jboss maven repository, you need to install these two artifacts into
+- Before jbossesb-rosetta.jar and jbossesb-config-model.jar get published in jboss maven
repository, you need to install these two artifacts into
your local repository by using following commands:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id>
-DartifactId=<artifact-id> -Dversion=<version>
-Dpackaging=<packaging>
-Here we are using jbossesb-rosetta 4.2.1 version, jbossesb-config-model 1.0.1 version.
+Notice: Here we are using jbossesb-rosetta 4.3 version, jbossesb-config-model 1.0.1
version.
-Running instructions for purchasing example:
-------------------------------------------------
+Instructions for purchasing example:
+===========================================
To run the purchasing, follow these steps:
-1 - run your JBoss AS - you will need to have the 4.2.1 or higher (with JBossESB
installed)
+1 - run your JBoss AS - you will need to have the 4.2.2 or higher (with JBossESB
installed)
2 - from the $JBossAS, execute the command to start the ESB: "bin/run.sh", or
"bin/run.bat" for windows.
3 - from the $purchasing: execute the command to start the Hsql database: "ant
startdb".
4 - Open up another shell, from the $Purchasing, execute the command to deploy the
"Purchasing": "mvn install"
-* this should deploy the ESB archive to your JBoss AS server/default.
+ * this should deploy the ESB archive to your JBoss AS server/default.
5 - from the $client, execute the command to run the client: "ant runClient"
- You will see the "<BuyResponse id="5"></BuyResponse>"
in the client console.
+ You will see following in the console.
-6 - you can from the $purchasing to run "ant dbmanager" to open up the database
browser to check the data.
+ [java] =========================================
+ [java] Request: <BuyRequest id="5" ></BuyRequest>
+ [java] Reply: <BuyResponse id="5"></BuyResponse>
+ [java] =========================================
+
+
+6 - you can be from the $purchasing to run "ant dbmanager" to open up the
database browser to check the data.
+
+
+Instructions for broker example:
+=======================================
+To run the broker, follow these steps:
+
+Currently, if you want to run the 'broker' example, please open up the
'jbossesb-properties.xml' in the $JBossAS/server/default/deploy/jbossesb.sar,
update the 'org.jboss.soa.esb.jms.connectionPool' property value to '30',
instead of '20'. It won't be needed to update this if we separate the Supplier
& Credit Agency as another two esb artifacts.
+
+1 - run your JBoss AS - you will need to have the 4.2.2 or higher (with JBossESB
installed)
+
+2 - from the $JBossAS, execute the command to start the ESB: "bin/run.sh", or
"bin/run.bat" for windows.
+
+3 - from the $broker: execute the command to start the Hsql database: "ant
startdb".
+
+4 - Open up another shell, from the $broker, execute the command to deploy the
"broker": "mvn install"
+ * this should deploy the ESB archive to your JBoss AS server/default.
+
+5 - from the $client, execute the command to run the client: "ant
runBrokerClient"
+ You will see following in the console.
+ [java] =========================================
+ [java] Request: <enquiry id="20" ></enquiry>
+ [java] Reply: <quoteList id="20"><quote
supplierDesc="{http://www.jboss.org/overlord/loanBroker}Supplier1&qu...
+ [java] Sending Buy request to Broker...
+ [java] Request: <buy id="20"
supplierDesc="{http://www.jboss.org/overlord/loanBroker}Supplier1"
quoteValue="10"></buy>
+ [java] Reply: <orderConfirmResponse id="20" supplierDesc =
"{http://www.jboss.org/overlord/loanBroker}Supplier1">The quote of 10 has
been confirmed.</orderConfirmResponse>
+ [java] =========================================
+
+6 - you can be from the $broker to run "ant dbmanager" to open up the database
browser to check the data.
+
Modified: cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml
===================================================================
---
cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml 2008-07-15
14:39:41 UTC (rev 170)
+++
cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/deployment.xml 2008-07-15
18:01:27 UTC (rev 171)
@@ -17,6 +17,7 @@
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-broker14</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-broker15</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-broker16</depends>
+
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-broker17</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-creditAgency</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-creditAgency1</depends>
<depends>jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-creditAgency2</depends>
Modified: cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/jboss-esb.xml
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/jboss-esb.xml 2008-07-15
14:39:41 UTC (rev 170)
+++ cdl/trunk/samples/jbossesb/broker/src/main/resources/META-INF/jboss-esb.xml 2008-07-15
18:01:27 UTC (rev 171)
@@ -57,6 +57,9 @@
<jms-bus busid="BrokerService16">
<jms-message-filter dest-type="QUEUE"
dest-name="queue/esb-loan-broker16"/>
</jms-bus>
+ <jms-bus busid="BrokerService17">
+ <jms-message-filter dest-type="QUEUE"
dest-name="queue/esb-loan-broker17"/>
+ </jms-bus>
<jms-bus busid="SupplierService1">
<jms-message-filter dest-type="QUEUE"
dest-name="queue/esb-loan-supplier1" />
</jms-bus>
@@ -181,22 +184,12 @@
<property name="serviceCategory"
value="ESBBroker.BrokerParticipant" />
<property name="serviceName" value="RequestForQuote.main"
/>
<property name="responseServiceCategory"
value="ESBBroker.BrokerParticipant" />
- <property name="responseServiceName"
value="ESBBrokerProcess.main.3" />
+ <property name="responseServiceName"
value="ESBBrokerProcess.main.9" />
<property name="bindDetails" >
<bind from-expression="getCurrentSupplier()"
to-variable="supplier" />
</property>
</action>
- <action
class="org.jboss.soa.overlord.jbossesb.actions.SetVariableAction"
name="s3-2">
- <property name="variable" value="supplierIndex" />
- <property name="stateExpression" value="nextSupplier()"
/>
- </action>
- <!--action
class="org.jboss.soa.overlord.jbossesb.actions.ScheduleStateAction"
- process="process" name="s3-3">
- <property name="serviceCategory"
value="ESBBroker.BrokerParticipant" />
- <property name="serviceName" value="ESBBrokerProcess.main.1"
/>
- <property name="immediate" value="true" />
- </action-->
</actions>
</service>
@@ -289,6 +282,7 @@
<actions mep="OneWay">
<action
class="org.jboss.soa.overlord.jbossesb.actions.ReceiveMessageAction"
process="process" name="s6-1">
+ <property name="session"
value="org.jboss.soa.overlord.samples.jbossesb.loan.broker.BrokerMain" />
<property name="operation" value="cancel" />
<property name="messageType" value="cancel" />
<property name="identities" >
@@ -307,12 +301,12 @@
maxThreads="1"/>
</listeners>
<actions mep="OneWay">
- <action
class="org.jboss.soa.overlord.jbossesb.actions.SetVariableAction"
name="s7-1">
+ <action class="org.jboss.soa.overlord.jbossesb.actions.SetStateAction"
name="s7-1">
<property name="session"
value="org.jboss.soa.overlord.samples.jbossesb.loan.broker.BrokerMain" />
<property name="variable" value="selectedSupplierDesc" />
<property name="messageExpression" value="//@supplierDesc"
/>
</action>
- <action
class="org.jboss.soa.overlord.jbossesb.actions.SetVariableAction"
name="s7-2">
+ <action class="org.jboss.soa.overlord.jbossesb.actions.SetStateAction"
name="s7-2">
<property name="variable" value="selectedQuoteValue" />
<property name="messageExpression" value="//@quoteValue"
/>
</action>
@@ -353,6 +347,37 @@
</actions>
</service>
+ <service category="ESBBroker.BrokerParticipant"
name="ESBBrokerProcess.main.9" description="">
+ <listeners>
+ <jms-listener name="BrokerServiceListener17"
+ busidref="BrokerService17"
+ maxThreads="1"/>
+ </listeners>
+ <actions mep="OneWay">
+ <action
class="org.jboss.soa.overlord.jbossesb.actions.ReceiveMessageAction"
+ process="process" name="s17-1">
+ <property name="session"
value="org.jboss.soa.overlord.samples.jbossesb.loan.broker.BrokerMain" />
+ <property name="messageType" value="quote" />
+ <property name="serviceDescriptionName"
value="{http://www.jboss.org/overlord/loanBroker}Broker"/>
+ <property name="identities" >
+ <identity type="primary" >
+ <token name="id" locator="//@id" />
+ </identity>
+ </property>
+ </action>
+ <action class="org.jboss.soa.overlord.jbossesb.actions.SetStateAction"
name="s17-2">
+ <property name="variable" value="supplierIndex" />
+ <property name="stateExpression" value="nextSupplier()"
/>
+ </action>
+ <action
class="org.jboss.soa.overlord.jbossesb.actions.ScheduleStateAction"
+ process="process" name="s17-3">
+ <property name="serviceCategory"
value="ESBBroker.BrokerParticipant" />
+ <property name="serviceName" value="ESBBrokerProcess.main.1"
/>
+ <property name="immediate" value="true" />
+ </action>
+ </actions>
+ </service>
+
<service category="ESBBroker.BrokerParticipant"
name="RequestForQuote.main" description="">
<listeners>
<jms-listener name="BrokerServiceListener10"
@@ -411,18 +436,18 @@
</identity>
</property>
</action>
- <action
class="org.jboss.soa.overlord.jbossesb.actions.SetVariableAction"
+ <action class="org.jboss.soa.overlord.jbossesb.actions.SetStateAction"
process="process" name="s9-2">
<property name="variable" value="quote.serviceDescription"
/>
<property name="messageExpression" value="//@supplierDesc"
/>
</action>
- <action
class="org.jboss.soa.overlord.jbossesb.actions.SetVariableAction"
+ <action class="org.jboss.soa.overlord.jbossesb.actions.SetStateAction"
process="process" name="s9-3">
<property name="variable" value="quote.value" />
<property name="messageExpression" value="/quote" />
</action>
- <action
class="org.jboss.soa.overlord.jbossesb.actions.SetVariableAction"
+ <action class="org.jboss.soa.overlord.jbossesb.actions.SetStateAction"
process="process" name="s9-4">
<property name="variable" value="parent.quote" />
<property name="stateExpression" value="quote" />
@@ -579,7 +604,7 @@
</property>
</action>
- <action
class="org.jboss.soa.overlord.jbossesb.actions.SetVariableAction"
+ <action class="org.jboss.soa.overlord.jbossesb.actions.SetStateAction"
process="process" name="s13-2">
<property name="variable" value="confirmation.detail" />
<property name="messageExpression"
value="/orderConfirmResponse" />
Modified: cdl/trunk/samples/jbossesb/broker/src/main/resources/jbmq-queue-service.xml
===================================================================
--- cdl/trunk/samples/jbossesb/broker/src/main/resources/jbmq-queue-service.xml 2008-07-15
14:39:41 UTC (rev 170)
+++ cdl/trunk/samples/jbossesb/broker/src/main/resources/jbmq-queue-service.xml 2008-07-15
18:01:27 UTC (rev 171)
@@ -111,6 +111,12 @@
</depends>
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
+
name="jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-broker17">
+ <depends optional-attribute-name="DestinationManager">
+ jboss.mq:service=DestinationManager
+ </depends>
+</mbean>
+<mbean code="org.jboss.mq.server.jmx.Queue"
name="jboss.esb.sample.broker.destination:service=Queue,name=esb-loan-creditAgency">
<depends optional-attribute-name="DestinationManager">
jboss.mq:service=DestinationManager
Modified: cdl/trunk/samples/jbossesb/client/src/com/acme/services/buyer/BrokerClient.java
===================================================================
---
cdl/trunk/samples/jbossesb/client/src/com/acme/services/buyer/BrokerClient.java 2008-07-15
14:39:41 UTC (rev 170)
+++
cdl/trunk/samples/jbossesb/client/src/com/acme/services/buyer/BrokerClient.java 2008-07-15
18:01:27 UTC (rev 171)
@@ -62,7 +62,7 @@
Message reply=brokerInvoker.deliverSync(mesg, 50000);
System.out.println("Reply: "+reply.getBody().get());
- Thread.sleep(10000);//Waiting...
+ Thread.sleep(5000);//Waiting...
System.out.println("Sending Buy request to Broker...");
String buyReq = "<buy id=\"20\"
supplierDesc=\"{http://www.jboss.org/overlord/loanBroker}Supplier1\&...
quoteValue=\"10\"></buy>";