public void exchangeBound(Session session, ExchangeBound method)
{
ExchangeBoundResult result = new ExchangeBoundResult();
VirtualHost virtualHost = getVirtualHost(session);
ExchangeImpl exchange;
AMQQueue queue;
boolean isDefaultExchange;
if(!nameNullOrEmpty(method.getExchange()))
{
isDefaultExchange = false;
exchange = virtualHost.getExchange(method.getExchange());
if(exchange == null)
{
result.setExchangeNotFound(true);
}
}
else
{
isDefaultExchange = true;
exchange = null;
}
if(isDefaultExchange)
{
// fake the existence of the "default" exchange for 0-10
if(method.hasQueue())
{
queue = getQueue(session, method.getQueue());
if(queue == null)
{
result.setQueueNotFound(true);
}
else
{
if(method.hasBindingKey())
{
if(!method.getBindingKey().equals(method.getQueue()))
{
result.setKeyNotMatched(true);
}
}
}
}
else if(method.hasBindingKey())
{
if(getQueue(session, method.getBindingKey()) == null)
{
result.setKeyNotMatched(true);
}
}
if(method.hasArguments() && !method.getArguments().isEmpty())
{
result.setArgsNotMatched(true);
}
}
else if(method.hasQueue())
{
queue = getQueue(session, method.getQueue());
if(queue == null)
{
result.setQueueNotFound(true);
}
if(exchange != null && queue != null)
{
boolean queueMatched = exchange.isBound(queue);
result.setQueueNotMatched(!queueMatched);
if(method.hasBindingKey())
{
if(queueMatched)
{
final boolean keyMatched = exchange.isBound(method.getBindingKey(), queue);
result.setKeyNotMatched(!keyMatched);
if(method.hasArguments())
{
if(keyMatched)
{
result.setArgsNotMatched(!exchange.isBound(method.getBindingKey(), method.getArguments(), queue));
}
else
{
result.setArgsNotMatched(!exchange.isBound(method.getArguments(), queue));
}
}
}
else
{
boolean keyMatched = exchange.isBound(method.getBindingKey());
result.setKeyNotMatched(!keyMatched);
if(method.hasArguments())
{
if(keyMatched)
{
result.setArgsNotMatched(!exchange.isBound(method.getBindingKey(), method.getArguments()));
}
else
{
result.setArgsNotMatched(!exchange.isBound(method.getArguments()));
}
}
}
}
else if (method.hasArguments())
{
if(queueMatched)
{
result.setArgsNotMatched(!exchange.isBound(method.getArguments(), queue));
}
else
{
result.setArgsNotMatched(!exchange.isBound(method.getArguments()));
}
}
}
else if(exchange != null && method.hasBindingKey())
{
final boolean keyMatched = exchange.isBound(method.getBindingKey());
result.setKeyNotMatched(!keyMatched);
if(method.hasArguments())
{
if(keyMatched)
{
result.setArgsNotMatched(!exchange.isBound(method.getBindingKey(), method.getArguments()));
}
else
{
result.setArgsNotMatched(!exchange.isBound(method.getArguments()));
}
}
}
}
else if(exchange != null && method.hasBindingKey())
{
final boolean keyMatched = exchange.isBound(method.getBindingKey());
result.setKeyNotMatched(!keyMatched);
if(method.hasArguments())
{
if(keyMatched)
{
result.setArgsNotMatched(!exchange.isBound(method.getBindingKey(), method.getArguments()));
}
else
{
result.setArgsNotMatched(!exchange.isBound(method.getArguments()));
}
}
}
else if(exchange != null && method.hasArguments())
{
result.setArgsNotMatched(!exchange.isBound(method.getArguments()));
}
session.executionResult((int) method.getId(), result);