Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2008, 2010 VMware Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: VMware Inc. - initial contribution /
package org.eclipse.virgo.nano.config.internal;
import  org.osgi.service.cm.ConfigurationAdmin;

ConfigurationInitialiser

Concurrent Semantics
threadsafe

public final class ConfigurationInitialiser {
        
    public KernelConfiguration start(BundleContext contextEventLogger eventLoggerthrows IOException {
        //The ConfigurationAdmin service is already available because the caller of this method(CoreBundleActivator.activate)
        //is a DS component that statically requires it
        ServiceReference<ConfigurationAdmin> configurationAdminReference = context.getServiceReference(ConfigurationAdmin.class);
        ConfigurationAdmin configAdmin = null;
        if (configurationAdminReference != null) {
            configAdmin = (ConfigurationAdmin) context.getService(configurationAdminReference);
        }
        if (configAdmin == null) {
            throw new IllegalStateException("ConfigurationAdmin service missing");
        }
        KernelConfiguration configuration = new KernelConfiguration(context);
        publishConfiguration(contexteventLoggerconfigurationconfigAdmin);
        initializeDumpContributor(contextconfigAdmin);
        initializeConsoleConfigurationConvertor(contextconfigAdmin);
        return configuration;
    }
    private void publishConfiguration(BundleContext contextEventLogger eventLoggerKernelConfiguration configuration,
        ConfigurationAdmin configAdminthrows IOException {
        PropertiesSource[] sources = new PropertiesSource[] { new UserConfigurationPropertiesSource(configuration.getConfigDirectories()),
            new OvfPropertiesSource(contexteventLogger), new KernelConfigurationPropertiesSource(configuration),
            new CommandLinePropertiesSource(contexteventLogger) };
        ConfigurationPublisher configPublisher = new ConfigurationPublisher(configAdminsources);
        configPublisher.publishConfigurations();
        configPublisher.registerConfigurationExporterService(context);
    }
    private void initializeDumpContributor(BundleContext context, ConfigurationAdmin configAdmin) {
        ConfigurationAdminDumpContributor dumpContributor = new ConfigurationAdminDumpContributor(configAdmin);
        this..track(context.registerService(DumpContributor.class.getName(), dumpContributornull));
    }
    
    private void initializeConsoleConfigurationConvertor(BundleContext context, ConfigurationAdmin configAdmin) {
         = new ConsoleConfigurationConvertor(contextconfigAdmin);
    }
    public void stop() {
        this..unregisterAll();
    }
New to GrepCode? Check out our FAQ X