private static SimpleString jmsPrefixOf(SimpleString address) { if (address.startsWith(OLD_QUEUE_PREFIX)) { return OLD_QUEUE_PREFIX; } else if (address.startsWith(OLD_TOPIC_PREFIX)) { return OLD_TOPIC_PREFIX; } else { return null; } }
public static SimpleString getOldPrefixedAddress(SimpleString address, RoutingType routingType) { if (routingType == RoutingType.MULTICAST && !address.startsWith(OLD_TOPIC_PREFIX)) { return OLD_TOPIC_PREFIX.concat(address); } else if (routingType == RoutingType.ANYCAST && !address.startsWith(OLD_QUEUE_PREFIX)) { return OLD_QUEUE_PREFIX.concat(address); } return address; } }
public static SimpleString getPrefix(SimpleString address, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return removeAddress(address, entry.getKey()); } } return null; }
public static SimpleString getAddress(SimpleString address, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return removePrefix(address, entry.getKey()); } } return address; }
public static Set<String> getPropertyNames(Message message) { HashSet<String> set = new HashSet<>(); for (SimpleString propName : message.getPropertyNames()) { if (propName.equals(Message.HDR_GROUP_ID)) { set.add(MessageUtil.JMSXGROUPID); } else if (propName.equals(Message.HDR_VALIDATED_USER)) { set.add(MessageUtil.JMSXUSERID); } else if ((!propName.startsWith(JMS) || propName.startsWith(JMSX) || propName.startsWith(JMS_)) && !propName.startsWith(CONNECTION_ID_PROPERTY_NAME) && !propName.equals(Message.HDR_ROUTING_TYPE) && !propName.startsWith(Message.HDR_ROUTE_TO_IDS)) { set.add(propName.toString()); } } set.add(JMSXDELIVERYCOUNT); return set; }
public static void clearProperties(Message message) { /** * JavaDoc for this method states: * Clears a message's properties. * The message's header fields and body are not cleared. * * Since the {@code Message.HDR_ROUTING_TYPE} is used for the JMSDestination header it isn't cleared */ List<SimpleString> toRemove = new ArrayList<>(); for (SimpleString propName : message.getPropertyNames()) { if ((!propName.startsWith(JMS) || propName.startsWith(JMSX) || propName.startsWith(JMS_)) && !propName.equals(Message.HDR_ROUTING_TYPE)) { toRemove.add(propName); } } for (SimpleString propName : toRemove) { message.removeProperty(propName); } }
public static Pair<SimpleString, EnumSet<RoutingType>> getAddressAndRoutingTypes(SimpleString address, EnumSet<RoutingType> defaultRoutingTypes, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return new Pair<>(removePrefix(address, entry.getKey()), EnumSet.of(entry.getValue())); } } return new Pair<>(address, defaultRoutingTypes); }
for (int i = 0; i < names; i++) { final SimpleString oldQueueName = queueNames.get(i); if (oldQueueName.startsWith(prefix)) { prefixedQueueNames.add(oldQueueName); } else {
@Override public void cleanupInternalProperties() { if (properties.hasInternalProperties()) { LinkedList<SimpleString> valuesToRemove = null; for (SimpleString name : getPropertyNames()) { // We use properties to establish routing context on clustering. // However if the client resends the message after receiving, it needs to be removed if ((name.startsWith(Message.HDR_ROUTE_TO_IDS) && !name.equals(Message.HDR_ROUTE_TO_IDS)) || (name.startsWith(Message.HDR_ROUTE_TO_ACK_IDS) && !name.equals(Message.HDR_ROUTE_TO_ACK_IDS))) { if (valuesToRemove == null) { valuesToRemove = new LinkedList<>(); } valuesToRemove.add(name); } } if (valuesToRemove != null) { for (SimpleString removal : valuesToRemove) { this.removeProperty(removal); } } } }
public SimpleString convertName(SimpleString name) { if (name == null) { return null; } if (name.startsWith(OLD_QUEUE_PREFIX)) { return name.subSeq(OLD_QUEUE_PREFIX.length(), name.length()); } else if (name.startsWith(OLD_TOPIC_PREFIX)) { return name.subSeq(OLD_TOPIC_PREFIX.length(), name.length()); } else { return name; } }
private synchronized void doPutValue(final SimpleString key, final PropertyValue value) { if (key.startsWith(AMQ_PROPNAME)) { internalProperties = true; } PropertyValue oldValue = properties.put(key, value); if (oldValue != null) { size += value.encodeSize() - oldValue.encodeSize(); } else { size += SimpleString.sizeofString(key) + value.encodeSize(); } }
public static SimpleString getAddress(SimpleString address, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return removePrefix(address, entry.getKey()); } } return address; }
public static SimpleString getAddress(SimpleString address, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return removePrefix(address, entry.getKey()); } } return address; }
public static SimpleString getAddress(SimpleString address, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return removePrefix(address, entry.getKey()); } } return address; }
public static SimpleString getPrefix(SimpleString address, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return removeAddress(address, entry.getKey()); } } return null; }
public static SimpleString getPrefix(SimpleString address, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return removeAddress(address, entry.getKey()); } } return null; }
public static SimpleString getAddress(SimpleString address, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return removePrefix(address, entry.getKey()); } } return address; }
public static Pair<SimpleString, EnumSet<RoutingType>> getAddressAndRoutingTypes(SimpleString address, EnumSet<RoutingType> defaultRoutingTypes, Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (address.startsWith(entry.getKey())) { return new Pair<>(removePrefix(address, entry.getKey()), EnumSet.of(entry.getValue())); } } return new Pair<>(address, defaultRoutingTypes); }
public AddressInfo getAddressAndRoutingType(Map<SimpleString, RoutingType> prefixes) { for (Map.Entry<SimpleString, RoutingType> entry : prefixes.entrySet()) { if (this.getName().startsWith(entry.getKey())) { AddressInfo newAddressInfo = this.create(PrefixUtil.removePrefix(this.getName(), entry.getKey()), entry.getValue()); return newAddressInfo; } } return this; }
@Test public void testStartsWith() throws Exception { SimpleString s1 = new SimpleString("abcdefghi"); Assert.assertTrue(s1.startsWith(new SimpleString("abc"))); Assert.assertTrue(s1.startsWith(new SimpleString("abcdef"))); Assert.assertTrue(s1.startsWith(new SimpleString("abcdefghi"))); Assert.assertFalse(s1.startsWith(new SimpleString("abcdefghijklmn"))); Assert.assertFalse(s1.startsWith(new SimpleString("aardvark"))); Assert.assertFalse(s1.startsWith(new SimpleString("z"))); }