Package org.apache.qpid.server.model

Examples of org.apache.qpid.server.model.VirtualHost


        final ConfigurationEntry virtualHostEntry = mock(ConfigurationEntry.class);
        String typeName = VirtualHost.class.getSimpleName();
        when(virtualHostEntry.getType()).thenReturn(typeName);
        _brokerEntryChildren.put(typeName, Arrays.asList(virtualHostEntry));
        final VirtualHost virtualHost = mock(VirtualHost.class);
        when(virtualHost.getName()).thenReturn("test");

        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[] { virtualHostEntry, _authenticationProviderEntry1 },
                new ConfiguredObject[] { virtualHost, _authenticationProvider1 });
        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
        assertNotNull(broker);
View Full Code Here


        String typeName = VirtualHost.class.getSimpleName();
        when(virtualHostEntry.getType()).thenReturn(typeName);
        _brokerEntryChildren.put(typeName, Arrays.asList(virtualHostEntry));

        final VirtualHost virtualHost = mock(VirtualHost.class);

        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[]{virtualHostEntry, _authenticationProviderEntry1},
                                                                     new ConfiguredObject[]{virtualHost, _authenticationProvider1});

        Broker broker = _brokerRecoverer.create(recovererProvider, _brokerEntry);
View Full Code Here

        File file = TestFileUtils.createTempFile(this, ".xml", "<virtualhosts><virtualhost><name>" + name + "</name><" + name
                + "></" + name + "></virtualhost></virtualhosts>");
        attributes.put(VirtualHost.CONFIG_PATH, file.getAbsolutePath());
        when(entry.getAttributes()).thenReturn(attributes);

        VirtualHost host = recoverer.create(null, entry, parent);

        assertNotNull("Null is returned", host);
        assertEquals("Unexpected name", getName(), host.getName());
    }
View Full Code Here

        attributes.put(VirtualHost.TYPE, StandardVirtualHostFactory.TYPE);

        attributes.put(VirtualHost.STORE_TYPE, "TESTMEMORY");
        when(entry.getAttributes()).thenReturn(attributes);

        VirtualHost host = recoverer.create(null, entry, parent);

        assertNotNull("Null is returned", host);
        assertEquals("Unexpected name", getName(), host.getName());
    }
View Full Code Here

            String name = inArgs.getStringValue("name");
            String type = inArgs.getStringValue("type");

            NameParser nameParser = new NameParser(name, type);
            String vhostName = nameParser.getVirtualHostName();
            VirtualHost vhost = nameParser.getVirtualHost();

            if (vhost == null)
            {
                if (vhostName == null)
                {
                    agent.raiseException(handle, "VirtualHost names for exchange and queue must match.");
                }
                else
                {
                    agent.raiseException(handle, "VirtualHost " + vhostName + " not found.");
                }
            }
            else
            {
                if (methodName.equals("create")) // method = create
                {
                    try
                    {
                        //boolean strict = inArgs.getBooleanValue("strict");
                        Map<String, Object> properties = inArgs.getValue("properties");

                        boolean durable = false;
                        Object property = properties.get("durable");
                        if (property != null && property instanceof Boolean)
                        {
                            Boolean durableProperty = (Boolean)property;
                            durable = durableProperty.booleanValue();
                            properties.remove("durable");
                        }

                        if (type.equals("exchange")) // create exchange.
                        {
/*
System.out.println("Create Exchange");
System.out.println("vhostName = " + vhostName);
System.out.println("exchange name = " + nameParser.getExchangeName());
System.out.println("properties = " + properties);
*/
                            String exchangeType = "";
                            property = properties.get("exchange-type");
                            if (property != null && property instanceof String)
                            {
                                exchangeType = property.toString();
                                properties.remove("exchange-type");
                            }

                            String alternateExchange = parseAlternateExchange(vhostName, properties);
                            if (alternateExchange != null && alternateExchange.equals("invalid"))
                            {
                                agent.raiseException(handle, "Alternate Exchange must belong to the same Virtual Host as the Exchange being added.");
                                return;
                            }

                            // Note that for Qpid 0.20 the "qpid.msg_sequence=1" and "qpid.ive=1" properties are
                            // not suppored, indeed no exchange properties seem to be supported yet.
                            Map<String,Object> attributes = new HashMap<>();
                            attributes.put(Exchange.NAME, nameParser.getExchangeName());
                            attributes.put(Exchange.STATE, State.ACTIVE);
                            attributes.put(Exchange.DURABLE, durable);
                            attributes.put(Exchange.LIFETIME_POLICY, LifetimePolicy.PERMANENT);
                            attributes.put(Exchange.TYPE, exchangeType);
                            attributes.put(Exchange.ALTERNATE_EXCHANGE, alternateExchange);


                            vhost.createExchange(attributes);

                        } // End of create exchange.
                        else if (type.equals("queue")) // create queue.
                        {
/*
System.out.println("Create Queue");
System.out.println("vhostName = " + vhostName);
System.out.println("queue name = " + nameParser.getQueueName());
System.out.println("properties = " + properties);
*/

                            // TODO Try to map from the QMF create queue properties to the closest equivalents on
                            // the Java Broker. Unfortunately there are a *lot* of frustrating little differences.


                            String alternateExchange = parseAlternateExchange(vhostName, properties);
                            if (alternateExchange != null && alternateExchange.equals("invalid"))
                            {
                                agent.raiseException(handle, "Alternate Exchange must belong to the same Virtual Host as the Queue being added.");
                                return;
                            }

                            // I don't *think* that it make sense to allow setting exclusive or autoDelete to
                            // a queue created from config.
                            Map<String,Object> attributes = new HashMap<String,Object>(properties);
                            attributes.put(Queue.NAME, nameParser.getQueueName());
                            attributes.put(Queue.DURABLE, durable);
                            attributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.PERMANENT);


                            // Set the queue's alternateExchange, which is just a little bit involved......
                            // The queue.setAttribute() method needs an org.apache.qpid.server.model.Exchange instance
                            // not just a name, so we look up org.apache.qpid.server.qmf2.agentdata.Exchange by ID
                            // and get its associated org.apache.qpid.server.model.Exchange. We can do a look up by ID
                            // because we needed to use ObjectIds that were based on names in order to allow qpid-config
                            // to work, so we may as well make use of this convenience here too.
                            if (alternateExchange != null)
                            {
                                ObjectId objectId =
                                        new ObjectId("", "org.apache.qpid.broker:exchange:" + alternateExchange, 0);

                                // Look up Exchange QmfAgentData by ObjectId from the Agent's internal Object store.
                                QmfAgentData object = agent.getObject(objectId);
                                if (object != null)
                                {
                                    org.apache.qpid.server.qmf2.agentdata.Exchange ex =
                                        (org.apache.qpid.server.qmf2.agentdata.Exchange)object;

                                    Exchange altEx = ex.getExchange();
                                    attributes.put(Queue.ALTERNATE_EXCHANGE, altEx.getId());
                                }
                            }
                            Queue queue = vhost.createQueue(attributes);
                        }
                        else if (type.equals("binding")) // create binding.
                        {
                            Exchange exchange = nameParser.getExchange();
                            if (exchange == null)
View Full Code Here

        else if (child instanceof Connection)
        {
            if (!agentConnection && !_objects.containsKey(child))
            {
                // If the parent object is the default vhost set it to null so that the Connection ignores it.
                VirtualHost vhost = (object.getName().equals(_defaultVirtualHost)) ? null : (VirtualHost)object;
                data = new org.apache.qpid.server.qmf2.agentdata.Connection(vhost, (Connection)child);
                _objects.put(child, data);

                // Raise a Client Connect Event.
                _agent.raiseEvent(((org.apache.qpid.server.qmf2.agentdata.Connection)data).createClientConnectEvent());
            }
            agentConnection = false; // Only ignore the first Connection, which is the one from the Agent.
        }
        else if (child instanceof Session)
        {
            if (!_objects.containsKey(child))
            {
                QmfAgentData ref = _objects.get(object); // Get the Connection QmfAgentData so we can get connectionRef.
                if (ref != null)
                {
                    data = new org.apache.qpid.server.qmf2.agentdata.Session((Session)child, ref.getObjectId());
                    _objects.put(child, data);
                }
            }
        }
        else if (child instanceof Exchange)
        {
            if (!_objects.containsKey(child))
            {
                // If the parent object is the default vhost set it to null so that the Connection ignores it.
                VirtualHost vhost = (object.getName().equals(_defaultVirtualHost)) ? null : (VirtualHost)object;
                data = new org.apache.qpid.server.qmf2.agentdata.Exchange(vhost, (Exchange)child);
                _objects.put(child, data);

                // Raise an Exchange Declare Event.
                _agent.raiseEvent(((org.apache.qpid.server.qmf2.agentdata.Exchange)data).createExchangeDeclareEvent());

            }
        }
        else if (child instanceof Queue)
        {
            if (!_objects.containsKey(child))
            {
                // If the parent object is the default vhost set it to null so that the Connection ignores it.
                VirtualHost vhost = (object.getName().equals(_defaultVirtualHost)) ? null : (VirtualHost)object;
                data = new org.apache.qpid.server.qmf2.agentdata.Queue(vhost, (Queue)child);
                _objects.put(child, data);

                // Raise a Queue Declare Event.
                _agent.raiseEvent(((org.apache.qpid.server.qmf2.agentdata.Queue)data).createQueueDeclareEvent());
View Full Code Here

            try
            {
                AMQManagedObject mbean;
                if(child instanceof VirtualHost)
                {
                    VirtualHost vhostChild = (VirtualHost)child;
                    mbean = new VirtualHostMBean(vhostChild, _objectRegistry);
                }
                else if(child instanceof PasswordCredentialManagingAuthenticationProvider)
                {
                    mbean = new UserManagementMBean((PasswordCredentialManagingAuthenticationProvider) child, _objectRegistry);
View Full Code Here

            names.addAll(Arrays.asList(path.split("/")));
        }
        String vhostName = names.get(0);
        String queueName = names.get(1);

        VirtualHost vhost = null;

        for(VirtualHost vh : getBroker().getVirtualHosts())
        {
            if(vh.getName().equals(vhostName))
            {
View Full Code Here

        {
            response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
        }
        else
        {
            VirtualHost vhost = null;
            for(VirtualHost host : _broker.getVirtualHosts())
            {
                if(host.getName().equals(vhostName))
                {
                    vhost = host;
                }
            }
            if(vhost == null)
            {
                response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
            }
            else
            {
                response.setStatus(HttpServletResponse.SC_NO_CONTENT);
                ObjectMapper mapper = new ObjectMapper();
                Map<String,Object> exchangeObject = mapper.readValue(request.getInputStream(), LinkedHashMap.class);

                final boolean isDurable = exchangeObject.get("durable") instanceof Boolean
                                          && ((Boolean)exchangeObject.get("durable"));
                final boolean isAutoDelete = exchangeObject.get("auto_delete") instanceof Boolean
                                          && ((Boolean)exchangeObject.get("auto_delete"));

                final String type = (String) exchangeObject.get("type");
                final Map<String, Object> attributes = new HashMap<String, Object>(exchangeObject);
                attributes.remove("durable");
                attributes.remove("auto_delete");
                attributes.remove("type");

                vhost.createExchange(exchangeName, State.ACTIVE, isDurable,
                                     isAutoDelete ? LifetimePolicy.AUTO_DELETE : LifetimePolicy.PERMANENT,
                                     0l,
                                     type,
                                     attributes);
            }
View Full Code Here

            try
            {
                AMQManagedObject mbean;
                if(child instanceof VirtualHost)
                {
                    VirtualHost vhostChild = (VirtualHost)child;
                    mbean = new VirtualHostMBean(vhostChild, _objectRegistry);
                }
                else if(child instanceof PasswordCredentialManagingAuthenticationProvider)
                {
                    mbean = new UserManagementMBean((PasswordCredentialManagingAuthenticationProvider) child, _objectRegistry);
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.model.VirtualHost

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.