简体   繁体   中英

How to get Bundle Object from ClassLoader? (Java, OSGI)

I'm working on some old code which depends on:

import org.eclipse.osgi.framework.adaptor.BundleClassLoader;

and uses it here:

protected Bundle getBundle() {
    BundleClassLoader cl = (BundleClassLoader) editor.getClass().getClassLoader();
    return cl.getBundle();
}

Is there a new way to do this? (Retrieve the bundle from the ClassLoader) I'm not finding any resources on this change. BundleClassLoader seems to have been deprecated..

您可以使用FrameworkUtil。

 Bundle b = FrameworkUtil.getBundle( editor.getClass() );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM