[jboss-svn-commits] JBL Code SVN: r11442 - in labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src: org/jboss/soa/esb and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Apr 29 12:59:51 EDT 2007


Author: sebcao
Date: 2007-04-29 12:59:51 -0400 (Sun, 29 Apr 2007)
New Revision: 11442

Added:
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/MyJMSListenerAction.java
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/ReturnJMSMessage.java
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/TeamAlert.java
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/ReceiveJMSMessage.java
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/SendJMSMessage.java
Removed:
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/ReceiveJMSMessage.java
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/SendJMSMessage.java
   labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/quickstart/
Log:
JBESB-403

Copied: labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/MyJMSListenerAction.java (from rev 11423, labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/quickstart/MyJMSListenerAction.java)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/MyJMSListenerAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/MyJMSListenerAction.java	2007-04-29 16:59:51 UTC (rev 11442)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.aggregator;
+
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+
+public class MyJMSListenerAction extends AbstractActionLifecycle
+{
+    
+  protected ConfigTree	_config;
+	  
+  public MyJMSListenerAction(ConfigTree config) { _config = config; } 
+  
+  public Message noOperation(Message message) { return message; } 
+
+  public Message displayMessage(Message message) throws Exception{		
+		  logHeader();
+		  System.out.println(new String(message.getBody().getContents()));
+		  logFooter();
+		  return message;         	
+	}
+  
+   public void exceptionHandler(Message message, Throwable exception) {
+	   logHeader();
+	   System.out.println("!ERROR!");
+	   System.out.println(exception.getMessage());
+	   System.out.println("For Message: ");
+	   System.out.println(message.getBody().getContents());
+	   logFooter();
+   }
+	
+
+   // This makes it easier to read on the console
+   private void logHeader() {
+	   System.out.println("\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+   }
+   private void logFooter() {
+	   System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
+   }
+    
+	
+}
\ No newline at end of file

Copied: labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/ReturnJMSMessage.java (from rev 11423, labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/quickstart/ReturnJMSMessage.java)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/ReturnJMSMessage.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/ReturnJMSMessage.java	2007-04-29 16:59:51 UTC (rev 11442)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.aggregator;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.jms.JMSException;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.QueueSender;
+import javax.jms.ObjectMessage;
+import javax.jms.TextMessage;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import org.jboss.soa.esb.message.Message;
+
+public class ReturnJMSMessage {
+       
+    public static void sendMessage(Message esbMessage,String newDestination) throws JMSException, NamingException, Exception {
+    	if (esbMessage == null || newDestination == null) 
+    		throw new Exception("Message and JMS Destination are required");
+    
+    	QueueConnection conn;
+        QueueSession session;
+        Queue que;
+        
+    	InitialContext iniCtx = new InitialContext();
+    	Object tmp = iniCtx.lookup("ConnectionFactory");
+    	QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+    	conn = qcf.createQueueConnection();
+    	que = (Queue) iniCtx.lookup("queue/" + newDestination);
+    	session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+    	conn.start();
+
+    	    	   
+    	String newMsg = new String(esbMessage.getBody().getContents());
+
+    	
+    	QueueSender send = session.createSender(que);        
+        TextMessage tm = session.createTextMessage(newMsg);
+        send.send(tm);
+        
+
+    	conn.stop();
+    }    
+    
+}
\ No newline at end of file

Copied: labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/TeamAlert.java (from rev 11423, labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/quickstart/TeamAlert.java)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/TeamAlert.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/TeamAlert.java	2007-04-29 16:59:51 UTC (rev 11442)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.aggregator;
+
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+
+import quickstart.ReturnJMSMessage;
+
+public class TeamAlert {
+	
+	  protected Message  _message;
+	  protected ConfigTree	_config;
+	  
+	  public TeamAlert (ConfigTree config) { _config = config; } 
+	  	  
+	  public Message sendResponseBlue(Message message) {
+		  try {
+			   logHeader();
+			   System.out.println(new String(message.getBody().getContents()));
+			   System.out.println("Blue Blue Blue");
+			   logFooter();
+			   ReturnJMSMessage.sendMessage(message,"quickstart_Fun_CBR_Blue_Alert");
+		   } catch (Exception e) {
+			   logHeader();
+			   System.out.println(e.getMessage());
+			   logFooter();
+		   }
+		   return message;
+	  }
+	  
+	  public Message sendResponseRed(Message message) {
+		  try {
+			   logHeader();
+			   System.out.println(new String(message.getBody().getContents()));
+			   System.out.println("Red Red Red");
+			   logFooter();
+			   ReturnJMSMessage.sendMessage(message,"quickstart_Fun_CBR_Red_Alert");
+		   } catch (Exception e) {
+			   logHeader();
+			   System.out.println(e.getMessage());
+			   logFooter();
+		   }
+		   return message;
+	  }
+
+	  public Message sendResponseGreen(Message message) {
+		  try {
+			   logHeader();
+			   System.out.println(new String(message.getBody().getContents()));
+			   System.out.println("Green Green Green");
+			   logFooter();
+			   ReturnJMSMessage.sendMessage(message,"quickstart_Fun_CBR_Green_Alert");
+		   } catch (Exception e) {
+			   logHeader();
+			   System.out.println(e.getMessage());
+			   logFooter();
+		   }
+		   return message;
+	  }
+	  
+	  private void logHeader() {
+		  System.out.println("\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+	  }
+	  private void logFooter() {
+		  System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
+	  }
+	
+}

Copied: labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test (from rev 11423, labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/quickstart/test)

Deleted: labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/ReceiveJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/quickstart/test/ReceiveJMSMessage.java	2007-04-27 19:24:49 UTC (rev 11423)
+++ labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/ReceiveJMSMessage.java	2007-04-29 16:59:51 UTC (rev 11442)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, 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) 2005-2006,
- * @author JBoss Inc.
- */
-package quickstart.test;
-
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSession;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-
-public class ReceiveJMSMessage {
-	   QueueConnection conn = null;	   
-	   QueueSession receiverSession = null;	   
-	   Queue receiverQueue = null;	   
-	   QueueReceiver queueReceiver = null;
-	   InitialContext iniCtx = null;
-	   QueueConnectionFactory qcf = null;
-	   String receiveQueueName = "queue/D"; // Default to queue/D
-	   
-	   public ReceiveJMSMessage() {
-		   
-	   }
-	   public void receiveOne() {
-		   try {
-		   if (iniCtx == null) iniCtx = new InitialContext();
-	          if (qcf == null) qcf = (QueueConnectionFactory) iniCtx.lookup("ConnectionFactory");
-	          if (conn == null) {
-	              conn = qcf.createQueueConnection();
-	              conn.start();
-	          }	        
-	          receiverQueue = (Queue) iniCtx.lookup(receiveQueueName);
-	          receiverSession = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
-	    	  queueReceiver = receiverSession.createReceiver(receiverQueue); 
-	    	  TextMessage msg = (TextMessage) queueReceiver.receive(2000);
-	    	  if (msg != null) {
-	    		  System.out.println("*********************************************************");
-	    		  System.out.println(msg);
-	    		  System.out.println("*********************************************************");
-	    	  }	
-		   } catch (Exception e) {
-			   System.out.println(e);
-		   }
-	   }
-	   public static void main(String[] args) {
-		      ReceiveJMSMessage receiver = new ReceiveJMSMessage();
-		      
-		      if(args[0] != null) {
-		    	  receiver.receiveQueueName = args[0];
-		    	  System.out.println("Receiving on: " + receiver.receiveQueueName );		    	 
-		      }		    	  
-		      while (true) { // loop until I'm killed
-		    	  receiver.receiveOne();
-		      }
-	   }
-}

Copied: labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/ReceiveJMSMessage.java (from rev 11439, labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/quickstart/test/ReceiveJMSMessage.java)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/ReceiveJMSMessage.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/ReceiveJMSMessage.java	2007-04-29 16:59:51 UTC (rev 11442)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.aggregator.test;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+import quickstart.test.ReceiveJMSMessage;
+
+public class ReceiveJMSMessage {
+	   QueueConnection conn = null;	   
+	   QueueSession receiverSession = null;	   
+	   Queue receiverQueue = null;	   
+	   QueueReceiver queueReceiver = null;
+	   InitialContext iniCtx = null;
+	   QueueConnectionFactory qcf = null;
+	   String receiveQueueName = "queue/D"; // Default to queue/D
+	   
+	   public ReceiveJMSMessage() {
+		   
+	   }
+	   public void receiveOne() {
+		   try {
+		   if (iniCtx == null) iniCtx = new InitialContext();
+	          if (qcf == null) qcf = (QueueConnectionFactory) iniCtx.lookup("ConnectionFactory");
+	          if (conn == null) {
+	              conn = qcf.createQueueConnection();
+	              conn.start();
+	          }	        
+	          receiverQueue = (Queue) iniCtx.lookup(receiveQueueName);
+	          receiverSession = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+	    	  queueReceiver = receiverSession.createReceiver(receiverQueue); 
+	    	  TextMessage msg = (TextMessage) queueReceiver.receive(2000);
+	    	  if (msg != null) {
+	    		  System.out.println("*********************************************************");
+	    		  System.out.println(msg);
+	    		  System.out.println("*********************************************************");
+	    	  }	
+		   } catch (Exception e) {
+			   System.out.println(e);
+		   }
+	   }
+	   public static void main(String[] args) {
+		      ReceiveJMSMessage receiver = new ReceiveJMSMessage();
+		      
+		      if(args[0] != null) {
+		    	  receiver.receiveQueueName = args[0];
+		    	  System.out.println("Receiving on: " + receiver.receiveQueueName );		    	 
+		      }		    	  
+		      while (true) { // loop until I'm killed
+		    	  receiver.receiveOne();
+		      }
+	   }
+}

Deleted: labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/quickstart/test/SendJMSMessage.java	2007-04-27 19:24:49 UTC (rev 11423)
+++ labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/SendJMSMessage.java	2007-04-29 16:59:51 UTC (rev 11442)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, 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) 2005-2006,
- * @author JBoss Inc.
- */
-package quickstart.test;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.jms.JMSException;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueSession;
-import javax.jms.QueueSender;
-import javax.jms.ObjectMessage;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
-public class SendJMSMessage {
-    QueueConnection conn;
-    QueueSession session;
-    Queue que;
-    
-    
-    public void setupConnection() throws JMSException, NamingException
-    {
-    	InitialContext iniCtx = new InitialContext();
-    	Object tmp = iniCtx.lookup("ConnectionFactory");
-    	QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
-    	conn = qcf.createQueueConnection();
-    	que = (Queue) iniCtx.lookup("queue/quickstart_Aggregator_Request_GW");
-    	session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
-    	conn.start();
-    	System.out.println("Connection Started");
-    }
-    
-    public void stop() throws JMSException 
-    { 
-        conn.stop();
-        session.close();
-        conn.close();
-    }
-    
-    public void sendAMessage(String msg) throws JMSException {
-    	
-        QueueSender send = session.createSender(que);        
-        ObjectMessage tm = session.createObjectMessage(msg);        
-        send.send(tm);        
-        send.close();
-    }
-    public String readAsciiFile(String fileName) throws IOException {
-		  FileReader fr = null;
-		  char[] thechars = null;
-
-		  try {
-			  File thefile = new File( fileName );
-			  fr = new FileReader( thefile );
-			  int size = (int) thefile.length();
-			  thechars = new char[size];
-		
-			  int count, index = 0;
-		
-			  // 	read in the bytes from the input stream
-			  while( ( count = fr.read( thechars, index, size ) ) > 0 ) {
-				  size -= count;
-				  index += count;
-			  }
-			} catch(Exception e) {	
-				System.out.println(e);
-			}
-			finally {
-				if( fr != null )
-		        fr.close();
-			}
-			return new String(thechars);
-
-    } // readAsciiFile
-    
-    public static void main(String args[]) throws Exception
-    {        	    	
-    	SendJMSMessage sm = new SendJMSMessage();
-    	sm.setupConnection();
-    	String fileContent = sm.readAsciiFile("SampleOrder.xml");
-    	System.out.println("---------------------------------------------");
-    	System.out.println(fileContent);
-    	System.out.println("---------------------------------------------");
-    	sm.sendAMessage(fileContent); 
-    	sm.stop();
-    	
-    }
-    
-}
\ No newline at end of file

Copied: labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/SendJMSMessage.java (from rev 11439, labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/quickstart/test/SendJMSMessage.java)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/SendJMSMessage.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/aggregator/src/org/jboss/soa/esb/samples/quickstart/aggregator/test/SendJMSMessage.java	2007-04-29 16:59:51 UTC (rev 11442)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.aggregator.test;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.jms.JMSException;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.QueueSender;
+import javax.jms.ObjectMessage;
+
+import quickstart.test.SendJMSMessage;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class SendJMSMessage {
+    QueueConnection conn;
+    QueueSession session;
+    Queue que;
+    
+    
+    public void setupConnection() throws JMSException, NamingException
+    {
+    	InitialContext iniCtx = new InitialContext();
+    	Object tmp = iniCtx.lookup("ConnectionFactory");
+    	QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+    	conn = qcf.createQueueConnection();
+    	que = (Queue) iniCtx.lookup("queue/quickstart_Aggregator_Request_GW");
+    	session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+    	conn.start();
+    	System.out.println("Connection Started");
+    }
+    
+    public void stop() throws JMSException 
+    { 
+        conn.stop();
+        session.close();
+        conn.close();
+    }
+    
+    public void sendAMessage(String msg) throws JMSException {
+    	
+        QueueSender send = session.createSender(que);        
+        ObjectMessage tm = session.createObjectMessage(msg);        
+        send.send(tm);        
+        send.close();
+    }
+    public String readAsciiFile(String fileName) throws IOException {
+		  FileReader fr = null;
+		  char[] thechars = null;
+
+		  try {
+			  File thefile = new File( fileName );
+			  fr = new FileReader( thefile );
+			  int size = (int) thefile.length();
+			  thechars = new char[size];
+		
+			  int count, index = 0;
+		
+			  // 	read in the bytes from the input stream
+			  while( ( count = fr.read( thechars, index, size ) ) > 0 ) {
+				  size -= count;
+				  index += count;
+			  }
+			} catch(Exception e) {	
+				System.out.println(e);
+			}
+			finally {
+				if( fr != null )
+		        fr.close();
+			}
+			return new String(thechars);
+
+    } // readAsciiFile
+    
+    public static void main(String args[]) throws Exception
+    {        	    	
+    	SendJMSMessage sm = new SendJMSMessage();
+    	sm.setupConnection();
+    	String fileContent = sm.readAsciiFile("SampleOrder.xml");
+    	System.out.println("---------------------------------------------");
+    	System.out.println(fileContent);
+    	System.out.println("---------------------------------------------");
+    	sm.sendAMessage(fileContent); 
+    	sm.stop();
+    	
+    }
+    
+}
\ No newline at end of file




More information about the jboss-svn-commits mailing list