Package org.apache.qpid.server.virtualhost

Examples of org.apache.qpid.server.virtualhost.VirtualHostImpl


    }

    public void setPublishFrame(MessagePublishInfo info, final MessageDestination e)
    {
        String routingKey = info.getRoutingKey() == null ? null : info.getRoutingKey().asString();
        VirtualHostImpl virtualHost = getVirtualHost();
        SecurityManager securityManager = virtualHost.getSecurityManager();

        securityManager.authorisePublish(info.isImmediate(), routingKey, e.getName(), virtualHost.getName());

        _currentMessage = new IncomingMessage(info);
        _currentMessage.setMessageDestination(e);
    }
View Full Code Here


        return getVirtualHost(session).getExchange(exchangeName);
    }

    private MessageDestination getDestinationForMessage(Session ssn, MessageTransfer xfr)
    {
        VirtualHostImpl virtualHost = getVirtualHost(ssn);

        MessageDestination destination;
        if(xfr.hasDestination())
        {
            destination = virtualHost.getMessageDestination(xfr.getDestination());
            if(destination == null)
            {
                destination = virtualHost.getDefaultDestination();
            }
        }
        else
        {
            destination = virtualHost.getDefaultDestination();
        }
        return destination;
    }
View Full Code Here

        if(_logger.isDebugEnabled())
        {
            _logger.debug("RECV[" + _channelId + "] BasicGet[" +" queue: " + queueName + " noAck: " + noAck + " ]");
        }

        VirtualHostImpl vHost = _connection.getVirtualHost();
        sync();
        AMQQueue queue = queueName == null ? getDefaultQueue() : vHost.getQueue(queueName.toString());
        if (queue == null)
        {
            _logger.info("No queue for '" + queueName + "'");
            if (queueName != null)
            {
View Full Code Here

    }

    @Override
    public void exchangeDelete(Session session, ExchangeDelete method)
    {
        VirtualHostImpl virtualHost = getVirtualHost(session);

        try
        {
            if (nameNullOrEmpty(method.getExchange()))
            {
                exception(session, method, ExecutionErrorCode.INVALID_ARGUMENT, "Delete not allowed for default exchange");
                return;
            }

            ExchangeImpl exchange = getExchange(session, method.getExchange());

            if(exchange == null)
            {
                exception(session, method, ExecutionErrorCode.NOT_FOUND, "No such exchange '" + method.getExchange() + "'");
            }
            else
            {
                virtualHost.removeExchange(exchange, !method.getIfUnused());
            }
        }
        catch (ExchangeIsAlternateException e)
        {
            exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Exchange in use as an alternate exchange");
View Full Code Here

                          " immediate: " + immediate + " ]");
        }



        VirtualHostImpl vHost = _connection.getVirtualHost();

        if(blockingTimeoutExceeded())
        {
            getVirtualHost().getEventLogger().message(ChannelMessages.FLOW_CONTROL_IGNORED());
            closeChannel(AMQConstant.MESSAGE_TOO_LARGE,
                         "Channel flow control was requested, but not enforced by sender");
        }
        else
        {
            MessageDestination destination;

            if (isDefaultExchange(exchangeName))
            {
                destination = vHost.getDefaultDestination();
            }
            else
            {
                destination = vHost.getMessageDestination(exchangeName.toString());
            }

            // if the exchange does not exist we raise a channel exception
            if (destination == null)
            {
View Full Code Here

    @Override
    public void exchangeBind(Session session, ExchangeBind method)
    {

        VirtualHostImpl virtualHost = getVirtualHost(session);

        if (!method.hasQueue())
        {
            exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "queue not set");
        }
        else
        {
            final String exchangeName = method.getExchange();
            if (nameNullOrEmpty(exchangeName))
            {
                exception(session, method, ExecutionErrorCode.INVALID_ARGUMENT, "Bind not allowed for default exchange");
            }
            else
            {
                //TODO - here because of non-compliant python tests
                // should raise exception ILLEGAL_ARGUMENT "binding-key not set"
                if (!method.hasBindingKey())
                {
                    method.setBindingKey(method.getQueue());
                }
                AMQQueue queue = virtualHost.getQueue(method.getQueue());
                ExchangeImpl exchange = virtualHost.getExchange(exchangeName);
                if(queue == null)
                {
                    exception(session, method, ExecutionErrorCode.NOT_FOUND, "Queue: '" + method.getQueue() + "' not found");
                }
                else if(exchange == null)
View Full Code Here

        {
            _logger.debug("RECV[" + _channelId + "] ExchangeBound[" +" exchange: " + exchangeName + " routingKey: " +
                          routingKey + " queue: " + queueName + " ]");
        }

        VirtualHostImpl virtualHost = _connection.getVirtualHost();
        MethodRegistry methodRegistry = _connection.getMethodRegistry();

        sync();

        int replyCode;
        String replyText;

        if (isDefaultExchange(exchangeName))
        {
            if (routingKey == null)
            {
                if (queueName == null)
                {
                    replyCode = virtualHost.getQueues().isEmpty()
                            ? ExchangeBoundOkBody.NO_BINDINGS
                            : ExchangeBoundOkBody.OK;
                    replyText = null;

                }
                else
                {
                    AMQQueue queue = virtualHost.getQueue(queueName.toString());
                    if (queue == null)
                    {
                        replyCode = ExchangeBoundOkBody.QUEUE_NOT_FOUND;
                        replyText = "Queue '" + queueName + "' not found";
                    }
                    else
                    {
                        replyCode = ExchangeBoundOkBody.OK;
                        replyText = null;
                    }
                }
            }
            else
            {
                if (queueName == null)
                {
                    replyCode = virtualHost.getQueue(routingKey.toString()) == null
                            ? ExchangeBoundOkBody.NO_QUEUE_BOUND_WITH_RK
                            : ExchangeBoundOkBody.OK;
                    replyText = null;
                }
                else
                {
                    AMQQueue queue = virtualHost.getQueue(queueName.toString());
                    if (queue == null)
                    {

                        replyCode = ExchangeBoundOkBody.QUEUE_NOT_FOUND;
                        replyText = "Queue '" + queueName + "' not found";
                    }
                    else
                    {
                        replyCode = queueName.equals(routingKey)
                                ? ExchangeBoundOkBody.OK
                                : ExchangeBoundOkBody.SPECIFIC_QUEUE_NOT_BOUND_WITH_RK;
                        replyText = null;
                    }
                }
            }
        }
        else
        {
            ExchangeImpl exchange = virtualHost.getExchange(exchangeName.toString());
            if (exchange == null)
            {

                replyCode = ExchangeBoundOkBody.EXCHANGE_NOT_FOUND;
                replyText = "Exchange '" + exchangeName + "' not found";
            }
            else if (routingKey == null)
            {
                if (queueName == null)
                {
                    if (exchange.hasBindings())
                    {
                        replyCode = ExchangeBoundOkBody.OK;
                        replyText = null;
                    }
                    else
                    {
                        replyCode = ExchangeBoundOkBody.NO_BINDINGS;
                        replyText = null;
                    }
                }
                else
                {

                    AMQQueue queue = virtualHost.getQueue(queueName.toString());
                    if (queue == null)
                    {
                        replyCode = ExchangeBoundOkBody.QUEUE_NOT_FOUND;
                        replyText = "Queue '" + queueName + "' not found";
                    }
                    else
                    {
                        if (exchange.isBound(queue))
                        {
                            replyCode = ExchangeBoundOkBody.OK;
                            replyText = null;
                        }
                        else
                        {
                            replyCode = ExchangeBoundOkBody.QUEUE_NOT_BOUND;
                            replyText = "Queue '"
                                        + queueName
                                        + "' not bound to exchange '"
                                        + exchangeName
                                        + "'";
                        }
                    }
                }
            }
            else if (queueName != null)
            {
                AMQQueue queue = virtualHost.getQueue(queueName.toString());
                if (queue == null)
                {
                    replyCode = ExchangeBoundOkBody.QUEUE_NOT_FOUND;
                    replyText = "Queue '" + queueName + "' not found";
                }
View Full Code Here

    }

    @Override
    public void exchangeUnbind(Session session, ExchangeUnbind method)
    {
        VirtualHostImpl virtualHost = getVirtualHost(session);

        if (!method.hasQueue())
        {
            exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "queue not set");
        }
        else if (nameNullOrEmpty(method.getExchange()))
        {
            exception(session, method, ExecutionErrorCode.INVALID_ARGUMENT, "Unbind not allowed for default exchange");
        }
        else if (!method.hasBindingKey())
        {
            exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "binding-key not set");
        }
        else
        {
            AMQQueue queue = virtualHost.getQueue(method.getQueue());
            ExchangeImpl exchange = virtualHost.getExchange(method.getExchange());
            if(queue == null)
            {
                exception(session, method, ExecutionErrorCode.NOT_FOUND, "Queue: '" + method.getQueue() + "' not found");
            }
            else if(exchange == null)
View Full Code Here

    @Override
    public void exchangeBound(Session session, ExchangeBound method)
    {

        ExchangeBoundResult result = new ExchangeBoundResult();
        VirtualHostImpl 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);
            }
View Full Code Here

    @Override
    public void queueDeclare(Session session, final QueueDeclare method)
    {

        final VirtualHostImpl virtualHost = getVirtualHost(session);
        DurableConfigurationStore store = virtualHost.getDurableConfigurationStore();

        String queueName = method.getQueue();
        AMQQueue queue;
        //TODO: do we need to check that the queue already exists with exactly the same "configuration"?

        final boolean exclusive = method.getExclusive();
        final boolean autoDelete = method.getAutoDelete();

        if(method.getPassive())
        {
            queue = virtualHost.getQueue(queueName);

            if (queue == null)
            {
                String description = "Queue: " + queueName + " not found on VirtualHost(" + virtualHost + ").";
                ExecutionErrorCode errorCode = ExecutionErrorCode.NOT_FOUND;

                exception(session, method, errorCode, description);

            }
            else if (!verifySessionAccess((ServerSession) session, queue))
            {
                String description = "Cannot declare queue('" + queueName + "'),"
                                                                       + " as exclusive queue with same name "
                                                                       + "declared on another session";
                ExecutionErrorCode errorCode = ExecutionErrorCode.RESOURCE_LOCKED;

                exception(session, method, errorCode, description);

            }
        }
        else
        {

            try
            {

                final String alternateExchangeName = method.getAlternateExchange();


                final Map<String, Object> arguments = QueueArgumentsConverter.convertWireArgsToModel(method.getArguments());

                if(alternateExchangeName != null && alternateExchangeName.length() != 0)
                {
                    arguments.put(Queue.ALTERNATE_EXCHANGE, alternateExchangeName);
                }

                final UUID id = UUID.randomUUID();

                arguments.put(Queue.ID, id);
                arguments.put(Queue.NAME, queueName);

                LifetimePolicy lifetime;
                if(autoDelete)
                {
                    lifetime = exclusive ? LifetimePolicy.DELETE_ON_SESSION_END
                            : LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS;
                }
                else
                {
                    lifetime = LifetimePolicy.PERMANENT;
                }

                arguments.put(Queue.LIFETIME_POLICY, lifetime);

                ExclusivityPolicy exclusivityPolicy = exclusive ? ExclusivityPolicy.SESSION : ExclusivityPolicy.NONE;


                arguments.put(Queue.DURABLE, method.getDurable());

                arguments.put(Queue.EXCLUSIVE, exclusivityPolicy);

                queue = virtualHost.createQueue(arguments);

            }
            catch(QueueExistsException qe)
            {
                queue = qe.getExistingQueue();
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.virtualhost.VirtualHostImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.