Osgi Equinox enable component from external bundle

不想你离开。 提交于 2019-12-13 04:33:28

问题


Given this scenario:

Bundle A: component 1A (enabled:false) Bundle B: component 2B

How can i enable component 1A from Bundle B or Component 2B?

I've tried to do it by using componentContext,

dsContext.enableComponent("1A");

but it seems to work only with services in the same bundle.


回答1:


Your using a mechanism that is intended for management and it seems you want to use it on application level. Declarative services should be enabled/disabled through their dependencies, or through a domain specific means. You should not let another actor that enables/disables a component. Using this route you likely get very complex systems since it is difficult to control the timing and order.

Technically, you should use the Apache Felix SCR Service to control the enable/disable of a DS, this is unfortunately not yet standardized and then requires Apache Felix SCR as implementation of DS.

If you explain why you want to enable/disable other components it might be possible to point you to better solutions.



来源:https://stackoverflow.com/questions/18982190/osgi-equinox-enable-component-from-external-bundle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!