Best technique for getting the OSGi bundle context?
You can use FrameworkUtil.getBundle(ClassFromBundle).getBundleContext(). See FrameworkUtil JavaDoc.
You can use FrameworkUtil.getBundle(ClassFromBundle).getBundleContext(). See FrameworkUtil JavaDoc.
you can use the Equinox Launcher API. Here’s an example of how you can use the Equinox Launcher api to launch a new instance of equinox with a set of bundles: ` EquinoxLauncher launcher = new EquinoxLauncher(); String equinoxHome = “/path/to/equinox/home”; String[] bundlePaths = { “/path/to/bundle1.jar”, “/path/to/bundle2.jar” }; EquinoxRunConfiguration runConfig = launcher.newConfiguration(); runConfig.setWorkingDir(new File(equinoxHome)); runConfig.setFramework(new … Read more
The error means that your bundle has a Require-Capability: osgi.ee; filter=”(&(osgi.ee=JavaSE)(version=1.8))” entry in its manifest. So this means the bundle will only start when there is a bundle that provides this capability. In case of the osgi.ee capability it is the OSGi framework (equinox) that should provide this capability. Apparently it does not do this. … Read more
“Components” are less formally defined than services. A service is any object that is registered in the OSGi Service Registry and can be looked up using its interface name(s). The only prerequisite is that a service should implement some interface… any interface. For example I could register a runnable object under the java.lang.Runnable interface, and … Read more
You can include a third party jar inside your bundle by adding the third party jar to the root directory of the bundle jar file and then adding a bundle classpath header to the bundle’s manifest, e.g.: Bundle-ClassPath: .,my3rdparty.jar If you want to place third party jar to subdirectory, specify the path without using heading … Read more
Well, since you can not have one part OSGi and one part non-OSGi you’ll need to make your entire app OSGi. In its simplest form you make a single OSGi bundle out of your entire application. Clearly this is not a best practice but it can be useful to get a feel for deploying a … Read more
OK, this took quite some digging, but the answer is not that surprising and not even that complicated: JAXB can’t find jaxb.index, because by default, newInstance(String) uses the current thread’s class loader (as returned by Thread.getContextClassLoader()). This doesn’t work inside Felix, because the OSGi bundles and the framework’s threads have separate class loaders. The solution … Read more
Mark circular dependencies as “Warning” in Eclipse tool to avoid “A CYCLE WAS DETECTED IN THE BUILD PATH” error. In Eclipse go to: Windows -> Preferences -> Java-> Compiler -> Building -> Circular Dependencies
I believe Require-Bundle is an Eclipse thing (that has now made it in the OSGi spec to accommodate Eclipse). The “pure” OSGi way is to use Import-Package, as it specifically decouples the package from the bundle that provides it. You should be declaring dependencies on functionality that you need (the Java API provided by a … Read more
Simply said, OSGi is a dynamic module system for Java. It defines means to install, uninstall, update, start and stop modules. Those modules are called bundles, but are, in their simplest form, actually Java jar files with a special Manifest. Modules can be installed, uninstalled etc without stopping or restarting the Java VM. An OSGi … Read more