Still, at least 9 times out of 10 this isn't *really* what you want to do...
Sam
How about another counter point, a word processor that needs a
document bound per frame, therefore more than one module is
required. Where the application would have one module and it's
respective bindings, and the document or documents created would have
their own modules and bindings associated with it.
Guice
unfortunately has anemic documentation and doesn't offer solutions for
real-life constructs like that.
Dhanji mate you're *always* doing plugs ;-)
>> binding commands will make other features like overriding bindings
trivial to implement
This is probably not yet available - unless you create new Injector?
Injector injector = Guice.createInjector(rewrittenModule);
assertEquals(new Pepsi(), injector.getInstance(Soda.class));
Will this help with unbinding as well?
e.g. I have a huge state machine where services come and go, meaning I
would still like to use Guice to handle my binding, but not for the cost
of class leakage - unless Class --> Provider mapping is weak, meaning
once I remove class's classloader that binding goes away as well?
Cheers,
Ales
btw: are Commands available in Maven2 repo?
I
would still like to use Guice to handle my binding, but not for the cost
of class leakage - unless Class --> Provider mapping is weak, meaning
once I remove class's classloader that binding goes away as well?
Yup, explained a bit better. :-)
> As to leakage, this entirely depends on your architecture. Can you
> describe it some more?
I'm using this in the new JBoss5 kernel.
Imagine having a single Injector at the AS's bootstrap.
And then different apps come and go, and they can register new bindings
making its beans/services available to Guice.
I do control the service lifecycle together with its classloader, but if
I cannot remove the binding, probably leaves me with a leakage?
OK, I guess I could do things differently, creating Injector per
classloader, and use some sort of hierarchy of Injectors (already exists
afaik), the root being the one at bootstrap.
- Ales