/** * If the address to add the binding to contains a wildcard then a copy of the binding (with the * same underlying queue) will be added to the actual mappings. Otherwise the binding is added as * normal. * * @param binding the binding to add * @return true if the address was a new mapping */ @Override public boolean addBinding(final Binding binding) throws Exception { boolean exists = super.addBinding(binding); if (!exists) { Address add = addAndUpdateAddressMap(binding.getAddress()); if (add.containsWildCard()) { for (Address destAdd : add.getLinkedAddresses()) { super.addMappingInternal(destAdd.getAddress(), binding); } } else { for (Address destAdd : add.getLinkedAddresses()) { Bindings bindings = super.getBindingsForRoutingAddress(destAdd.getAddress()); for (Binding b : bindings.getBindings()) { super.addMappingInternal(binding.getAddress(), b); } } } } return exists; }
@Override public Bindings getBindingsForRoutingAddress(final SimpleString address) throws Exception { Bindings bindings = super.getBindingsForRoutingAddress(address); // this should only happen if we're routing to an address that has no mappings when we're // running checkAllowable if (bindings == null && !wildCardAddresses.isEmpty()) { Address add = addAndUpdateAddressMap(address); if (!add.containsWildCard()) { for (Address destAdd : add.getLinkedAddresses()) { Bindings b = super.getBindingsForRoutingAddress(destAdd.getAddress()); if (b != null) { Collection<Binding> theBindings = b.getBindings(); for (Binding theBinding : theBindings) { super.addMappingInternal(address, theBinding); } } } } bindings = super.getBindingsForRoutingAddress(address); } return bindings; }