return;
}
}
synchronized(exchangeRegistry)
{
Exchange exchange = getExchange(session, exchangeName);
if(method.getPassive())
{
if(exchange == null)
{
exception(session, method, ExecutionErrorCode.NOT_FOUND, "not-found: exchange-name '" + exchangeName + "'");
}
else
{
if (!exchange.getTypeShortString().toString().equals(method.getType())
&& (method.getType() != null && method.getType().length() > 0))
{
exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to redeclare exchange: "
+ exchangeName + " of type " + exchange.getTypeShortString() + " to " + method.getType() + ".");
}
}
}
else
{
if (exchange == null)
{
if (exchangeName.startsWith("amq."))
{
exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to declare exchange: "
+ exchangeName + " which begins with reserved prefix 'amq.'.");
}
else if (exchangeName.startsWith("qpid."))
{
exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to declare exchange: "
+ exchangeName + " which begins with reserved prefix 'qpid.'.");
}
else
{
ExchangeFactory exchangeFactory = virtualHost.getExchangeFactory();
try
{
exchange = exchangeFactory.createExchange(method.getExchange(),
method.getType(),
method.getDurable(),
method.getAutoDelete());
String alternateExchangeName = method.getAlternateExchange();
boolean validAlternate;
if(alternateExchangeName != null && alternateExchangeName.length() != 0)
{
Exchange alternate = getExchange(session, alternateExchangeName);
if(alternate == null)
{
validAlternate = false;
}
else