Lets say I have two applications sharing the same library. This library contains common classes like DAOs, Utils, etc. Everything in the shared library is wired with Guice. My two apps depend on this library but do not have a direct dependency on Guice.
There is no such way. You either embrace Guice totally or do not use it and pass your dependencies explicitly. Well, structuring your code in such way so you never directly create class dependencies, passing them instead through a constructor, also may be called 'dependency injection', but I'm sure this is not what you meant. If you do not want to use Guice in your apps, you won't be able to get anything better than getInstance(), which is ugly, especially because you're using static wrapper.
There is no such way. You either embrace Guice totally or do not use it and pass your dependencies explicitly. Well, structuring your code in such way so you never directly create class dependencies, passing them instead through a constructor, also may be called 'dependency injection', but I'm sure this is not what you meant. If you do not want to use Guice in your apps, you won't be able to get anything better than getInstance(), which is ugly, especially because you're using static wrapper.
Ideally your library should provide a module which you can install via Guice.createInjector() in your applications, or, in the other way around, the library should provide an Injector instance which you can use in your applications by using createChildInjector() and providing application-specific modules. Slight modification of this approach is passing application-specific modules to the library so they will be used to create Injector. I have recently written Guice-based API over custom servlet-like interface which didn't support any kind of DI at all using the last approach, and it is working perfectly.
Ideally your library should provide a module which you can install via Guice.createInjector() in your applications, or, in the other way around, the library should provide an Injector instance which you can use in your applications by using createChildInjector() and providing application-specific modules. Slight modification of this approach is passing application-specific modules to the library so they will be used to create Injector. I have recently written Guice-based API over custom servlet-like interface which didn't support any kind of DI at all using the last approach, and it is working perfectly.
It is not at all hard to use Guice in servlet or Jersey environment. The latter, for example, has out-of-the-box integration with Guice (at least, in 1.x versions). Guice servlet extension is also very good and convenient. Just try it and see for yourself.
While in a few small cases this it is acceptable for the injector to escape into other creational objects, I don't think this one of them. You have ended up with all the disadvantages of a Service Locator and all the advantages can be had by using the tool you are already using.It is not at all hard to use Guice in servlet or Jersey environment. The latter, for example, has out-of-the-box integration with Guice (at least, in 1.x versions). Guice servlet extension is also very good and convenient. Just try it and see for yourself.
I strongly recommend that you inject all dependencies at construction, if at all possible, even if it requires writing a few more lines of code. I've used Guice for years, and have yet to need partial construction or any other advanced feature.
While in a few small cases this it is acceptable for the injector to escape into other creational objects, I don't think this one of them. You have ended up with all the disadvantages of a Service Locator and all the advantages can be had by using the tool you are already using.
The "usual" pattern of using an injector is to set it up in some top-level entry point of you project (in a servlet scenario, using Guice-Servlet, this would be the GuiceServletContextListener). You may want to configure an individual injector at an entry point to some dependency and make it responsible for wiring that dependency, for the sake of modularization. If you want both, individual bindings and the bindings from the parent project, in your dependencies, than you can create a child injector that delegates to its parent if no binding is found. Guice supports this.
I strongly recommend that you inject all dependencies at construction, if at all possible, even if it requires writing a few more lines of code. I've used Guice for years, and have yet to need partial construction or any other advanced feature.
However, it seem strange to me that you want to set up an injector inside a dependency and use it in your main app(s). This would mean that the dependency knows about all bindings required by the main app(s). I'm not quite sure what you are trying to achieve with this approach. Is it that your two apps have the same/a very similar binding setup and you don't want to repeat it? In this case you should define a module with all that bindings configurations once (maybe in a dependency) and use it when setting up the injector at the entry points of each of your apps. That much in regard to your scenario.
To your question in general. I think its good practice to avoid explicitly passing the injector. Whenever you do this, you work against the idea of dependency injection as being a transparent project and you tie yourself to a concrete injection framework. In most cases you can avoid explicit references to the injector by using Providers and Factories.
However, it seem strange to me that you want to set up an injector inside a dependency and use it in your main app(s). This would mean that the dependency knows about We are a privately owned support forum for the Dodge Ram Cummins Diesels. All information is free to read for everyone. To interact or ask questions you must have a subscription plan to enable all other features beyond reading. Please go over to the Subscription Page and pick out a plan that fits you best. At any time you wish to cancel the subscription please go back over to the Subscription Page and hit the Cancel button and your subscription will be stopped. All subscriptions are auto-renewing.
So if your running a junky edge comp or juice and want just a little more fun, this is what smoke out put you can expect with a 90hp 7x.0085 VCO injector from DAP. Clean burning and sensible injector for a well balanced rig. Pop pressure on this truck is 300bar.
Good setup for daily drivers and tow rigs. You can hit 1300-1350* on wide open runs on all levels so make sure you have a good set of gauges (not glow shi(f)t, there garbage, slow and your gonna melt a piston)... would work well with S03 users also. Levels 1-4 or if you use REVO settings (actual level is irrelevant then).
Problem is Edge Juice, Edge Comp and Edge EZ are built around stock injectors the biggest you can go without huge smoke is a +50HP injector. I Ran Edge Comp for years and tried stock injectors, RV275 and +50HP whih the +50HP injectors where getting rather smokey and there wasn't a setting that would handle that smoke.
Now if you drop the Edge product and switched over to Quadzilla you can set your lead in fuel at BELOW stock fuel levels which will remove that smoke. I'm running +75 HP injectors now and smoke free.
Now thats an idea! I've been tossing around the idea of putting a couple real gauges in the stock radio location and building a nice compact cupholder with a spot for a double din radio down where the stock cupholder folds down. I'll have to check into that for sure.
That's the beauty of Quadzilla you are not limited to the screen size. It can be as big or small as you want to have. Edge Juice and Smarty Touch are both limited to there own screen design that's it.
Personally, I love the idea of going headless... This way there is no tuner display. Then most people think the truck is totally stock. I've got the a-pillar gauges but that all. Small tires and no tuner on the dash. Thieves just would rather pass my truck up. Not worth it. Under the plain wrapper is a beast but no one will ever know it.
Thats a good point especially in bad areas Im always paranoid someone is gonna pick me to mess with. I could still use my edge mount for my phone mount the way i've got it so when im driving the truck i could use that as my gauges as well and when im not driving it i just have a phone mount. guess its time to start saving up
Like right now I'm down here in Ontario, OR and crime isn't horrid but it's here. I'm less worried. Now with my old Edge Comp that bothered me. I hid it under the steering column to make it go away. Hard to adjust that way.
My paranoia probably stems from the fact my edge is mounted to my a pillar. I modified a magnetic phone mount to hold it there and stuck the magnet to the edge display and ran the cables up through my dash. It's an awesome spot for it but puts it in plain sight and when going to Phoenix I get pretty paranoid about someone seeing it.
Quadzilla is now gone... If I really want to secure the truck just set the Quadzilla to level 1 which is set for 15% fuel and it barely rolls at 25 MPH at WOT. Go ahead steal my truck you are not going to get away fast that's for sure. Not knowing the Quadzilla is there how would they know its choked to 15% fuel too. Thief is not going to mess around opening the hood to figure it out they will just ditch the truck.
@Mopar1973Man that is a nice simple setup. Im sold on the quadzilla now that i've looked into it and am kinda gaining an understanding of how this all works. Now i just need to find the cash. I could sell the edge to cover some but its still got a decent price tag. And i gotta convince the boss.. i mean wife
Simple sell the Edge Juice for $500 which is 50% of the new price tag and would be a fair price. Now the Quadzilla is $674. You shouldn't have much trouble affording the Quadzilla. Yank that Edge juice out and put an ad in the classified area here and get it sold!
I got this Edge secondhand from a coworker for $300. Technically third-hand because it was in his truck when he bought it. I didnt have the map adapter so i made one. Prowireusa on ebay sells weatherpack connectors for cheap he's got a website too but shipping is pricey unless you order several things. I'll be yanking it out one of these days here.
Im sure i wont regret the quad. Even though it will be more money for me to go that route simply because i bought the edge used i know i'll be happier and for the functionality you get out of it you really cant beat it. I dont know of any other tuners that will allow you to tune it how you want it unless you go standalone and im not doing that on the truck, i'll leave the standalone for the buggy project.
3a8082e126