What I am trying to achieve
Using netbeans modular system to prepare the application for us, as we implement the modules in OSGi using declarative-services via apache felix. Here is the module setup:
Module C installs modules through the following code:
BundleContext context = FrameworkUtil.getBundle(class).getBundleContext();
Bundle tcp = context.installBundle("file:Location");
tcp.start();
Where everything installs and starts without error. However the declared references are not being bound to the services.
For more specific on how everything holds together I added the code to github https://github.com/jonaslagoni/server. Remember to change the lines in file: module C, dk.sdu.ace.dp.Controller, line 27-28 to the location of module B and A.
What I have tried so far
Extra questions
Should the declarative-services automatically bind the providers with the references when installed and started through the bundlecontext?
Is this way of structuring the application even viable, or should we pursue another way? if so which?
Your DS references are using an optional cardinality while not using greedy
policy option. (reluctant
policy option is the default for historical backwards compatibility reasons.)
With reluctant
, the reference will not be rebound when additional/better services are later registered such as the bundle providing the service starting after the bundle consuming the service. With greedy
, the reference will be rebound.