[overlord-commits] Overlord SVN: r790 - in cdl/trunk/samples/jbossesb/client: src and 5 other directories.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Thu Aug 20 23:20:54 EDT 2009


Author: jeff.yuchang
Date: 2009-08-20 23:20:54 -0400 (Thu, 20 Aug 2009)
New Revision: 790

Added:
   cdl/trunk/samples/jbossesb/client/src/org/
   cdl/trunk/samples/jbossesb/client/src/org/jboss/
   cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/
   cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/
   cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/
   cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/BrokerClient.java
   cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/BuyerClient.java
   cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/WSBuyerClient.java
Removed:
   cdl/trunk/samples/jbossesb/client/src/com/
Modified:
   cdl/trunk/samples/jbossesb/client/build.xml
Log:
* update the example's client package name.


Modified: cdl/trunk/samples/jbossesb/client/build.xml
===================================================================
--- cdl/trunk/samples/jbossesb/client/build.xml	2009-08-20 21:32:47 UTC (rev 789)
+++ cdl/trunk/samples/jbossesb/client/build.xml	2009-08-21 03:20:54 UTC (rev 790)
@@ -39,7 +39,7 @@
 	</target>
 
 	<target name="runPurchasingClient" depends="compile">
-		<java fork="yes" classname="com.acme.services.buyer.BuyerClient">
+		<java fork="yes" classname="org.jboss.savara.examples.client.BuyerClient">
 			<classpath refid="project.classpath" />
 			<classpath location="${classes.dir}" />
 		</java>
@@ -47,7 +47,7 @@
 	</target>
 	
 	<target name="runBrokerageClient" depends="compile">
-		<java fork="yes" classname="com.acme.services.buyer.BrokerClient">
+		<java fork="yes" classname="org.jboss.savara.examples.client.BrokerClient">
 			<classpath refid="project.classpath" />
 			<classpath location="${classes.dir}" />
 		</java>

Added: cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/BrokerClient.java
===================================================================
--- cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/BrokerClient.java	                        (rev 0)
+++ cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/BrokerClient.java	2009-08-21 03:20:54 UTC (rev 790)
@@ -0,0 +1,85 @@
+/*
+ * 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.savara.examples.client;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+
+/**
+ * @author jeffyu
+ *
+ */
+public class BrokerClient {
+	
+   private static Logger logger = Logger.getLogger(BrokerClient.class);
+    
+   private ServiceInvoker brokerInvoker; 
+	
+    public BrokerClient() {
+
+    	System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");
+		
+        try {
+        	brokerInvoker = new ServiceInvoker("org.pi4soa.esbbroker.esbbroker", "ESBBrokerProcess_Broker");
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to create ServiceInvoker", e);
+        }
+    }
+
+    public void run() {
+    	
+    	String id = "20";
+    	
+       	String quoteReq="<enquiry id=\"" + id +"\" ></enquiry>";
+        	
+        Message mesg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+        mesg.getBody().add(quoteReq);
+        mesg.getProperties().setProperty("org.jboss.soa.esb.exceptionOnDeliverFailure", "true");
+        
+        try {
+        	System.out.println("=========================================");
+        	System.out.println("Request: " + mesg.getBody().get());
+        	Message reply=brokerInvoker.deliverSync(mesg, 50000);
+        	System.out.println("Reply: "+reply.getBody().get());
+        	
+        	Thread.sleep(5000);//Waiting...
+        	
+        	System.out.println("Sending Buy request to Broker...");
+	        String buyReq = "<buy id=\"" + id + "\" supplierDesc=\"{http://www.jboss.org/overlord/loanBroker}Supplier1\" quoteValue=\"10\"></buy>";	
+	        mesg.getBody().add(buyReq);
+	        
+	        System.out.println("Request: " + mesg.getBody().get());
+	        reply = brokerInvoker.deliverSync(mesg, 50000);
+	        System.out.println("Reply: " + reply.getBody().get());
+	        System.out.println("=========================================");
+        } catch (Exception e) {
+            logger.error(e);
+            e.printStackTrace();
+        }
+    }
+    
+	public static void main(String[] args) {
+		BrokerClient client=new BrokerClient();
+		client.run();
+	}
+}

Added: cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/BuyerClient.java
===================================================================
--- cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/BuyerClient.java	                        (rev 0)
+++ cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/BuyerClient.java	2009-08-21 03:20:54 UTC (rev 790)
@@ -0,0 +1,80 @@
+/*
+ * 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.savara.examples.client;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+
+/**
+ * @author gary
+ */
+public class BuyerClient {
+	
+    private static Logger logger = Logger.getLogger(BuyerClient.class);
+    
+    private ServiceInvoker storeInvoker; 
+	
+    public BuyerClient() {
+ 
+    	System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");
+		
+        try {
+        	storeInvoker = new ServiceInvoker("org.pi4soa.purchase.purchasegoods", "PurchaseGoodsProcess_Store");
+        } catch (Exception e) {
+        	e.printStackTrace();
+            throw new RuntimeException("Failed to create ServiceInvoker", e);
+        }
+    }
+
+    public void run() {
+
+       	String buyReq="<BuyRequest id=\"5\" ></BuyRequest>";
+        	
+        Message mesg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+        mesg.getBody().add(buyReq);
+        mesg.getProperties().setProperty("org.jboss.soa.esb.exceptionOnDeliverFailure", "true");
+    		
+        try {
+        	System.out.println("=========================================");
+        	System.out.println("Request: "+mesg.getBody().get());
+        	Message reply=storeInvoker.deliverSync(mesg, 20000);
+        	
+        	if (reply != null) {
+        		System.out.println("Reply: "+reply.getBody().get());
+        	} else {
+        		System.err.println("NO REPLY");
+        	}
+        	System.out.println("=========================================");
+        } catch (Exception e) {
+            logger.error(e);
+            e.printStackTrace();
+        }
+    }
+    
+	public static void main(String[] args) {
+		BuyerClient client=new BuyerClient();
+		
+		client.run();
+	}
+
+}

Added: cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/WSBuyerClient.java
===================================================================
--- cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/WSBuyerClient.java	                        (rev 0)
+++ cdl/trunk/samples/jbossesb/client/src/org/jboss/savara/examples/client/WSBuyerClient.java	2009-08-21 03:20:54 UTC (rev 790)
@@ -0,0 +1,69 @@
+/*
+ * 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.savara.examples.client;
+
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * @author <a href="mailto:cyu at redhat.com">Jeff Yu</a>
+ *
+ */
+public class WSBuyerClient {
+
+    public void sendMessageToJBRListener(String protocol, int port, String message) throws Throwable {
+        String locatorURI = protocol + "://localhost:" + port;
+        InvokerLocator locator = new InvokerLocator(locatorURI);
+        System.out.println("Calling JBoss Remoting Listener using locator URI: " + locatorURI);
+
+        Client remotingClient = null;
+        try {
+            remotingClient = new Client(locator);
+            remotingClient.connect();
+
+            // Deliver the message to the listener...
+            Object response = remotingClient.invoke(message);
+            System.out.println("JBR Class: " + response.getClass().getName());
+            System.out.println("Response from JBoss Remoting Listener '" + locatorURI + "' was '" + response + "'.");
+        } finally {
+            if(remotingClient != null) {
+                remotingClient.disconnect();
+            }
+        }
+    }
+    
+    private static String getMessage(String messageNum) {
+        String msg = new String(StreamUtils.readStream(WSBuyerClient.class.getResourceAsStream("/soap_message_" + messageNum + ".xml")));
+        return msg;
+    }
+    
+	
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) throws Throwable{
+		WSBuyerClient client = new WSBuyerClient();
+		String msg = getMessage("01");
+		System.out.println(msg);
+		client.sendMessageToJBRListener("http", 8765, msg);
+	}
+
+}



More information about the overlord-commits mailing list