问题
Is it possible to add declarative services using some kind of api?
A little background:
I have a server application based on dynamic scripts (they can be added, edited or removed at any time). Those scripts have dependencies to OSGi services and possibly each other. Whenever a script gets edited, the script gets compiled to javascript, and its dependencies are detected.
At that point, I'd like to (re)register it as a declarative service, so it will be activated / deactivated when its dependencies come and go.
- Is this even possible? Or is there something major I'm missing?
- If it isn't possible with an OSGi standard, is there a specific solution for Felix or Equinox?
- Can you do that in the other frameworks, like iPojo or blueprint?
回答1:
There is no API to imperatively add declarative services. You can use the normal OSGi api to register and use services. Perhaps that is what you want?
You may want to checkout the Dependency Manager which may provide an API model giving you the dependency support you want.
来源:https://stackoverflow.com/questions/10702295/programmatically-adding-declarative-services