Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sisu-users] Problem with the Sisu Extender


Hello,

I'm trying to use the sisu extender in an OSGi application, but I it does not seem to work as expected. I am using M5.

Here is my configuration. I have two bundles, B1 and B2, where B2 depends on B1. The Sisu extender is started before B1 and B2.

B1 bootstraps the Injector with a custom module "someModule" as follows:
injector = Guice.createInjector(new WireModule(someModule, new SpaceModule(new BundleClassSpace(FrameworkUtil.getBundle(getClass())))));
B2 declares an additional module via META-INF/services/com.google.inject.Module

In debug I see that SisuActivator is starting and that is starts tracking bundles and services.
I also stepped into the code that instantiates the module declared by B2, creates a new Injector out of it and registers the Injector in the DefaultBeanLocator.
The OSGi console also shows that the SisuActivator has registered a BundleInjector service on behalf of B2.

Now, if I write code in B2 that uses the same injector instance that was created by B1, I can succesfully instantiate objects and have their fields injected with classes that are bound by "someModule".
But if I try to do the same with objects that would require injections that are bound by the module declared in B2, Guice complaints that no implementation could be found.

What am I missing? I believe I should tell the Injector to use the bean locator created by SisuActivator. How can I do that?

GianMaria.


 


Back to the top