How to auto-start/eager start OSGi services on Eclipse platform

前端 未结 5 1626
别跟我提以往
别跟我提以往 2021-01-11 22:44

I develop an Eclipse RCP application which makes heavy use of OSGi bundles which provide services for later use. The use case requires the bundles to register their services

5条回答
  •  渐次进展
    2021-01-11 23:20

    Sigh. You're the victim of a misguided strategy in Eclipse to prevent (dumb) programmers from extending the startup time. Instead of warning, they just decided not to start bundles at all. This is the opposite of what OSGi recommends :-( A bundle could only get activated (they basically voided start) when somebody loaded a class from it (this is what lazy activation is.)

    The by far best solution is to use Declarative Services. You can declare immediate services, which will be activated at startup, and you can declare lazy services, which get activated when used. The lazy are of course preferred (when you're not a dumb programmer) but certain use cases require immediate, like example a server that offers it services over the internet. You have to make sure in your config.ini that DS is started.

提交回复
热议问题