(x-posted to guice mailing list)
I'm trialling Guice on a new library that will live in an existing application. All our apps right now are spring apps and we have some common code that is tied to spring, mainly to do with the thread model we tend to use. It basically gives us (what could be seen as) a logical thread.
So we can throw jobs at it and it ensures that jobs with a given key always end up on the same pipe in the order that they were submitted. Typically this is a single thread for the life of the application but if bad things happen then the worker thread (that backs the pipe) is thrown away, the pipe deactivated, a new worker created and the pipe reactivated on that worker. All the wiring here is provided by spring.
My new lib needs to use this for the thread model & I plan on using guice for the logic & domain side of things, i.e. constructing the work that goes on the pipeline & and the logic that it represents. This seems quite straightforward to me except for one thing that seems quite gnarly, namely that I want to inject certain things with "pipe" (aka logical thread) scope. I've read the custom scopes (and SimpleScope implementation) wiki page but some things are not clear to me and clarification would be much appreciated...
- pipes survive for the life of the JVM therefore it seems that I need to enter a scope but never exit, any downsides to this?
- what options do I have for triggering scope entry in a spring managed bean? is it just a case of creating the spring context and then using the SpringIntegration to suck in the spring beans into a guice context?
- does this sound really flaky and I should just wrap it with a singleton keyed by my pipe id instead?
Cheers Matt