Search in sources :

Example 1 with SimpleMavenResolver

use of org.apache.karaf.main.util.SimpleMavenResolver in project karaf by apache.

the class Main method launch.

public void launch() throws Exception {
    if (config == null) {
        config = new ConfigProperties();
    }
    config.performInit();
    if (config.delayConsoleStart) {
        System.out.println(config.startupMessage);
    }
    String log4jConfigPath = System.getProperty("karaf.etc") + "/org.ops4j.pax.logging.cfg";
    BootstrapLogManager.setProperties(config.props, log4jConfigPath);
    lockCallback = new KarafLockCallback();
    InstanceHelper.updateInstancePid(config.karafHome, config.karafBase, true);
    BootstrapLogManager.configureLogger(LOG);
    for (String provider : config.securityProviders) {
        addSecurityProvider(provider);
    }
    List<File> bundleDirs = getBundleRepos();
    ArtifactResolver resolver = new SimpleMavenResolver(bundleDirs);
    // Start up the OSGI framework
    ClassLoader classLoader = createClassLoader(resolver);
    FrameworkFactory factory = loadFrameworkFactory(classLoader);
    framework = factory.newFramework(config.props);
    setLogger();
    framework.init();
    framework.getBundleContext().addFrameworkListener(lockCallback);
    framework.start();
    FrameworkStartLevel sl = framework.adapt(FrameworkStartLevel.class);
    sl.setInitialBundleStartLevel(config.defaultBundleStartlevel);
    // If we have a clean state, install everything
    if (framework.getBundleContext().getBundles().length == 1) {
        LOG.info("Installing and starting initial bundles");
        File startupPropsFile = new File(config.karafEtc, STARTUP_PROPERTIES_FILE_NAME);
        List<BundleInfo> bundles = readBundlesFromStartupProperties(startupPropsFile);
        installAndStartBundles(resolver, framework.getBundleContext(), bundles);
        LOG.info("All initial bundles installed and set to start");
    }
    ServerInfo serverInfo = new ServerInfoImpl(args, config);
    framework.getBundleContext().registerService(ServerInfo.class, serverInfo, null);
    activatorManager = new KarafActivatorManager(classLoader, framework);
    activatorManager.startKarafActivators();
    setStartLevel(config.lockStartLevel);
    // Progress bar
    if (config.delayConsoleStart) {
        new StartupListener(LOG, framework.getBundleContext());
    }
    monitor();
    registerSignalHandler();
    watchdog();
}
Also used : ServerInfo(org.apache.karaf.info.ServerInfo) FrameworkStartLevel(org.osgi.framework.startlevel.FrameworkStartLevel) ArtifactResolver(org.apache.karaf.main.util.ArtifactResolver) FrameworkFactory(org.osgi.framework.launch.FrameworkFactory) SimpleMavenResolver(org.apache.karaf.main.util.SimpleMavenResolver) URLClassLoader(java.net.URLClassLoader) File(java.io.File)

Aggregations

File (java.io.File)1 URLClassLoader (java.net.URLClassLoader)1 ServerInfo (org.apache.karaf.info.ServerInfo)1 ArtifactResolver (org.apache.karaf.main.util.ArtifactResolver)1 SimpleMavenResolver (org.apache.karaf.main.util.SimpleMavenResolver)1 FrameworkFactory (org.osgi.framework.launch.FrameworkFactory)1 FrameworkStartLevel (org.osgi.framework.startlevel.FrameworkStartLevel)1