ef-labs / vertx-guice

Create Vert.x Modules and Verticles with dependency injection using Guice
MIT License
59 stars 24 forks source link

Use parent and child Injectors instead of creating a new one for each verticle #9

Closed jakub-bochenski closed 8 years ago

jakub-bochenski commented 8 years ago

I think the use case is similar to one described here: https://stackoverflow.com/a/12774246/1237617

This should allow one to have global modules that will only be applied once per Vertx creation and child modules that will be applied per each verticle.

If you think it's a valid improvement I'll be glad to send a PR quite soon as we have a real use case for it

adrianluisgonzalez commented 8 years ago

We had actually been discussing something similar for vertx-hk2 which we use with Jersey.

I have pushed a branch feature/parent-child-injector.

Is this similar to what you had in mind?

The issue is how to initialize the parent injector on the factory since it doesn't run on the vert.x event loop with a Context so the JSON config is not available. I have left it so you can programmatically set the injector. Thoughts?

jakub-bochenski commented 8 years ago

Looks promising, though I need some time to process your last remark about setting the injector.