Hi, folks. Thanks for your comments!

Dhanji R. Prasanna wrote:
> If you like you can try the experimental lifecycle module which takes 
> an executor and calls a bunch of services in parallel.

Tim Peierls wrote:
> [...] I
> don't see how you would deal with interdependencies between
> Startables, and it seemed like that was the main issue you were hoping
> Guice could quasi-magically address: Service A needs both Service B
> and Service C started before it can itself start.
>   

Yes, that's the manual work I was hoping to avoid. Once you get past 
some number of services, even though all the dependencies make sense 
individually, it's a lot of head-scratching to put it all together properly.

 From what you and Dhanji say, it looks my use case is either out of 
scope or bleeding edge for Guice, so I'll pass for now. However, I still 
may try using Guice after parallelizing the high-cost services internally.


> What you'd like to be able to say is something like this:
>
> class ServiceA implements Service {
>     private final ServiceB b;
>     private final ServiceC c;
>     @Inject ServiceA(ServiceB b, ServiceC c) { this.b = b; this.c =
> c; }
>     public void start() throws InterruptedException {
>         waitForStart(b, c); // where waitForStart is a blocking
> utility method provided the lifecycle machinery
>         expensiveInitialization(b, c);
>     }
>     ...
> }
>
> Maybe something like this is already there and I just missed it?
>   

That would be nice. Actually, in my case, the services currently do all 
their initialization at construction time, so I don't even need the 
ability to wait, but I could see that others would.

> During JSR 330 discussions, when I was nattering on about documenting
> concurrency properties of injection, Bob Lee led me to believe that a
> parallel injector would be really, really hard to do. So I don't think
> we'll ever be able to do something like this:
>
> class ServiceA implements Service {
>     @Inject ServiceA(Provider<ServiceB> bp, Provider<ServiceC> c) {
>         expensiveInitialization(bp.get(), cp.get());
>     }
>     ...
> }
>
> and have the ServiceB and ServiceC constructions happen in parallel.
>   

Hmmm... That's unfortunate, as that would be the ideal scenario for me. 
If all of my dependent services are going to have duplicate code where 
they wait for their dependencies to heat up, I'd love to pull that 
duplication out somewhere, and the dependency injection framework seems 
like the ideal place for that.

William

--

You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.


Reply via email to