[overlord-commits] Overlord SVN: r546 - in cdl/trunk/samples/jbossesb/brokerage: broker/stateless/src/main/resources/META-INF and 2 other directories.
overlord-commits at lists.jboss.org
overlord-commits at lists.jboss.org
Sat Mar 21 13:11:43 EDT 2009
Author: jeff.yuchang
Date: 2009-03-21 13:11:43 -0400 (Sat, 21 Mar 2009)
New Revision: 546
Added:
cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/MemoryEPRStorage.java
cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/MemoryStore.java
cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/SendReqForQuoteDecision.java
cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/SetQuoteAction.java
cdl/trunk/samples/jbossesb/brokerage/supplier/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/supplier/MemoryEPRStorage.java
Modified:
cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/resources/META-INF/jboss-esb.xml
cdl/trunk/samples/jbossesb/brokerage/supplier/stateless/src/main/resources/META-INF/jboss-esb.xml
Log:
[SOAG-93] Finished broker stateless example.
Added: cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/MemoryEPRStorage.java
===================================================================
--- cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/MemoryEPRStorage.java (rev 0)
+++ cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/MemoryEPRStorage.java 2009-03-21 17:11:43 UTC (rev 546)
@@ -0,0 +1,46 @@
+/*
+ * 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.samples.jbossesb.loan.broker;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.overlord.jbossesb.EPRStorage;
+
+/**
+ * @author <a href="mailto:cyu at redhat.com">Jeff Yu</a>
+ *
+ */
+public class MemoryEPRStorage implements EPRStorage {
+
+ private static final Map<String, EPR> storage = new HashMap<String, EPR>();
+
+ public EPR getEPRByRole(String roleName, Message message) {
+ return storage.get(roleName);
+ }
+
+ public void registerRole(String roleName, Message message) {
+ EPR epr = message.getHeader().getCall().getReplyTo();
+ storage.put(roleName, epr);
+ }
+
+}
Added: cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/MemoryStore.java
===================================================================
--- cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/MemoryStore.java (rev 0)
+++ cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/MemoryStore.java 2009-03-21 17:11:43 UTC (rev 546)
@@ -0,0 +1,42 @@
+/*
+ * 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.samples.jbossesb.loan.broker;
+
+/**
+ * @author <a href="mailto:cyu at redhat.com">Jeff Yu</a>
+ *
+ */
+public class MemoryStore {
+
+ private static int counter = 0;
+
+ public static void increaseCounter() {
+ counter = counter + 1;
+ }
+
+ public static void decreaseCounter() {
+ counter = counter - 1;
+ }
+
+ public static int getCounter() {
+ return counter;
+ }
+
+}
Added: cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/SendReqForQuoteDecision.java
===================================================================
--- cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/SendReqForQuoteDecision.java (rev 0)
+++ cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/SendReqForQuoteDecision.java 2009-03-21 17:11:43 UTC (rev 546)
@@ -0,0 +1,48 @@
+/*
+ * 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.samples.jbossesb.loan.broker;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.overlord.jbossesb.Decision;
+
+/**
+ * @author <a href="mailto:cyu at redhat.com">Jeff Yu</a>
+ *
+ */
+public class SendReqForQuoteDecision implements Decision {
+
+ private final int DEFAULT = 1;
+
+ private Logger logger = Logger.getLogger(SendReqForQuoteDecision.class);
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.overlord.jbossesb.Decision#executeDecision(org.jboss.soa.esb.message.Message)
+ */
+ public boolean executeDecision(Message message) {
+ if (DEFAULT > MemoryStore.getCounter()) {
+ logger.info("The decision is true");
+ return true;
+ }
+ logger.info("The decision is false");
+ return false;
+ }
+
+}
Added: cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/SetQuoteAction.java
===================================================================
--- cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/SetQuoteAction.java (rev 0)
+++ cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/loan/broker/SetQuoteAction.java 2009-03-21 17:11:43 UTC (rev 546)
@@ -0,0 +1,73 @@
+/*
+ * 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.samples.jbossesb.loan.broker;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.overlord.jbossesb.XMLUtils;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author <a href="mailto:cyu at redhat.com">Jeff Yu</a>
+ *
+ */
+public class SetQuoteAction extends AbstractActionLifecycle {
+
+ private Logger logger = Logger.getLogger(SetQuoteAction.class);
+
+ private ConfigTree config;
+
+ public SetQuoteAction(ConfigTree config) {
+ this.config = config;
+ }
+
+ public Message process(Message message) throws Exception {
+
+ Node node = XMLUtils.getNode((String)message.getBody().get());
+ String quoteValue = node.getTextContent();
+ String desc = node.getAttributes().getNamedItem("supplierDesc").getNodeValue();
+
+ List<Quote> quotes = (List<Quote>)message.getProperties().getProperty("quotes");
+ if (quotes == null) {
+ quotes = new ArrayList<Quote>();
+ }
+
+ Quote quote = new Quote();
+ quote.setServiceDescription(desc);
+ quote.setValue(quoteValue);
+
+ quotes.add(quote);
+
+ message.getProperties().setProperty("quotes", quotes);
+
+ MemoryStore.increaseCounter();
+
+ logger.info("set quote message :[" + node + "]");
+
+ return message;
+ }
+
+}
Modified: cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/resources/META-INF/jboss-esb.xml
===================================================================
--- cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/resources/META-INF/jboss-esb.xml 2009-03-20 16:48:05 UTC (rev 545)
+++ cdl/trunk/samples/jbossesb/brokerage/broker/stateless/src/main/resources/META-INF/jboss-esb.xml 2009-03-21 17:11:43 UTC (rev 546)
@@ -79,6 +79,8 @@
<action class="org.jboss.soa.overlord.jbossesb.stateless.actions.ReceiveMessageAction" name="ESBBrokerProcess_Broker__1_action_1" process="process">
<property name="operation" value="makeEnquiry"/>
<property name="messageType" value="enquiry"/>
+ <property name="clientRole" value="Buyer"/>
+ <property name="storageClass" value="org.jboss.soa.overlord.samples.jbossesb.loan.broker.MemoryEPRStorage" />
</action>
<action class="org.jboss.soa.overlord.jbossesb.stateless.actions.IfAction" name="ESBBrokerProcess_Broker__1_action_2" process="process">
<property name="paths">
@@ -168,6 +170,7 @@
<property name="operation" value="makeEnquiry"/>
<property name="messageType" value="quoteList"/>
<property name="clientRole" value="Buyer"/>
+ <property name="storageClass" value="org.jboss.soa.overlord.samples.jbossesb.loan.broker.MemoryEPRStorage" />
</action>
</actions>
</service>
@@ -179,7 +182,11 @@
<action class="org.jboss.soa.overlord.jbossesb.stateless.actions.ReceiveMessageAction" name="ESBBrokerProcess_Broker__8_action_1" process="process">
<property name="operation" value="buy"/>
<property name="messageType" value="buy"/>
+ <property name="clientRole" value="Buyer"/>
+ <property name="storageClass" value="org.jboss.soa.overlord.samples.jbossesb.loan.broker.MemoryEPRStorage" />
</action>
+ <action name="creditCheck-Request" class="org.jboss.soa.overlord.samples.jbossesb.loan.broker.SetCreditCheckRequestMessageAction" >
+ </action>
<action class="org.jboss.soa.overlord.jbossesb.stateless.actions.SendMessageAction" name="ESBBrokerProcess_Broker__8_action_2" process="process">
<property name="operation" value="checkCredit"/>
<property name="messageType" value="CreditCheckRequest"/>
@@ -199,6 +206,8 @@
<property name="operation" value="checkCredit"/>
<property name="messageType" value="CreditCheckOk"/>
</action>
+ <action name="set-orderConfirm" class="org.jboss.soa.overlord.samples.jbossesb.loan.broker.SetOrderConfirmRequestAction">
+ </action>
<action class="org.jboss.soa.overlord.jbossesb.stateless.actions.SendMessageAction" name="ESBBrokerProcess_Broker__9_action_2" process="process">
<property name="operation" value="confirm"/>
<property name="messageType" value="orderConfirmed"/>
@@ -222,6 +231,7 @@
<property name="operation" value="buy"/>
<property name="messageType" value="bookingReference"/>
<property name="clientRole" value="Buyer"/>
+ <property name="storageClass" value="org.jboss.soa.overlord.samples.jbossesb.loan.broker.MemoryEPRStorage" />
</action>
</actions>
</service>
@@ -234,10 +244,12 @@
<property name="operation" value="checkCredit"/>
<property name="messageType" value="CreditCheckInvalid"/>
</action>
+ <action name="set-orderRejected" class="org.jboss.soa.overlord.samples.jbossesb.loan.broker.SetOrderRejectMessageAction"></action>
<action class="org.jboss.soa.overlord.jbossesb.stateless.actions.SendMessageAction" name="ESBBrokerProcess_Broker__11_action_2" process="process">
<property name="operation" value="buy"/>
<property name="messageType" value="orderRejected"/>
- <property name="clientRole" value="Buyer"/>
+ <property name="clientRole" value="Buyer"/>
+ <property name="storageClass" value="org.jboss.soa.overlord.samples.jbossesb.loan.broker.MemoryEPRStorage" />
</action>
</actions>
</service>
Added: cdl/trunk/samples/jbossesb/brokerage/supplier/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/supplier/MemoryEPRStorage.java
===================================================================
--- cdl/trunk/samples/jbossesb/brokerage/supplier/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/supplier/MemoryEPRStorage.java (rev 0)
+++ cdl/trunk/samples/jbossesb/brokerage/supplier/stateless/src/main/java/org/jboss/soa/overlord/samples/jbossesb/supplier/MemoryEPRStorage.java 2009-03-21 17:11:43 UTC (rev 546)
@@ -0,0 +1,46 @@
+/*
+ * 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.samples.jbossesb.supplier;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.overlord.jbossesb.EPRStorage;
+
+/**
+ * @author <a href="mailto:cyu at redhat.com">Jeff Yu</a>
+ *
+ */
+public class MemoryEPRStorage implements EPRStorage {
+
+ private static final Map<String, EPR> storage = new HashMap<String, EPR>();
+
+ public EPR getEPRByRole(String roleName, Message message) {
+ return storage.get(roleName);
+ }
+
+ public void registerRole(String roleName, Message message) {
+ EPR epr = message.getHeader().getCall().getReplyTo();
+ storage.put(roleName, epr);
+ }
+
+}
Modified: cdl/trunk/samples/jbossesb/brokerage/supplier/stateless/src/main/resources/META-INF/jboss-esb.xml
===================================================================
--- cdl/trunk/samples/jbossesb/brokerage/supplier/stateless/src/main/resources/META-INF/jboss-esb.xml 2009-03-20 16:48:05 UTC (rev 545)
+++ cdl/trunk/samples/jbossesb/brokerage/supplier/stateless/src/main/resources/META-INF/jboss-esb.xml 2009-03-21 17:11:43 UTC (rev 546)
@@ -40,6 +40,8 @@
<action class="org.jboss.soa.overlord.jbossesb.stateless.actions.ReceiveMessageAction" name="ESBBrokerProcess_SupplierTxnProcessor__1_action_1" process="process">
<property name="operation" value="confirm"/>
<property name="messageType" value="orderConfirmed"/>
+ <property name="clientRole" value="Broker" />
+ <property name="storageClass" value="org.jboss.soa.overlord.samples.jbossesb.supplier.MemoryEPRStorage" />
</action>
<action class="org.jboss.soa.overlord.samples.jbossesb.supplier.SetOrderConfirmResponseAction" name="su-1">
</action>
@@ -47,6 +49,7 @@
<property name="operation" value="confirm"/>
<property name="messageType" value="bookingReference"/>
<property name="clientRole" value="Broker"/>
+ <property name="storageClass" value="org.jboss.soa.overlord.samples.jbossesb.supplier.MemoryEPRStorage" />
</action>
</actions>
</service>
@@ -74,6 +77,8 @@
<action class="org.jboss.soa.overlord.jbossesb.stateless.actions.ReceiveMessageAction" name="ESBBrokerProcess_SupplierQuoteEngine__1_action_1" process="process">
<property name="operation" value="getQuote"/>
<property name="messageType" value="requestForQuote"/>
+ <property name="clientRole" value="Broker"/>
+ <property name="storageClass" value="org.jboss.soa.overlord.samples.jbossesb.supplier.MemoryEPRStorage" />
</action>
<action class="org.jboss.soa.overlord.samples.jbossesb.supplier.SetQuoteMessageAction" name="su1-2">
</action>
@@ -81,6 +86,7 @@
<property name="operation" value="getQuote"/>
<property name="messageType" value="quote"/>
<property name="clientRole" value="Broker"/>
+ <property name="storageClass" value="org.jboss.soa.overlord.samples.jbossesb.supplier.MemoryEPRStorage" />
</action>
</actions>
</service>
More information about the overlord-commits
mailing list