Hi Richard,
Yeah, I had dynamically created delegates in mind. Basically I'd use
code generation (handcrafted or ASM or CGLib or ...) to create a
delegate class definition (a perfectly legitimate class) and then ask
Guice to provide an instance of this class after which I set the
actual instance to delegate to (returned by the provider). I'd go and
intercept the provider like this
@CreateDynamicDelegate // this will intercept the instance and do the
magic and return the delegate, which only implements IFoo, instead of
FooImpl.
IFoo get(){
return new FooImpl(12);
}
There are some issues with this, do you need annotations, how about
other interfaces the instance implements and obviously you can't cast
to a concrete instance and it only works for interfaces...
There are lots of smart people on this list...surely somebody will
come up with something better.
Cheers,
Alen
On Mar 21, 5:54 pm, Richard Hauswald <[email protected]>
wrote:
> Hi Alen,
> I'm a brave guy so i don't fear intimidating solutions :-) But you are
> right, bindInterceptor would be the way of the hero.
>
> > With the auto delegates I had this craziness in mind:
> > when you want IFoo but are supplied with new FooImpl, you'd create a
> > delegate class definition for IFoo and ask Guice to provide it (Guice
> > will then subclass it with AOP) and then set the FooImpl to the
> > created delegate and return the delegate. Not for the faint hearted.
>
> What do you mean by auto delegates? Dynamicly created or created by
> the IDE? If you mean dynamicly created, I don't have any glue how to
> do this, maybe my brain is trapped at the end of one way dead end
> road...
> Please help me out of this misery,
> Richard
>
> > Cheers,
> > Alen
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---