Use a single destination transformation method instead of having to
different implementations.
This commit is contained in:
Timothy Bish 2016-04-25 12:22:06 -04:00
parent 43d8205cf0
commit e996dbe7c2
1 changed files with 35 additions and 39 deletions

View File

@ -19,10 +19,25 @@ 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
@ -45,26 +60,7 @@ 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);
}
/**