From e62c36aeb8abc664957548b3a53a0c82c7d4c677 Mon Sep 17 00:00:00 2001 From: Nate Jensen Date: Tue, 13 May 2014 14:02:01 -0500 Subject: [PATCH] Omaha #3133 remove dead activemq code Change-Id: I1a28b58241bd219f59749328cd23b5abd26bf903 Former-commit-id: eaf4ec9916a706d1ea3c5e5968557b777c2bc936 --- .../META-INF/MANIFEST.MF | 4 +- .../edex/uengine/util/JmsSupport.java | 232 ---------------- .../raytheon/edex/uengine/util/MEUtils.java | 258 ------------------ 3 files changed, 1 insertion(+), 493 deletions(-) delete mode 100644 edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/util/JmsSupport.java delete mode 100644 edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/util/MEUtils.java diff --git a/edexOsgi/com.raytheon.edex.uengine/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.uengine/META-INF/MANIFEST.MF index 12d804201e..2ec1b31c29 100644 --- a/edexOsgi/com.raytheon.edex.uengine/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.uengine/META-INF/MANIFEST.MF @@ -34,6 +34,4 @@ Require-Bundle: com.raytheon.uf.edex.core;bundle-version="1.12.1174", com.raytheon.uf.common.util;bundle-version="1.12.1174", org.apache.commons.configuration;bundle-version="1.6.0", org.apache.commons.lang;bundle-version="2.3.0", - org.apache.commons.pool;bundle-version="1.3.0", - org.apache.activemq;bundle-version="5.2.0", - javax.jms;bundle-version="1.0.0" + org.apache.commons.pool;bundle-version="1.3.0" diff --git a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/util/JmsSupport.java b/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/util/JmsSupport.java deleted file mode 100644 index 30778e0cc7..0000000000 --- a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/util/JmsSupport.java +++ /dev/null @@ -1,232 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ - -package com.raytheon.edex.uengine.util; - -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.Session; - -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.util.IndentPrinter; - -import com.raytheon.uf.common.util.StringUtil; - -/** - * Taken from test.ToolSupport, should probably be cleaned up and moved to common? - * - * @author pheaberl - * - */ -public class JmsSupport { - protected Destination destination = null; - protected String subject = "TOOL.DEFAULT"; - protected boolean topic = false; - protected String user = ActiveMQConnection.DEFAULT_USER; - protected String pwd = ActiveMQConnection.DEFAULT_PASSWORD; - protected String url = ActiveMQConnection.DEFAULT_BROKER_URL; - protected boolean transacted = false; - protected boolean durable = false; - protected String clientID = null; - protected int ackMode = Session.AUTO_ACKNOWLEDGE; - protected long timeToLive = 0; - - public JmsSupport() { - - } - - public JmsSupport(String subject, boolean topic, boolean transacted, boolean durable, String clientID) { - super(); - this.subject = subject; - this.topic = topic; - this.transacted = transacted; - this.durable = durable; - this.clientID = clientID; - } - - public JmsSupport(String subject, boolean topic) { - super(); - this.subject = subject; - this.topic = topic; - } - - public Session createSession(Connection connection) throws Exception { - Session session = connection.createSession(transacted, ackMode); - if (topic) { - destination = session.createTopic(subject); - } - else { - destination = session.createQueue(subject); - } - return session; - } - - public Connection createConnection() throws JMSException, Exception { - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user, pwd, url); - Connection connection = connectionFactory.createConnection(); - if (durable && clientID!=null) { - connection.setClientID(clientID); - } - connection.start(); - return connection; - } - - public MessageProducer createProducer(Session session) throws JMSException { - MessageProducer producer = session.createProducer(destination); - if (durable) { - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - } - else { - producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); - } - if( timeToLive!=0 ) - producer.setTimeToLive(timeToLive); - - return producer; - } - - public MessageConsumer createConsumer(Session session) throws JMSException { - return createConsumer(session, null, null); - } - public MessageConsumer createConsumer(Session session,String selector) throws JMSException { - return createConsumer(session,null,selector); - } - public MessageConsumer createConsumer(Session session, MessageListener msgListener) throws JMSException { - - return createConsumer(session,msgListener,null); - } - public MessageConsumer createConsumer(Session session, MessageListener msgListener, String selector) throws JMSException { - MessageConsumer consumer; - if(StringUtil.isEmptyString(selector)) { - consumer = session.createConsumer(destination); - } else { - consumer = session.createConsumer(destination, selector); - } - - if (msgListener != null) { - consumer.setMessageListener(msgListener); - } - return consumer; - } - - public void close(Connection connection, Session session) throws JMSException { - // lets dump the stats - dumpStats(connection); - - if (session != null) { - session.close(); - } - if (connection != null) { - connection.close(); - } - } - - protected void dumpStats(Connection connection) { - ActiveMQConnection c = (ActiveMQConnection) connection; - c.getConnectionStats().dump(new IndentPrinter()); - } - - public int getAckMode() { - return ackMode; - } - - public void setAckMode(int ackMode) { - this.ackMode = ackMode; - } - - public String getClientID() { - return clientID; - } - - public void setClientID(String clientID) { - this.clientID = clientID; - } - - public Destination getDestination() { - return destination; - } - - public void setDestination(Destination destination) { - this.destination = destination; - } - - public boolean isDurable() { - return durable; - } - - public void setDurable(boolean durable) { - this.durable = durable; - } - - public String getPwd() { - return pwd; - } - - public void setPwd(String pwd) { - this.pwd = pwd; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public boolean isTopic() { - return topic; - } - - public void setTopic(boolean topic) { - this.topic = topic; - } - - public boolean isTransacted() { - return transacted; - } - - public void setTransacted(boolean transacted) { - this.transacted = transacted; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - -} diff --git a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/util/MEUtils.java b/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/util/MEUtils.java deleted file mode 100644 index 30863b84bd..0000000000 --- a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/util/MEUtils.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.edex.uengine.util; - -import java.util.ArrayList; -import java.util.Calendar; - -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - -import org.apache.activemq.command.ActiveMQQueue; - -import com.raytheon.uf.common.util.StringUtil; - -/** - * Contains utility methods that are specific to the Micro Engine. All - * methods are {@code static}. All constants are {@code static final}. - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date       	Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * 09Feb2007    TO5         MW Fegan    Initial Creation.
- * 02Oct2007    345         MW Fegan    Corrected correlation ID.
- * 16Oct2007    458         MW Fegan    Corrected logic in HandleTestMessage() to
- *                                       not attempt ACK when connection times out
- * 
- * 
- * - * @author mfegan - * @version 1 - */ - -public class MEUtils { - - /** - * Constructor. - */ - public MEUtils() { - //intentionally empty - nothing to initialize. - } - /** - * Provides a simple interface for posting a message and awaiting - * a reply. This overload sets up a non-durable queue that is - * non-transacted. - *

- * Note that the message returned may be null. - * - * @param text the text of the message to send - * @param destinationQueue the queue to send the message to - * @param responseQueue the queue to use for the response - * @param timeOut time to wait for a response (msec) - * @param correlationID correlation ID of the message, used to screen - * @param clientID client ID for the session - * @param url connection to the local JMS server - * - * @return the return message from the queue - * - * @throws JMSException if a JMS error occurred - * @throws Exception for other errors - */ - public static Message handleTextMessage(String text, - String destinationQueue, - String responseQueue, - long timeOut, - String correlationID, - String clientID, - String url) - throws JMSException, Exception { - return handleTextMessage(text, - destinationQueue, - responseQueue, - timeOut, - correlationID, - clientID, - url, - false, - false, - false); - } - /** - * Provides a simple interface for posting a message and awaiting - * a reply. Creates and posts a JMS Text Message to the specified - * JMS queue. Once the message has been dispatched, a connection - * to the return queue is established and the response is obtained. - *

- * Note that the message returned may be null. - * - * @param text the text of the message to send - * @param destinationQueue the queue to send the message to - * @param responseQueue the queue to use for the response - * @param timeOut time to wait for a response (msec) - * @param correlationID correlation ID of the message, used to screen - * @param clientID client ID for the session - * @param url connection to the local JMS server - * @param topic set true if the connection is a topic - * @param transacted set true is the connection is transacted - * @param durable set true if the connection is durable - * - * @return the return message from the queue - * - * @throws JMSException if a JMS error occurred - * @throws Exception for other errors - */ - public static Message handleTextMessage(String text, - String destinationQueue, - String responseQueue, - long timeOut, - String correlationID, - String clientID, - String url, - boolean topic, - boolean transacted, - boolean durable) - throws JMSException, Exception { - /* create the JMS Support object */ - Connection connection = null; - String selector = ""; - Session session = null; - Message response = null; - JmsSupport jms = new JmsSupport(destinationQueue, - topic, - transacted, - durable, - clientID + "_producer"); - jms.setUrl(url); - - try { - /* create the JMS producer */ - connection = jms.createConnection(); - session = jms.createSession(connection); - MessageProducer producer = jms.createProducer(session); - - /* create the message */ - TextMessage message = session.createTextMessage(text); - - /* sending the message */ - /* set the message correlation id */ - if (StringUtil.isEmptyString(correlationID)) { - correlationID = String.format("%1$tY%1$tm%1$td%1$tH%1$tM%1$tS", - Calendar.getInstance()); - } - message.setJMSCorrelationID(correlationID); - message.setStringProperty("MULE_CORRELATION_ID", correlationID); - /* set the return queue */ - message.setJMSReplyTo(new ActiveMQQueue(responseQueue)); - - /* send the message */ - producer.send(message); - - /* close the session */ - if (transacted) { - session.commit(); - } - jms.close(connection, session); - - /* receiving the return message */ - /* change JMS support for consumer */ - jms.setClientID(clientID + "_consumer"); - jms.setSubject(responseQueue); - jms.setAckMode(Session.CLIENT_ACKNOWLEDGE); - - /* create the JMS consumer */ - selector = "JMSCorrelationID = '" + correlationID + "'"; - connection = jms.createConnection(); - session = jms.createSession(connection); - MessageConsumer consumer = jms.createConsumer(session,selector);//jms.createConsumer(session);//jms.createConsumer(session,selector); - - /* fetch the message for the queue */ - response = consumer.receive(timeOut); - if(response != null) { - response.acknowledge(); - } - - return response; - } finally { - if (jms.isTransacted() && session != null) { - session.commit(); - } - jms.close(connection,session); - } - } - /** - * Converts the elements of an {@code ArrayList} into a comma - * delineated string. - * - * @param data contains the strings to convert - * - * @return the comma delineated string. - */ - public static String changeArrayListToString(ArrayList data) { - StringBuffer retVal = new StringBuffer(); - boolean first = true; - for (Object value : data) { - if (!first) { - retVal.append(","); - } - first = false; - retVal.append(value.toString()); - } - return retVal.toString(); - } - /** - * Filters the values in a byte array, setting to zero bytes less than the - * specified minimum or greater than the specified maximum. - * - * @param bytes buffer of byte values to filter - * @param low minimum value to retain - * @param high maximum value to retain - * - * @return the filtered byte buffer - */ - public static byte[] byteHighLowFilterImage(byte[] bytes, int low, int high) { - for (int i = 0; i < bytes.length; i++) { - int temp = byteToInt(bytes[i]); - if (temp < low) { - bytes[i] = (byte)0; - } else if (temp > high) { - bytes[i] = (byte)0; - } - } - return bytes; - } - /** - * Safely converts a byte value to an integer. - * - * @param val the byte to convert - * - * @return the converted byte - */ - private static int byteToInt(byte val) { - return (val < 0)?255+val:val; - } -}