Package org.lilyproject.runtime.conf

Examples of org.lilyproject.runtime.conf.ConfImpl


                }

                // Merge the confs
                while (confs.size() >= 2) {
                    // Replace the last 2 confs in the list by a merged conf.
                    ConfImpl parent = confs.remove(confs.size() - 1);
                    ConfImpl child = confs.remove(confs.size() - 1);
                    child.inherit(parent);
                    confs.add(child);
                }

                conf = confs.get(0);
            }
View Full Code Here


            if (cachedConfig == null || cachedConfig.lastModified != configPath.file.lastModified()) {
                if (log.isDebugEnabled()) {
                    log.debug("Configuration: detected updated or added config " + configPath.path + " in " + location);
                }
                long lastModified = configPath.file.lastModified();
                ConfImpl conf = parseConfiguration(configPath.file);
                cachedConfig = new CachedConfig();
                cachedConfig.lastModified = lastModified;
                cachedConfig.conf = conf;
                cachedConfig.state = conf == null ? ConfigState.ERROR : ConfigState.OK;
                confs.put(configPath.path, cachedConfig);
View Full Code Here

            return !name.startsWith(".") && name.endsWith(CONFIG_FILE_EXT);
        }
    }

    private ConfImpl parseConfiguration(ConfigFile file) {
        ConfImpl config = null;
        InputStream is = null;
        try {
            is = file.getInputStream();
            config = XmlConfBuilder.build(is, file.getPath());
        } catch (Throwable e) {
View Full Code Here

import org.lilyproject.runtime.conf.ConfImpl;
import org.lilyproject.runtime.conf.XmlConfBuilder;

public class InheritanceTest extends TestCase {
    public void testInheritance1() throws Exception {
        ConfImpl parent = loadConf("inherit1_parent.xml");

        // Child 1
        {
            ConfImpl child = loadConf("inherit1_child1.xml");
            child.inherit(parent);

            JXPathContext context = JXPathContext.newContext(child);
            assertEquals(1, context.getValue("count(properties)", Integer.class));
            assertEquals(3, context.getValue("count(properties/property)", Integer.class));

            assertEquals("value1", context.getValue("properties/property[@key='key1']"));
            assertEquals("value2 - altered", context.getValue("properties/property[@key='key2']"));
            assertEquals("value3", context.getValue("properties/property[@key='key3']"));
        }

        // Child 2
        {
            ConfImpl child = loadConf("inherit1_child2.xml");
            child.inherit(parent);

            JXPathContext context = JXPathContext.newContext(child);
            assertEquals(1, context.getValue("count(properties)", Integer.class));
            assertEquals(4, context.getValue("count(properties/property)", Integer.class));

            assertEquals("value1", context.getValue("properties/property[@key='key1']"));
            assertEquals("value2 - altered", context.getValue("properties/property[@key='key2'][1]"));
            assertEquals("value2", context.getValue("properties/property[@key='key2'][2]"));
            assertEquals("value3", context.getValue("properties/property[@key='key3']"));
        }

        // Child 3
        {
            ConfImpl child = loadConf("inherit1_child3.xml");
            child.inherit(parent);

            JXPathContext context = JXPathContext.newContext(child);
            assertEquals(1, context.getValue("count(properties)", Integer.class));
            assertEquals(1, context.getValue("count(properties/property)", Integer.class));

            assertEquals("value3", context.getValue("properties/property[@key='key3']"));
        }

        // Child 4
        {
            ConfImpl child = loadConf("inherit1_child4.xml");
            child.inherit(parent);

            JXPathContext context = JXPathContext.newContext(child);
            assertEquals(0, context.getValue("count(*)", Integer.class));
        }
    }
View Full Code Here

            assertEquals(0, context.getValue("count(*)", Integer.class));
        }
    }

    public void testInheritance2() throws Exception {
        ConfImpl parent = loadConf("inherit2_parent.xml");

        // Child 1
        {
            ConfImpl child = loadConf("inherit2_child1.xml");
            child.inherit(parent);

            JXPathContext context = JXPathContext.newContext(child);
            assertEquals(3, context.getValue("count(*)", Integer.class));

            assertEquals("val1", context.getValue("@attr1"));
View Full Code Here

TOP

Related Classes of org.lilyproject.runtime.conf.ConfImpl

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.