Package org.lilyproject.runtime.rapi

Examples of org.lilyproject.runtime.rapi.ConfRegistry


    public LilyRuntimeModel buildModel() {
        // Init the configuration manager
        ConfManager confManager = settings.getConfManager();
        confManager.initRuntimeConfig();

        ConfRegistry confRegistry = confManager.getRuntimeConfRegistry();

        return buildModel(confRegistry);
    }
View Full Code Here


        // Init the configuration manager
        ConfManager confManager = settings.getConfManager();
        confManager.initRuntimeConfig();

        ConfRegistry confRegistry = confManager.getRuntimeConfRegistry();

        this.model = buildModel(confRegistry);

        // Validate the config
        List<ConfigError> configErrors = new ArrayList<ConfigError>();
        model.validate(configErrors);
        if (configErrors.size() > 0) {
            StringBuilder errorMsg = new StringBuilder();
            String subject = configErrors.size() == 1 ? "error" : "errors";
            errorMsg.append("Encountered the following ").append(subject).append(" in the runtime configuration: ");
            for (int i = 0; i < configErrors.size(); i++) {
                if (i > 0) {
                    errorMsg.append(", ");
                }
                errorMsg.append(configErrors.get(i).getMessage());
            }
            throw new LilyRTException(errorMsg.toString());
        }

        moduleConfigs = new ArrayList<ModuleConfig>();

        // First read the configuration of each module, and do some classpath checks
        if (infolog.isInfoEnabled()) {
            infolog.info("Reading module configurations of " + model.getModules().size() + " modules.");
        }
        for (ModuleDefinition entry : model.getModules()) {
            if (infolog.isInfoEnabled()) {
                infolog.debug("Reading module config " + entry.getId() + " - " + entry.getFile().getAbsolutePath());
            }
            ModuleConfig moduleConf = ModuleConfigBuilder.build(entry, this);
            moduleConfigs.add(moduleConf);
        }

        // Check / build class path configurations
        Conf classLoadingConf = confRegistry.getConfiguration("classloading");
        List<ClasspathEntry> sharedClasspath = ClassLoaderConfigurer.configureClassPaths(moduleConfigs,
                settings.getEnableArtifactSharing(), classLoadingConf);

        // Construct the shared classloader
        infolog.debug("Creating shared classloader");
View Full Code Here

        return new ConfManagerImpl(confDirs);
    }

    public void testConf() throws Exception {
        Map beans = runtime.getModuleById("conflistenmod").getApplicationContext().getBeansOfType(ConfRegistry.class);
        ConfRegistry confRegistry = (ConfRegistry)beans.get("conf");

        final Set<String> changedPaths = new HashSet<String>();
        final Set<String> changedConfs = new HashSet<String>();

        confRegistry.addListener(new ConfListener() {
            public void confAltered(String path, ChangeType changeType) {
                switch (changeType) {
                    case CONF_CHANGE:
                        changedConfs.add(path);
                        break;
                    case PATH_CHANGE:
                        changedPaths.add(path);
                        break;
                }
            }
        }, null, ConfListener.ChangeType.CONF_CHANGE, ConfListener.ChangeType.PATH_CHANGE);

        // Sleep a second, as it seems the resolution for (my) file system changes is 1 second
        Thread.sleep(1500);
        writeConf(conflistenmodConfDir, "foobar.xml", "<conf x='y'/>");
        writeConf(conflistenmodConfDir, "x/y/foobar.xml", "<conf x='y'/>");

        // Sleep so that we can receive notifications (see configured delay)
        Thread.sleep(1000);

        Assert.assertEquals(2, changedConfs.size());
        Assert.assertEquals(1, changedPaths.size());

        Assert.assertTrue(changedConfs.contains("foobar"));
        Assert.assertTrue(changedConfs.contains("x/y/foobar"));
        Assert.assertTrue(changedPaths.contains("x/y"));

        Collection<String> childPaths = confRegistry.getConfigurations("x/y");
        Assert.assertEquals(1, childPaths.size());
        Assert.assertEquals("foobar", childPaths.iterator().next());

        //
        // Test that removal of a conf causes both a change event for the conf and its containing directory
View Full Code Here

    public void testConf() {
        ApplicationContext appContext = runtime.getModuleById("confmod").getApplicationContext();

        Map beans = appContext.getBeansOfType(ConfRegistry.class);
        ConfRegistry confRegistry = (ConfRegistry)beans.get("conf");

        Conf conf = confRegistry.getConfiguration("test1");
        Assert.assertEquals("Jef", conf.getChild("name").getValue());

        conf = confRegistry.getConfiguration("test2");
        Assert.assertEquals("foobar@hotmail.com", conf.getChild("email").getValue());
        Assert.assertEquals("smtp.google.com", conf.getChild("smtp").getValue());

        conf = confRegistry.getConfiguration("test3");
        Assert.assertEquals(599, conf.getChild("delay").getValueAsInteger());

        String confTestBean1 = (String)appContext.getBean("confTestBean1");
        Assert.assertEquals("foobar@hotmail.com", confTestBean1);
View Full Code Here

TOP

Related Classes of org.lilyproject.runtime.rapi.ConfRegistry

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.