Search in sources :

Example 11 with BundleReference

use of org.osgi.framework.BundleReference in project aries by apache.

the class Utils method getBundleContext.

private static BundleContext getBundleContext(ClassLoader cl2) {
    ClassLoader cl = cl2;
    BundleContext result = null;
    while (result == null && cl != null) {
        if (cl instanceof BundleReference) {
            Bundle b = ((BundleReference) cl).getBundle();
            result = b.getBundleContext();
            if (result == null) {
                try {
                    b.start();
                    result = b.getBundleContext();
                } catch (BundleException e) {
                }
                break;
            }
        } else if (cl != null) {
            cl = cl.getParent();
        }
    }
    return result;
}
Also used : Bundle(org.osgi.framework.Bundle) BundleReference(org.osgi.framework.BundleReference) BundleException(org.osgi.framework.BundleException) BundleContext(org.osgi.framework.BundleContext)

Aggregations

BundleReference (org.osgi.framework.BundleReference)11 Bundle (org.osgi.framework.Bundle)6 File (java.io.File)2 InputStream (java.io.InputStream)2 ServiceLoader (java.util.ServiceLoader)2 LoggerContext (org.apache.logging.log4j.core.LoggerContext)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 Test (org.junit.Test)2 URLClassLoader (java.net.URLClassLoader)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Preference (org.apache.felix.ipojo.extender.internal.queue.pref.Preference)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ITopic (org.eclipse.help.ITopic)1 IUAElement (org.eclipse.help.IUAElement)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 FunctionInfo (org.eclipse.linuxtools.cdt.libhover.FunctionInfo)1 LibHoverInfo (org.eclipse.linuxtools.cdt.libhover.LibHoverInfo)1