Repository: activemq Updated Branches: refs/heads/master 43d8205cf -> e996dbe7c
https://issues.apache.org/jira/browse/AMQ-5954 Use a single destination transformation method instead of having to different implementations. Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/e996dbe7 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/e996dbe7 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/e996dbe7 Branch: refs/heads/master Commit: e996dbe7c28d928c701daef6b3afd5770ae4c2ed Parents: 43d8205 Author: Timothy Bish <[email protected]> Authored: Mon Apr 25 12:22:06 2016 -0400 Committer: Timothy Bish <[email protected]> Committed: Mon Apr 25 12:22:06 2016 -0400 ---------------------------------------------------------------------- .../activemq/ActiveMQMessageTransformation.java | 74 +++++++++----------- 1 file changed, 35 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/e996dbe7/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageTransformation.java ---------------------------------------------------------------------- diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageTransformation.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageTransformation.java index 5b74689..2d6094e 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageTransformation.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageTransformation.java @@ -19,25 +19,40 @@ package org.apache.activemq; import java.net.MalformedURLException; import java.util.Enumeration; -import javax.jms.*; +import javax.jms.BytesMessage; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MapMessage; import javax.jms.Message; +import javax.jms.MessageEOFException; +import javax.jms.ObjectMessage; +import javax.jms.StreamMessage; +import javax.jms.TextMessage; + import org.apache.activemq.blob.BlobDownloader; -import org.apache.activemq.command.*; +import org.apache.activemq.command.ActiveMQBlobMessage; +import org.apache.activemq.command.ActiveMQBytesMessage; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ActiveMQMapMessage; +import org.apache.activemq.command.ActiveMQMessage; +import org.apache.activemq.command.ActiveMQObjectMessage; +import org.apache.activemq.command.ActiveMQStreamMessage; +import org.apache.activemq.command.ActiveMQTextMessage; /** * A helper class for converting normal JMS interfaces into ActiveMQ specific * ones. - * - * + * + * */ public final class ActiveMQMessageTransformation { - private ActiveMQMessageTransformation() { + private ActiveMQMessageTransformation() { } - + /** * Creates a an available JMS message from another provider. - * + * * @param destination - Destination to be converted into ActiveMQ's * implementation. * @return ActiveMQDestination - ActiveMQ's implementation of the @@ -45,33 +60,14 @@ public final class ActiveMQMessageTransformation { * @throws JMSException if an error occurs */ public static ActiveMQDestination transformDestination(Destination destination) throws JMSException { - ActiveMQDestination activeMQDestination = null; - - if (destination != null) { - if (destination instanceof ActiveMQDestination) { - return (ActiveMQDestination)destination; - - } else { - if (destination instanceof TemporaryQueue) { - activeMQDestination = new ActiveMQTempQueue(((Queue)destination).getQueueName()); - } else if (destination instanceof TemporaryTopic) { - activeMQDestination = new ActiveMQTempTopic(((Topic)destination).getTopicName()); - } else if (destination instanceof Queue) { - activeMQDestination = new ActiveMQQueue(((Queue)destination).getQueueName()); - } else if (destination instanceof Topic) { - activeMQDestination = new ActiveMQTopic(((Topic)destination).getTopicName()); - } - } - } - - return activeMQDestination; + return ActiveMQDestination.transform(destination); } /** * Creates a fast shallow copy of the current ActiveMQMessage or creates a * whole new message instance from an available JMS message from another * provider. - * + * * @param message - Message to be converted into ActiveMQ's implementation. * @param connection * @return ActiveMQMessage - ActiveMQ's implementation object of the @@ -146,18 +142,18 @@ public final class ActiveMQMessageTransformation { msg.setText(textMsg.getText()); activeMessage = msg; } else if (message instanceof BlobMessage) { - BlobMessage blobMessage = (BlobMessage)message; - ActiveMQBlobMessage msg = new ActiveMQBlobMessage(); - msg.setConnection(connection); + BlobMessage blobMessage = (BlobMessage)message; + ActiveMQBlobMessage msg = new ActiveMQBlobMessage(); + msg.setConnection(connection); if (connection != null){ - msg.setBlobDownloader(new BlobDownloader(connection.getBlobTransferPolicy())); + msg.setBlobDownloader(new BlobDownloader(connection.getBlobTransferPolicy())); } - try { - msg.setURL(blobMessage.getURL()); - } catch (MalformedURLException e) { - - } - activeMessage = msg; + try { + msg.setURL(blobMessage.getURL()); + } catch (MalformedURLException e) { + + } + activeMessage = msg; } else { activeMessage = new ActiveMQMessage(); activeMessage.setConnection(connection); @@ -172,7 +168,7 @@ public final class ActiveMQMessageTransformation { /** * Copies the standard JMS and user defined properties from the givem * message to the specified message - * + * * @param fromMessage the message to take the properties from * @param toMessage the message to add the properties to * @throws JMSException
