Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sisu-users] strange behaviour of TypeListener

Hello,

I am having a strange behaviour related to TypeListeners when using Sisu in an OSGi application.

I created a Guice Module and listed it in the META-INF/services/com.google.inject.Module inside a bundle. The module is properly instantiated by Sisu and the listener registered.

The TypeListener is exepected to add an AOP interceptor to selected classes of the same bundle in which the Guice Module is declared and registered.

Now, if I am instantiating one of the types that should be subject to AOP as follows what I obtain is a properly woven class.

((InjectorBindings)MutableBeanLocator.publishers().get(3)).getInjector().getInstance(org.example.AOPCandidate.class)

If I am instead instantiating the class as follows:

MutableBeanLocator.locate(com.google.inject.Key.get(org.example.AOPCandidate.class)).iterator().next().getValue()

the class is not woven anymore.

The first method consists in unboxing from the bean locator the injector that was created for the bundle and using it directly, while the second approach consists in using the BeanLocator directly, which is what I should do.

What am I doing wrong?  Sisu 0.3.3 and Guice 3.0.

Thanks in advance.
--
Gian Maria Romanato
<gm.romanato (at) gmail (dot) com>

Back to the top