Skip to main content

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


On Wed, Feb 8, 2017 at 1:11 AM, Stuart McCulloch <mcculls@xxxxxxxxx> wrote:
The only thing I can think of without seeing an example project is that AOPCandidate is a concrete class which is not bound in any of the injectors.
In such cases (where all explicit bindings have been exhausted) the container will fall back to implicit bindings. And if AOPCandidate is a concrete class then its implicit binding will potentially exist in any of the injectors, in which case it could be creating the instance in an injector that didn’t have the interceptor installed.

That was the case, the classes in question are not annotated @Named, and somehow another injector which was not aware of the type listener was able to instantiate them.


If this is the case then the solution would be to add @Named to AOPCandidate so that it’s indexed and bound by Sisu, or make sure it’s bound in a module belonging to the appropriate injector. You could also enable “binder. requireExplicitBindings” in all the injectors to make sure that implicit bindings are never used.

Binding explicitly the classes in the same module where the type listener is registered resolved the problem. I think your answer would make an excellent entry in a SISU FAQ page.

One last question: I would prefer such classes not to be candidates for injection outside of the current bundle, because they are not API. Would this be a proper use case for the @Hidden annotation (and still make AOP work)?

Thanks a lot.
GianMaria.



Back to the top