com.yahoo.osgi.OsgiImpl Maven / Gradle / Ivy
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.osgi;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.component.Version;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.jdisc.application.OsgiFramework;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.launch.Framework;
import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;
/**
* @author Tony Vaagenes
* @author bratseth
* @author gjoranv
*/
public class OsgiImpl implements Osgi {
private static final Logger log = Logger.getLogger(OsgiImpl.class.getName());
private final OsgiFramework jdiscOsgi;
// The initial bundles are never scheduled for uninstall
private final List initialBundles;
// An initial bundle that is not the framework, and can hence be used to look up current bundles
private final Bundle alwaysCurrentBundle;
public OsgiImpl(OsgiFramework jdiscOsgi) {
this.jdiscOsgi = jdiscOsgi;
this.initialBundles = jdiscOsgi.bundles();
if (initialBundles.isEmpty())
throw new IllegalStateException("No initial bundles!");
alwaysCurrentBundle = firstNonFrameworkBundle(initialBundles);
if (alwaysCurrentBundle == null)
throw new IllegalStateException("The initial bundles only contained the framework bundle!");
log.info("Using " + alwaysCurrentBundle + " to lookup current bundles.");
}
@Override
public Bundle[] getBundles() {
List bundles = jdiscOsgi.bundles();
return bundles.toArray(new Bundle[bundles.size()]);
}
@Override
public List getCurrentBundles() {
return jdiscOsgi.getBundles(alwaysCurrentBundle);
}
public Class
© 2015 - 2025 Weber Informatics LLC | Privacy Policy