Twitter github

Extension Registry is just another OSGi Service

After working with a colleague today regarding a problem with the extension registry, I saw a lack of domain knowledge on my colleague’s part. He thought the extension registry was some mythical beast that can be summoned via an incantation of Platform.getExtensionRegistry()… that thought is wrong. The Extension Registry is just another OSGi service (read about it in Neil Bartlett’s fantastic article). What this means is that you can simply interact with it like any other OSGi service…

// some simple snippets...
ServiceTracker tracker = new ServiceTracker(context,IExtensionRegistry.class.getName(), null);;
IExtensionRegistry registry =(IExtensionRegistry) tracker.getService();

There, no more Platform.getExtensionRegistry()… now it’s back to working off the 2 pounds gained being on the EclipseCon diet.