Differences
This shows you the differences between two versions of the page.
accessing_bundle_resources [2014/02/24 14:25] |
accessing_bundle_resources [2021/04/05 11:23] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Accessing Bundle Resources ====== | ||
+ | To access a resource (file) in a bundle various solutions are possible. A discussion about how to access an included file can be found on [[http:// | ||
+ | ===== BundleContext ===== | ||
+ | Accessing the resource via the BundleContext class is possible but not very convenient. | ||
+ | |||
+ | context.getClass.getResource(" | ||
+ | | ||
+ | ===== URL ===== | ||
+ | Accessing the resource via the URL works in Eclipse but may not working in other OSGi environments. | ||
+ | |||
+ | URL url = new URL(" | ||
+ | InputStream inputStream = url.openConnection().getInputStream(); | ||
+ | | ||
+ | ====== FileLocator ====== | ||
+ | Bundle yourBundle = Platform.getBundle(" | ||
+ | Path relativePathToBundle = new Path("/ | ||
+ | FileLocator.openStream(yourBundle, | ||
+ | |||
+ | | ||
+ | {{tag> |