Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2010-07-24 13:38:31 -0400
committerrbrooks2010-07-24 13:38:31 -0400
commit4081f04850d3eff9eb1bd7241763707bfbb43a45 (patch)
tree258620df94d4b24077ff103a6c4dea9cb78493fb /plugins/jms.activemq.launch
parent4ed8bddc791fda93940f238c5135556a07041dc0 (diff)
downloadorg.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.tar.gz
org.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.tar.xz
org.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.zip
applied Eclipse source cleanup
Diffstat (limited to 'plugins/jms.activemq.launch')
-rw-r--r--plugins/jms.activemq.launch/src/jms/activemq/launch/Activator.java86
-rw-r--r--plugins/jms.activemq.launch/src/jms/activemq/launch/RunActiveMq.java190
2 files changed, 139 insertions, 137 deletions
diff --git a/plugins/jms.activemq.launch/src/jms/activemq/launch/Activator.java b/plugins/jms.activemq.launch/src/jms/activemq/launch/Activator.java
index d1476d7fc5..c960502d38 100644
--- a/plugins/jms.activemq.launch/src/jms/activemq/launch/Activator.java
+++ b/plugins/jms.activemq.launch/src/jms/activemq/launch/Activator.java
@@ -8,46 +8,46 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package jms.activemq.launch;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends Plugin {
-
- public static final String PLUGIN_ID = "lba.messaging.activemq.launch";
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
+package jms.activemq.launch;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ public static final String PLUGIN_ID = "lba.messaging.activemq.launch";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/plugins/jms.activemq.launch/src/jms/activemq/launch/RunActiveMq.java b/plugins/jms.activemq.launch/src/jms/activemq/launch/RunActiveMq.java
index 246aba5cd9..aa3a5955aa 100644
--- a/plugins/jms.activemq.launch/src/jms/activemq/launch/RunActiveMq.java
+++ b/plugins/jms.activemq.launch/src/jms/activemq/launch/RunActiveMq.java
@@ -8,97 +8,99 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package jms.activemq.launch;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-import javax.jms.Topic;
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
-
-public class RunActiveMq implements IApplication {
- private static String BROKER_URI;
- private BrokerService broker;
-
- private boolean isKillable = true;
- private Session session;
- private MessageConsumer replyToConsumer;
- private Connection connection;
-
- @Override
- public Object start(IApplicationContext appContext) throws Exception {
- broker = new BrokerService();
- broker.setBrokerName("osee");
- broker.setUseShutdownHook(true);
- broker.setUseJmx(false);
- String[] myArgs = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
- BROKER_URI = "tcp://localhost:"+myArgs[0];
- broker.addConnector(BROKER_URI);
- broker.start();
-
- if(isKillable){
- ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_USER, ActiveMQConnection.DEFAULT_PASSWORD, BROKER_URI);
- connection = factory.createConnection();
- connection.start();
- session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- Topic destination = session.createTopic("jms.kill.broker");
- replyToConsumer = session.createConsumer(destination);
- replyToConsumer.setMessageListener(new MessageListener() {
-
- @Override
- public void onMessage(Message arg0) {
- try {
- System.err.println("got a kill message");
- stopBrokerInNewThread();
- System.err.println("did something with a kill message");
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- });
- while(broker.isStarted()){
- Thread.sleep(1000);
- }
- } else {
- while(broker.isStarted()){
- Thread.sleep(60000);
- }
- }
- return null;
- }
-
- @Override
- public void stop() {
- try {
- broker.stop();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- void stopBrokerInNewThread() throws Exception {
- new Thread(new StopIt()).start();
- }
-
- private class StopIt implements Runnable {
- @Override
- public void run() {
- try {
- System.err.println("close the connection");
- connection.close();
- System.err.println("stop the broker");
- broker.stop();
- System.err.println("done");
- } catch (Throwable th) {
- th.printStackTrace();
- }
- }
- }
-
-}
+package jms.activemq.launch;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+import javax.jms.Topic;
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+
+public class RunActiveMq implements IApplication {
+ private static String BROKER_URI;
+ private BrokerService broker;
+
+ private final boolean isKillable = true;
+ private Session session;
+ private MessageConsumer replyToConsumer;
+ private Connection connection;
+
+ @Override
+ public Object start(IApplicationContext appContext) throws Exception {
+ broker = new BrokerService();
+ broker.setBrokerName("osee");
+ broker.setUseShutdownHook(true);
+ broker.setUseJmx(false);
+ String[] myArgs = (String[]) appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
+ BROKER_URI = "tcp://localhost:" + myArgs[0];
+ broker.addConnector(BROKER_URI);
+ broker.start();
+
+ if (isKillable) {
+ ActiveMQConnectionFactory factory =
+ new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_USER, ActiveMQConnection.DEFAULT_PASSWORD,
+ BROKER_URI);
+ connection = factory.createConnection();
+ connection.start();
+ session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ Topic destination = session.createTopic("jms.kill.broker");
+ replyToConsumer = session.createConsumer(destination);
+ replyToConsumer.setMessageListener(new MessageListener() {
+
+ @Override
+ public void onMessage(Message arg0) {
+ try {
+ System.err.println("got a kill message");
+ stopBrokerInNewThread();
+ System.err.println("did something with a kill message");
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+ while (broker.isStarted()) {
+ Thread.sleep(1000);
+ }
+ } else {
+ while (broker.isStarted()) {
+ Thread.sleep(60000);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void stop() {
+ try {
+ broker.stop();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ void stopBrokerInNewThread() throws Exception {
+ new Thread(new StopIt()).start();
+ }
+
+ private class StopIt implements Runnable {
+ @Override
+ public void run() {
+ try {
+ System.err.println("close the connection");
+ connection.close();
+ System.err.println("stop the broker");
+ broker.stop();
+ System.err.println("done");
+ } catch (Throwable th) {
+ th.printStackTrace();
+ }
+ }
+ }
+
+}

Back to the top