public void unregisterExchange(AMQShortString name, boolean inUse) throws AMQException
{
final Exchange exchange = _exchangeMap.get(name);
if (exchange == null)
{
throw new AMQException(AMQConstant.NOT_FOUND, "Unknown exchange " + name, null);
}
if (ExchangeDefaults.DEFAULT_EXCHANGE_NAME.equals(name))
{
throw new AMQException(AMQConstant.NOT_ALLOWED, "Cannot unregister the default exchange", null);
}
if (!_host.getSecurityManager().authoriseDelete(exchange))
{
throw new AMQSecurityException();
}
// TODO: check inUse argument
Exchange e = _exchangeMap.remove(name);
_exchangeMapStr.remove(name.toString());
if (e != null)
{
if (e.isDurable())
{
getDurableConfigurationStore().removeExchange(e);
}
e.close();
synchronized (_listeners)
{
for(RegistryChangeListener listener : _listeners)
{
listener.exchangeUnregistered(exchange);
}
}
}
else
{
throw new AMQException("Unknown exchange " + name);
}
}