Package org.lilyproject.runtime.configuration

Examples of org.lilyproject.runtime.configuration.ConfManager


    }


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

        ConfRegistry confRegistry = confManager.getRuntimeConfRegistry();

        return buildModel(confRegistry);
    }
View Full Code Here


            throw new LilyRTException("This Lily Runtime instance has already been started before.");
        }
        state = LifeCycle.STARTED;

        // 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");

        rootClassLoader = ClassLoaderBuilder.build(sharedClasspath, this.getClass().getClassLoader(), settings.getRepository());

        // Construct the classloaders of the various modules
        List<ClassLoader> moduleClassLoaders = new ArrayList<ClassLoader>();
        for (ModuleConfig cfg : moduleConfigs) {
            ClassLoader classLoader = cfg.getClassLoadingConfig().getClassLoader(getClassLoader());
            moduleClassLoaders.add(classLoader);
        }

        // Initialize the ConfManager for the modules configuration
        confManager.initModulesConfig(moduleConfigs);

        // Create the modules
        infolog.info("Starting the modules.");

        modules = new ArrayList<Module>(model.getModules().size());
        for (int i = 0; i < moduleConfigs.size(); i++) {
            ModuleConfig moduleConfig = moduleConfigs.get(i);
            Module module = ModuleBuilder.build(moduleConfig, moduleClassLoaders.get(i), this);
            modules.add(module);
            modulesById.put(module.getDefinition().getId(), module);
        }

        // Start the FAM, conf manager refreshing
        fam.start();
        confManager.startRefreshing();

        infolog.info("Runtime initialisation finished.");
    }
View Full Code Here

TOP

Related Classes of org.lilyproject.runtime.configuration.ConfManager

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.