[jboss-svn-commits] JBL Code SVN: r7902 - in labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src: . quickstart
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 28 16:29:46 EST 2006
Author: burrsutter
Date: 2006-11-28 16:29:45 -0500 (Tue, 28 Nov 2006)
New Revision: 7902
Added:
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/Launcher.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/MyJMSListenerAction.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/ReturnJMSMessage.java
Log:
Added a folder remotely
Added: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/Launcher.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/Launcher.java 2006-11-28 21:29:12 UTC (rev 7901)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/Launcher.java 2006-11-28 21:29:45 UTC (rev 7902)
@@ -0,0 +1,84 @@
+package quickstart;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.listeners.gateway.GatewayListenerController;
+import org.jboss.soa.esb.listeners.message.EsbListenerController;
+
+
+public class Launcher {
+ private static Log log = LogFactory.getLog(Launcher.class);
+
+ private EsbListenerController _esbListController;
+ private GatewayListenerController _gatewayController;
+
+
+
+ private Logger _logger = Logger.getLogger(Launcher.class);
+
+ public static void main (String args[]) throws Exception {
+
+ log.info("args passed into Launcher: " + args.length);
+ for (int x=0; x<args.length; x++)
+ log.info("arg[" + x + "]=" + args[x]);
+
+
+ Launcher launcher = new Launcher();
+
+ launcher.triggerListener(Long.valueOf(args[0]).longValue(), args[1], args[2]);
+
+ }
+
+ private void triggerListener(long runTime, String messageAwareConfigFile,
+ String gatewayConfigFile) throws Exception{
+ try
+ {
+
+ if (null != messageAwareConfigFile) {
+ _logger.info("starting message aware listener with config file - " +
+ messageAwareConfigFile);
+ _esbListController = new EsbListenerController(messageAwareConfigFile);
+
+ new Thread(_esbListController).start();
+ Thread.sleep(2000);
+
+ }
+ if (null != gatewayConfigFile) {
+ _logger.info("starting gateway listener with config file - " +
+ gatewayConfigFile);
+ _gatewayController = new GatewayListenerController(gatewayConfigFile);
+ new Thread(_gatewayController).start();
+
+ Thread.sleep(2000);
+ }
+
+ System.out.println("**Listener Ready**");
+
+// This code is used to automatically shutdown the listeners which
+// might be useful for automated testing purposes. It is not needed
+// in the quickstart samples.
+// _logger.info("going to sleep now for " + runTime + " milliseconds...");
+// Thread.sleep(runTime);
+// if (null != messageAwareConfigFile) {
+// _logger.info("shutting down message aware listener...");
+// _esbListController.requestEnd();
+// }
+//
+// if (null != gatewayConfigFile) {
+// _logger.info("shutting down gateway listener...");
+// _gatewayController.requestEnd();
+// }
+
+
+ }
+ catch (Exception e) {
+ _logger.error(e);
+ throw(e);
+ }
+
+
+ }
+
+
+}
\ No newline at end of file
Added: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/MyJMSListenerAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/MyJMSListenerAction.java 2006-11-28 21:29:12 UTC (rev 7901)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/MyJMSListenerAction.java 2006-11-28 21:29:45 UTC (rev 7902)
@@ -0,0 +1,72 @@
+package quickstart;
+
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.Header;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.apache.log4j.Logger;
+
+public class MyJMSListenerAction
+{
+
+ 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("Body: " + new String(message.getBody().getContents()));
+ logFooter();
+ return message;
+ }
+
+ public Message playWithMessage(Message message) throws Exception {
+ Header msgHeader = message.getHeader();
+ Body msgBody = message.getBody();
+ Call theCall = msgHeader.getCall();
+ EPR theEpr = theCall.getFrom();
+ String contents = new String(msgBody.getContents());
+ StringBuffer sb = new StringBuffer();
+ sb.append("BEFORE\n");
+ sb.append(contents);
+ sb.append("\nAFTER");
+ msgBody.setContents(sb.toString().getBytes());
+ 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();
+ }
+
+ public void sendResponse(Message message) {
+ try {
+ logHeader();
+ System.out.println(new String(message.getBody().getContents()));
+ logFooter();
+ ReturnJMSMessage.sendMessage(message,"quickstart_helloworld_action_Response");
+ } catch (Exception e) {
+ logHeader();
+ System.out.println(e.getMessage());
+ 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
Added: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/ReturnJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/ReturnJMSMessage.java 2006-11-28 21:29:12 UTC (rev 7901)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_action/src/quickstart/ReturnJMSMessage.java 2006-11-28 21:29:45 UTC (rev 7902)
@@ -0,0 +1,49 @@
+package quickstart;
+
+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
More information about the jboss-svn-commits
mailing list