Package org.apache.qpid.server.configuration

Examples of org.apache.qpid.server.configuration.ConfigurationEntry


                {
                    if (entry.hasChild(uuid))
                    {
                        Set<UUID> children = new HashSet<UUID>(entry.getChildrenIds());
                        children.remove(uuid);
                        ConfigurationEntry referal = new ConfigurationEntry(entry.getId(), entry.getType(),
                                entry.getAttributes(), children, this);
                        _entries.put(entry.getId(), referal);
                    }
                }
                removedIds.add(uuid);
View Full Code Here


    protected boolean replaceEntries(ConfigurationEntry... entries)
    {
        boolean anySaved = false;
        for (ConfigurationEntry entry : entries)
        {
            ConfigurationEntry oldEntry = _entries.put(entry.getId(), entry);
            if (!entry.equals(oldEntry))
            {
                anySaved = true;
            }
        }
View Full Code Here

            {
                throw new IllegalConfigurationException("The data of version " + storeVersion
                        + " can not be loaded by store of version " + STORE_VERSION);
            }

            ConfigurationEntry brokerEntry = toEntry(node, Broker.class, _entries);
            _rootId = brokerEntry.getId();
        }
        catch (IOException e)
        {
           throw new IllegalConfigurationException("Cannot load store from: " + url, e);
        }
View Full Code Here

        }
    }

    protected void copyEntry(UUID entryId, ConfigurationEntryStore initialStore, Map<UUID,ConfigurationEntry> entries)
    {
        ConfigurationEntry entry = initialStore.getEntry(entryId);
        if (entry != null)
        {
            if (entries.containsKey(entryId))
            {
                throw new IllegalConfigurationException("Duplicate id is found: " + entryId
                        + "! The following configuration entries have the same id: " + entries.get(entryId) + ", " + entry);
            }

            Set<UUID> children = entry.getChildrenIds();
            Set<UUID> childrenCopy = children == null? null : new HashSet<UUID>(children);
            ConfigurationEntry copy = new ConfigurationEntry(entryId, entry.getType(), new HashMap<String, Object>(entry.getAttributes()), childrenCopy, this);
            entries.put(entryId, copy);
            if (children != null)
            {
                for (UUID uuid : children)
                {
View Full Code Here

        try
        {
            byte[] bytes = json.getBytes("UTF-8");
            bais = new ByteArrayInputStream(bytes);
            JsonNode node = loadJsonNodes(bais, _objectMapper);
            ConfigurationEntry brokerEntry = toEntry(node, Broker.class, _entries);
            _rootId = brokerEntry.getId();
        }
        catch(Exception e)
        {
            throw new IllegalConfigurationException("Cannot create store from json:" + json);
        }
View Full Code Here

        }
    }

    private void createRootEntry()
    {
        ConfigurationEntry brokerEntry = new ConfigurationEntry(UUIDGenerator.generateRandomUUID(),
                Broker.class.getSimpleName(), Collections.<String, Object> emptyMap(), Collections.<UUID> emptySet(), this);
        _rootId = brokerEntry.getId();
        _entries.put(_rootId, brokerEntry);
    }
View Full Code Here

        _entries.put(_rootId, brokerEntry);
    }

    private Map<String, Object> toTree(UUID rootId, Map<UUID, ConfigurationEntry> entries)
    {
        ConfigurationEntry entry = entries.get(rootId);
        if (entry == null || !entry.getId().equals(rootId))
        {
            throw new IllegalConfigurationException("Cannot find entry with id " + rootId + "!");
        }
        Map<String, Object> tree = new TreeMap<String, Object>();
        Map<String, Object> attributes = entry.getAttributes();
        if (attributes != null)
        {
            tree.putAll(attributes);
        }
        tree.put(ID, entry.getId());
        Set<UUID> childrenIds = entry.getChildrenIds();
        if (childrenIds != null && !childrenIds.isEmpty())
        {
            for (UUID relationship : childrenIds)
            {
                ConfigurationEntry child = entries.get(relationship);
                if (child != null)
                {
                    String relationshipName = child.getType().toLowerCase() + "s";

                    @SuppressWarnings("unchecked")
                    Collection<Map<String, Object>> children = (Collection<Map<String, Object>>) tree.get(relationshipName);
                    if (children == null)
                    {
View Full Code Here

        return relationships;
    }

    private boolean removeInternal(UUID entryId)
    {
        ConfigurationEntry oldEntry = _entries.remove(entryId);
        if (oldEntry != null)
        {
            Set<UUID> children = oldEntry.getChildrenIds();
            if (children != null && !children.isEmpty())
            {
                for (UUID childId : children)
                {
                    removeInternal(childId);
View Full Code Here

                    {
                        Class<? extends ConfiguredObject> expectedChildConfiguredObjectClass = findExpectedChildConfiguredObjectClass(
                                fieldName, expectedConfiguredObjectClass);

                        // assuming it is a child node
                        ConfigurationEntry entry = toEntry(element, expectedChildConfiguredObjectClass, entries);
                        childrenIds.add(entry.getId());
                    }
                    else
                    {
                        if (fieldValues == null)
                        {
                            fieldValues = new ArrayList<Object>();
                        }
                        fieldValues.add(toObject(element));
                    }
                }
                if (fieldValues != null)
                {
                    Object[] array = fieldValues.toArray(new Object[fieldValues.size()]);
                    if (attributes == null)
                    {
                        attributes = new HashMap<String, Object>();
                    }
                    attributes.put(fieldName, array);
                }
            }
            else if (fieldNode.isObject())
            {
                // ignore, in-line objects are not supported yet
            }
            else
            {
                // primitive attribute
                Object value = toObject(fieldNode);
                if (attributes == null)
                {
                    attributes = new HashMap<String, Object>();
                }
                attributes.put(fieldName, value);
            }
        }

        if (type == null)
        {
            if (expectedConfiguredObjectClass == null)
            {
                throw new IllegalConfigurationException("Type attribute is not provided for configuration entry " + parent);
            }
            else
            {
                type = expectedConfiguredObjectClass.getSimpleName();
            }
        }
        String name = null;
        if (attributes != null)
        {
            name = (String) attributes.get(ATTRIBUTE_NAME);
        }
        if ((name == null || "".equals(name)))
        {
            if (expectedConfiguredObjectClass == Broker.class)
            {
                name = DEFAULT_BROKER_NAME;
            }
            else
            {
                throw new IllegalConfigurationException("Name attribute is not provided for configuration entry " + parent);
            }
        }
        UUID id = null;
        if (idAsString == null)
        {
            id = UUIDGenerator.generateRandomUUID();

            _generatedObjectIdDuringLoad = true;
        }
        else
        {
            try
            {
                id = UUID.fromString(idAsString);
            }
            catch (Exception e)
            {
                throw new IllegalConfigurationException(
                        "ID attribute value does not conform to UUID format for configuration entry " + parent);
            }
        }
        ConfigurationEntry entry = new ConfigurationEntry(id, type, attributes, childrenIds, this);
        if (entries.containsKey(id))
        {
            throw new IllegalConfigurationException("Duplicate id is found: " + id
                    + "! The following configuration entries have the same id: " + entries.get(id) + ", " + entry);
        }
View Full Code Here

        }
    }

    public void testGroupProviderValidStateTransitions() throws Exception
    {
        ConfigurationEntry providerEntry = getGroupProviderConfigurationEntry();
        ConfiguredObject provider = createConfiguredObject(providerEntry);
        provider.setDesiredState(State.INITIALISING, State.QUIESCED);
        assertValidStateTransition(provider, State.QUIESCED, State.STOPPED);

        provider = createConfiguredObject(providerEntry);
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.configuration.ConfigurationEntry

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.