Check for the presence of a prefix before asking for a substring
This commit is contained in:
Timothy Bish 2014-10-14 11:46:49 -04:00
parent 0cf7c0bc47
commit 78446ad175
1 changed files with 10 additions and 1 deletions

View File

@ -47,6 +47,8 @@ public class ActiveMQJMSVendor extends JMSVendor {
final public static ActiveMQJMSVendor INSTANCE = new ActiveMQJMSVendor();
private static final String PREFIX_MARKER = "://";
private ActiveMQJMSVendor() {
}
@ -87,7 +89,13 @@ public class ActiveMQJMSVendor extends JMSVendor {
@Override
public <T extends Destination> T createDestination(String name, Class<T> kind) {
String destinationName = name.substring(name.lastIndexOf("://") + 3);
String destinationName = name;
int prefixEnd = name.lastIndexOf(PREFIX_MARKER);
if (prefixEnd >= 0) {
destinationName = name.substring(prefixEnd + PREFIX_MARKER.length());
}
if (kind == Queue.class) {
return kind.cast(new ActiveMQQueue(destinationName));
}
@ -100,6 +108,7 @@ public class ActiveMQJMSVendor extends JMSVendor {
if (kind == TemporaryTopic.class) {
return kind.cast(new ActiveMQTempTopic(destinationName));
}
return kind.cast(ActiveMQDestination.createDestination(name, ActiveMQDestination.QUEUE_TYPE));
}