Review of Jetbrains Intellij Idea 9 Ultimate Edition

6. OSGI support

From this version, Idea natively integrate an OSGi plugin, Osmorc. This plugin try to make easier the development of OSGi applications in Idea. I’ll try to show you the main functionalities who are now integrated in Idea.

The first thing to do is to configure the project for OSGi. To do that, we just need to activate the OSGi facet for the necessary modules. Then (or before, as you want), we must configure the installed OSGi instances.

Configuration of installed OSGi instances

Configuration of installed OSGi instances

Then, we must configure the instance to use for the project :

Configure the OSGI instance to use for the project

Configure the OSGI instance to use for the project

We can then go to the creation of a simple OSGi project.

The first functionality to note is of course the code completion of the MANIFEST.MF entries :

OSGi Headers code completion

OSGi Headers code completion

When you add the Import-Package header, we can use the classes of this package from the project without doing anything else.
But we can also define a Manifest file from Idea :

Manifest configuration

Manifest configuration

Et we continue with an activator :

package com.pragprog.hello;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class HelloWorld implements BundleActivator{
    @Override
    public void start(BundleContext bundleContext) throws Exception {
        System.out.println("I'm in OSGi :) ");
    }

    @Override
    public void stop(BundleContext bundleContext) throws Exception {
        System.out.println("I'm leaving OSGi :( ");
    }
}

To finish, we create a new run configuration “OSGi bundles”. For That, we just need to add the bundle to the list and in the “Parameters” tab to choose the good OSGi instance to run :

OSGi run configuration

OSGi run configuration

And we launch the configuration, that give us :

OSGi application

OSGi application

But we cannot interact with the OSGi instance from Idea, that’s not very practical. We cannot stop modules or either manage them from the console. But the OSGi development is still facilitated by Idea. But it would have been better to have something a bit more advanced.

 

  • http://www.aryol.com.tr prefabrik

    thanks for the review. It’s so informative about Intellij Idea.