Blog
Bringing OSGi-DS to plain java applications
Fairly everything in e(fx)clipse is done with DS-Services when you run in an OSGi-Environment. Still many of them don't have any dependency on OSGi at all so most components we have can also run/get used in an ordinary Java-Environment (see the blog post about the code editor framework as an example). Since the beginning we published some of them through the ServiceLoader-API (and we'll still keep it for those) but that has the draw back that you can not express relations between services. Tonight I had a crazy idea: Could I read the DS-Component-Registration files in an none-OSGi environment and wire services together without using the ServiceLoader-API. The result is JavaDSServiceProcessor. Our public service lookup API has been retrovited to use this internal service instead of ServiceLoader so if one now eg looks up our AdapterService like this:
import org.eclipse.fx.core.Util;
import org.eclipse.fx.core.adapter.AdapterService;
public class Test {
public static void main(String[] args) {
AdapterService adapterService = Util.getService(AdapterService.class).get();
}
}
will get a fully configured AdapterService. We currently don't support everything from the DS-Spec (eg Properties are not yet support) but I'll fill this gap soon.