Friday, May 24, 2013

Did my plug-in load?

One of the most frequent question I get asked is 'How to check if my plug-in is getting picked up properly?' The easiest way to verify is by using Host OSGi Console.

Note that if you do not see 'osgi>' prompt, just press Enter key once. Now you can issue OSGi commands and verify the status of your plug-in

ss is OSGi command to check the status of a plug-in.
Issue help command to see other commands possible as osgi prompt.

You may find some more info at

So the STARTING status means that the plug-in has been discovered but not loaded yet (lazy loading - no class from this plug-in has been requested yet). Once you invoke a functionality that shall need this plug-in, the status shall change to ACTIVE. This would mean that your plug-in is now been loaded into memory.

This is fine, how did we land to OSGi console and how to use Self Hosting?

Self Hosting is nothing but launching your plug-ins with 'Eclipse Application' launch configuration. This launches a new Eclipse instance (called guest instance) having your chosen plug-ins along with the Target Platform

So can be done now is, self-host your eclipse plug-ins. Invoke the Console view and switch to OSGi console and have a look at the state of your plug-ins. This will tell if the Eclipse was able to locate and load plug-ins.

But you want more.

How would you verify the manifest or plugin.xml for the plug-in that got loaded. Typical stuff to check when an extension is not behaving.

Invoke the Plug-ins view. It will show all the plug-ins with which the Guest Eclipse was launch. That is, target platform plus selected workspace plug-ins. You can find you plug-in in this view and expand it to see all its contents. Since, it not a binary plug-in but coming straight from the workspace, you can view the source code that got built and used for this plug-in.

Interestingly, there is one more friend - Plug-in Registry view. This would tell you the location from where the plug-in was picked. The extensions and extension points detected by Eclipse and the dependency tree.

With these views, you can pin point on what code got loaded, from where and what state it is in now.