From 4081f04850d3eff9eb1bd7241763707bfbb43a45 Mon Sep 17 00:00:00 2001 From: rbrooks Date: Sat, 24 Jul 2010 17:38:31 +0000 Subject: applied Eclipse source cleanup --- .../src/jms/activemq/launch/Activator.java | 86 +++++----- .../src/jms/activemq/launch/RunActiveMq.java | 190 +++++++++++---------- 2 files changed, 139 insertions(+), 137 deletions(-) (limited to 'plugins/jms.activemq.launch') 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 d1476d7fc55..c960502d38a 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 246aba5cd91..aa3a5955aad 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(); + } + } + } + +} -- cgit v1.2.3