Getting instance from injector

Hello everyone,

I’m trying to get an instance of an interface that has been bound to a class and I can’t figure out where the injector lives. The interface/class is provided from a plugin. But generally I think that is not relevant as this should be applicable to accessing both plugin and core components.

I found org.graylog2.shared.bindings.GuiceInjectorHolder and tried to use the getInjector() method. However it always throws a "“No injector available. Please call createInjector() first.”, when called in a plugin. I also tend to find it only used in conjection with tests/mocking in the graylog source code. That gives me the impression its meant for tests, which is helpful, but not quite enough. Passing tests, ain’t making a working product.

So where is/are the injector/s all these configuration modules are binding things too?

Thanks for the help

jrunu

Any ideas? I’m in the situation that I can’t use @Inject on the constructor, because I need a service in a class (custom deserializer) that requires a no arg constructor.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.