When I started using OSGi the issue, in fact, development and debugging rose by itself. Debugging a standalone application on a platform that was built into Eclipse was irrational, too many bundles and it contains too many dependencies - this is on the one hand. On the other hand, I didn’t want the platform to expand with each update of Eclipse and overgrow with new dependencies. In short, I only needed Jetty, OSGi console, EclipseLink and RAP / RWT from the platform.
I wanted to completely control the composition of the runtime environment and debug the project in it. And for this it was necessary to select the OSGi platform from Eclipse and set it back on it. How to do it - I will tell in this article.
In general, I want to immediately protect myself from recommendations to use Eclipse Virgo or Apache Felix. Or glassfish. Yes, they are big, powerful, cool. And heavy, complex, bulky. One of the features of Equinox is that it really allows you to integrate yourself with minimal effort into the project. I do not need to have a heavy application server on the hosting, where I want to deploy this project - I just copied the archive, deployed, launched the script and now, it already works!
The story will be quite detailed, so something you can skip. ;)
')
Step 1. Download EquinoxYou can take it on the official website:
download.eclipse.org/equinox . We swing, we develop anywhere, under Windows I had it C: / Equinox, under Linux - / home / user / Equnox. It is important that we can write there after deployment, so that follow the rights.
The latest version at the time of writing of article 3.8.2 weighs 28Mb. There are 238 bundles in it, including the source code (about half). We don’t have to include them all, but you shouldn’t remove them from the delivery - it will suddenly come in handy. ;) For example, I haven’t needed the P2 repository yet, but for the implementation of auto-update of the system it will be most welcome (this is 64 bundles).
Now we need to run all this stuff from under Eclipse, and let it manage the composition of the bundles and the platform configuration.
Step 2. Customize EclipseThe implication is that you have an adequate build, either Eclipse for RAP / RCP developers or Eclipse for Java EE developers. Even if it is not, then almost any can be brought to an adequate state by installing the necessary bundles through Eclipse itself. Or just download the assembly and unpack it into another directory.
By the way, I advise you to take Kepler milestone 7 which has recently come out, even though it is a developer build, but it is stable enough to work with it, unlike milestone 6.
To begin, go to Eclipse in the menu "Window" / "Options" (I have it Russified for convenience). And then, as shown in the pictures, we create and load our new configuration. Everything is intuitive and clear to hell, but this is only half the battle.






The second half of the case is to configure the launch configuration directly for your project. What is the most funny - one platform can run in different configurations and this gives some room for maneuver. Each configuration enables or disables some of the system components. It is absolutely not necessary to create several platforms, unless you have several completely different projects with different sets of required bundles.
Step 3. Configuring launch configurationFrom the image below, I think it is quite clear where to poke and what exactly to create: “OSGi Equinox environment”. There is one important point, you need to specify where to store the configuration from the simpleconfigurator, which Eclipse loves so much. I have indicated that it is stored with the medium in its catalog. It's easier then to transfer. If this is not done, the config will be stored in the workspace of Eclipse, and this is very, very inconvenient.


In principle, this is all, but you may still have to check for dependencies so that everything is in place. The base environment should start like this. In the Eclipse console, we will see the osgi> cherished prompt, answer “ss” and get a list of bundles running in the system.
At this stage, any difficulties should arise. But lastly, what I killed 20 hours of life;), how to run this farm from the command line and make it work correctly. You need to run it the same way Eclipse does. And how does he do it?
Here is the magic script that does what Eclipse does, now our platform is really independent and can be deployed on any server where there is Java. Only the way you need to register your own.
Ps. A nice bonus is that HTTPs is immediately turned on in Embedded Jetty. Find how to do it, as it turned out, not easy.