I'm looking for a way to automatically install a couple of bundles into an OSGi application, ideally by some kind of batch file / console script so as to allow us to embed it into our build process.
The ideal situation would allow me to just pass the update site URLs to the console and have it download and install them as that would spare from having to install the jars one by one.
Is this possible? Beware that the application I'm talking about is not Eclipse although it contains a couple of Eclipse plugin jars in its bundles directory. I reckon this fact may well imply a slightly different approach to the situation, although I'm not totally sure.
At the moment I'm in control of the application's OSGi console (p2), so I guess that would be the right tool to use, from what I've read.
Thanks
There are several ways to go about this (apart from using p2 which you already mention):
Use the Apache Felix Gogo shell, which has commands to install bundles from a URL, and create a script for that that is executed at startup.
Use the Apache Felix File Install bundle, which allows you to put all bundles in a "hot deploy" folder and automatically installs them.
Use Apache ACE, which is a full blown provisioning solution that allows you to map artifacts to target systems.
Use a Bnd feature to create an executable jar that embeds both the OSGi framework and all bundles and launches them when you start the jar.
Use Apache Karaf features, which allow you to define a list of URLs as a feature and install that feature (using a shell similarly to #1).
There's a lot more to say about each of them, but these are the most-used options I'm aware of.
Related
I am trying to embed Felix in an application of ours to handle plugins. Everything is working fine, however, development and debugging is very cumbersome.
Is there a solution where I can tell Felix to automatically reload a plugin bundle or its classes when I recompile a plugin in Eclipse?
I cannot use any OSGi specific launchers because Felix is embedded in our application
Felix' fileinstall supports directories, but expects a specific structure, which is incompatible with the layout of the Eclipse project.
Any help or pointers to a solution would be greatly appreciated.
You could take a look at Bndtools and the remote launcher. You only need to install a remote agent in your framework and then Bndtools can update any bundle that has changed in the workspace.
This is explained in remote launching. In OSGi enRoute you find an IoT tutorial that uses this model as well as a Karaf App Note.
I've been learning about groovy and it works nicely with eclipse via the eclipse groovy plugin. I've been informed that I should use griffon if I want to write desktop applications.
Is it possible to add libraries/jars/etc to my groovy install so that I can create griffon applications? (I know that I could try this instead, but it doesn't really do what I want.)
Griffon is more than just a set of libraries, it's a full blown framework that provides a command line tool that takes care of many things, like processing resources, launching the application, packaging and deployment. It's also extensible via plugins. This being said, you cannot build a Griffon application with just its runtime libraries placed under ~/.groovy/lib
The base of our enterprise application is OSGI and we have several Java projects that are logically OSGI bundles. We use Maven to compile the application using the Maven Bundle plugin. But this process is time consuming and makes it impossible to debug the application. We also use the Runner and Pax(:provison) plugins to run the application. If we could rely on the Auto build function of Eclipse and also debug the application it would make our lives so much easier. Is there a way to configure Eclipse to be able to compile (and may be run) an OSGI-based application?
I'm not entirely sure if I understand you, but here goes.
Well, running/debugging OSGi applications in Eclipse is really easy, as long as your bundles reside in PDE aware projects or at least are on your target platform.
Do you have the source of all your bundles? Debugging without source isn't all that useful. If you do, can you just import all the source of your bundles into your Eclipse workspace?
Otherwise you can create a target platform, add all your bundles to that. (as a first attempt, I'd say dump all your bundles in a directory and point the target platform there)
Either way, then you should be able to Run (or debug)-> OSGi framework -> New -> Pick your bundles -> Start
You can both pick bundles from or target platform and from your workspace.
For building, you can use Eclipse Plugin Development Environment (PDE). Despite its name, it isn't specific to building Eclipse plugins and can be used for working on pure OSGi bundles. Eclipse plugins are OSGi bundles with some extras.
Cannot help you with the running or debugging part, although I do know that some enterprise-oriented OSGi platforms provide extensions to PDE.
If you're already using the maven bundle plugin, you may find that PDE's manifest-first approach isn't a good fit with your existing code-first build (I assume at the end you want both an IDE build for development and debugging, and a command-line build for continuous integration and automated testing).
You have two choices. As others have suggested, you can use Eclipse's integrated PDE, and use Tycho for your maven build. Tycho uses the same data used by PDE, so you don't have to write things down more than once. Alternatively, you can stick with the maven bundle plugin and use bndtools within Eclipse. Like the bundle plugin, bndtools is code-first, so you won't need to worry about maintaining manifests. However, you may find there isn't quite as big a set of features in bndtools as in PDE, and I'd suggest still checking your manifests by hand to make sure you understand what's being generated. Whether you prefer manifest-first or code-first is a bit of a heated philosophical debate.
Look at bndtools. bndtools is using the same bnd that is underlying the maven bundle plugin. You can even use bndtools together with m2e. bndtools is available from the Eclipse market place.
We are looking at rearchitecting our web application and want to move to a more modular solution, OSGi seems to meet a lot of our needs.
I've come across the Apache Felix project and taken it for a spin. It looks solid yet I find the development cycle a bit slow as it requires a maven build of the bundle(s) to make any code changes effective.
Instead I would like to be able to reload a bundle once classes have been compiled by Eclipse, without any extra building/packaging. Similar to how Tomcat and other servlet containers support deployment of "exploded" war files.
Is this possible to do with Felix or any other OSGi container?
In the Gogo shell, you can do:
install reference:file:/path/to/exploded/directory
This will install an exploded bundle. The format of the exploded directory should be exact that of a bundle JAR file.
Apache Felix FileInstall supports exploded bundles out of the box. Just install it, and put a directory with your bundle in the load directory (or configure FileInstall to look somewhere else).
Not exactly answering your question, but if you have issues with the build cycle, you should take a look at bndtools, which is a plugin for Eclipse that a.o. automatically builds and deploys your bundles in a running framework when your code changes.
I need to run the eclipse FeaturesAndBundlesPublisher application on a linux server. The clumsy way is to download eclipse and put it on the server but since I only need the FeaturesAndBundlesPublisher is there someway of getting that application as a standalone application?
Eclipse itself is a standalone application, though it contains many applications based on different arguments.
If you're unhappy with the big size or base, you can create a .product definition, then export the p2.publisher and its dependencies as a standalone application.