[jboss-cvs] JBoss Messaging SVN: r6227 - in trunk/examples/jms: durable/src/org/jboss/jms/example and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 31 05:55:01 EDT 2009
Author: ataylor
Date: 2009-03-31 05:55:00 -0400 (Tue, 31 Mar 2009)
New Revision: 6227
Modified:
trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java
trunk/examples/jms/durable/src/org/jboss/jms/example/DurableSubscriberExample.java
trunk/examples/jms/queue/src/org/jboss/jms/example/QueueExample.java
trunk/examples/jms/topic/src/org/jboss/jms/example/TopicExample.java
trunk/examples/jms/transactional/src/org/jboss/jms/example/TransactionalExample.java
Log:
added support for multiple servers
Modified: trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java
===================================================================
--- trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java 2009-03-31 08:56:39 UTC (rev 6226)
+++ trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java 2009-03-31 09:55:00 UTC (rev 6227)
@@ -51,7 +51,7 @@
{
protected static Logger log = Logger.getLogger(JMSExample.class.getName());
- private JBMBootstrapServer server;
+ private JBMBootstrapServer[] servers;
private Connection conn;
@@ -64,7 +64,7 @@
{
if (runServer)
{
- startServer(args);
+ startServer(getServerNames(args));
}
InitialContext ic = new InitialContext();
ConnectionFactory cf = (ConnectionFactory) ic.lookup("/ConnectionFactory");
@@ -132,15 +132,27 @@
return new InitialContext(props);
}
- private void startServer(String[] args) throws Throwable
+ private void startServer(String[][] args) throws Throwable
{
- server = new JBMBootstrapServer(args);
- server.run();
+ servers = new JBMBootstrapServer[args.length];
+ for (int i = 0; i < args.length; i++)
+ {
+ String[] arg = args[i];
+ log.info("starting server with config '" + arg[0] + "'");
+ servers[i] = new JBMBootstrapServer(arg);
+ }
+ for (JBMBootstrapServer server : servers)
+ {
+ server.run();
+ }
}
private void stopServer() throws Throwable
{
- server.shutDown();
+ for (JBMBootstrapServer server : servers)
+ {
+ server.shutDown();
+ }
}
private void deployQueues(Session session, QueueRequestor requestor) throws Exception
@@ -197,7 +209,16 @@
}
}
- public abstract void runExample();
+ private String[][] getServerNames(String[] args)
+ {
+ String[][] actArgs = new String[args.length][1];
+ for (int i = 0; i < args.length; i++)
+ {
+ actArgs[i][0] = args[i].trim();
+ }
+ return actArgs;
+ }
+ public abstract void runExample() throws Exception;
}
Modified: trunk/examples/jms/durable/src/org/jboss/jms/example/DurableSubscriberExample.java
===================================================================
--- trunk/examples/jms/durable/src/org/jboss/jms/example/DurableSubscriberExample.java 2009-03-31 08:56:39 UTC (rev 6226)
+++ trunk/examples/jms/durable/src/org/jboss/jms/example/DurableSubscriberExample.java 2009-03-31 09:55:00 UTC (rev 6227)
@@ -47,7 +47,7 @@
new DurableSubscriberExample().run(args);
}
- public void runExample()
+ public void runExample() throws Exception
{
Connection connection = null;
try
@@ -113,10 +113,6 @@
{
}
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
finally
{
Modified: trunk/examples/jms/queue/src/org/jboss/jms/example/QueueExample.java
===================================================================
--- trunk/examples/jms/queue/src/org/jboss/jms/example/QueueExample.java 2009-03-31 08:56:39 UTC (rev 6226)
+++ trunk/examples/jms/queue/src/org/jboss/jms/example/QueueExample.java 2009-03-31 09:55:00 UTC (rev 6227)
@@ -44,7 +44,7 @@
new QueueExample().run(args);
}
- public void runExample()
+ public void runExample() throws Exception
{
Connection connection = null;
try
@@ -68,10 +68,6 @@
log.info("message received from queue");
log.info("message = " + message2.getText());
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
finally
{
if(connection != null)
Modified: trunk/examples/jms/topic/src/org/jboss/jms/example/TopicExample.java
===================================================================
--- trunk/examples/jms/topic/src/org/jboss/jms/example/TopicExample.java 2009-03-31 08:56:39 UTC (rev 6226)
+++ trunk/examples/jms/topic/src/org/jboss/jms/example/TopicExample.java 2009-03-31 09:55:00 UTC (rev 6227)
@@ -47,7 +47,7 @@
new TopicExample().run(args);
}
- public void runExample()
+ public void runExample() throws Exception
{
Connection connection = null;
try
@@ -93,11 +93,6 @@
{
}
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
finally
{
if (connection != null)
@@ -108,7 +103,7 @@
}
catch (JMSException e)
{
- e.printStackTrace();
+ //ignore
}
}
}
Modified: trunk/examples/jms/transactional/src/org/jboss/jms/example/TransactionalExample.java
===================================================================
--- trunk/examples/jms/transactional/src/org/jboss/jms/example/TransactionalExample.java 2009-03-31 08:56:39 UTC (rev 6226)
+++ trunk/examples/jms/transactional/src/org/jboss/jms/example/TransactionalExample.java 2009-03-31 09:55:00 UTC (rev 6227)
@@ -44,7 +44,7 @@
new TransactionalExample().run(args);
}
- public void runExample()
+ public void runExample() throws Exception
{
Connection connection = null;
try
@@ -75,10 +75,6 @@
log.info("message = " + message2.getText());
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
finally
{
if(connection != null)
More information about the jboss-cvs-commits
mailing list