return actualAddress != null ? actualAddress : add;
}
private synchronized Address addAndUpdateAddressMap(final SimpleString address)
{
Address add = new AddressImpl(address);
Address actualAddress;
if (add.containsWildCard())
{
actualAddress = wildCardAddresses.get(address);
}
else
{
actualAddress = addresses.get(address);
}
if (actualAddress == null)
{
actualAddress = add;
addAddress(address, actualAddress);
}
if (actualAddress.containsWildCard())
{
for (Address destAdd : addresses.values())
{
if (destAdd.matches(actualAddress))
{
destAdd.addLinkedAddress(actualAddress);
actualAddress.addLinkedAddress(destAdd);
}
}
}
else
{
for (Address destAdd : wildCardAddresses.values())
{
if (actualAddress.matches(destAdd))
{
destAdd.addLinkedAddress(actualAddress);
actualAddress.addLinkedAddress(destAdd);
}
}
}
return actualAddress;