Oli
unread,Mar 17, 2008, 8:43:08 PM3/17/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-guice
Hello guicer!
I don't know if there is some interest in this topic... just for the
case.
In my project I meet this problem very often: I have several
algorithms working on certain data sets; sometimes many instances of
the same algorithm on different views on the same data set, and so
on... classical robot-leg scenarios.
I have worked out some solutions I'd like to share, discuss, and maybe
evolve together - if desired.
In certain small cases it's of course possible to subclass and use
different annotations. Not very satisfying - as I think.
For those simple cases I worked out an AssistedProvider which works
pretty much like the AssistedFactory mechansim (see FactoryProvider)
but does not need to have a factory. Instead it takes instances or
keys during configuration for the robot-leg-parts. The rest is
injected as usual.
For more complex cases I use Injector chaining. I.e., create an
Injector for the robot-leg, fill in necessary Providers from the outer
injector, and as return fill some Providers into the outer injector.
(quite straight-forward...).
This does not only solve the robotleg for me, but also prevents bind-
collisions and unforeseen behavior due to scope 'collisions'. Example:
some modules working fine using an unscoped Jit-bound instance; after
mixing with other modules that make an explicit, Singleton scoped
binding, these modules might behave 'strange'. Such errors are not
easy to track...
I'd like to attach some sources here... but can't see how to do this.
Bye,
Oli