Allow creating your own injector
marshallpierce opened this issue · comments
I want to be able to create my own injector, not hand creating the injector off to jersey2-guice. I got it working by marking a few things public (https://github.com/marshallpierce/jersey2-guice/compare/external-injector) and duplicating a couple of lines of logic from BootstrapUtils#newInjector.
I'm guessing that you don't really want to just mark stuff public and that you'd like to expose a better way of doing this, so I didn't file my changes as PR. If you have any suggestions for how you'd like to structure things to allow making your own injector instead of having jersey2-guice do it, I'd be happy to do the work to make it happen. (Or just submit my code as a PR if you're cool with making things public.) Thanks!
How is it different (as in added value) from (see below)?
ServiceLocator locator = BootstrapUtils.newServiceLocator();
Injector injector = BootstrapUtils.newInjector(locator, Arrays.asList(module));
BootstrapUtils.install(locator);
I don't want to relinquish control of creating my injector how I want to, much like I wouldn't want to let a library insert itself into my inheritance hierarchy.
What if another library wanted to handle creating its own injector also? Then I couldn't use it with jersey2-guice.
Done 0bd41e6
Looks correct.
Great, thanks for checking! :)