|
From: Chris N. <ch...@si...> - 2003-11-18 17:40:48
|
Colin Sampaleanu wrote:
> I think I may be missing something, but I think it's desireable to be
> able to create in an easy fashion, 'closures' which encapsulate getting
> a bean from a bean factory.
>
> Say you have an interface
> interface MyInteface { ... whatever }
>
> and you have a factory Interface
> interface MyInterfaceFactory {
> MyInterface getInstance();
> }
You may want to look at:
http://cglib.sourceforge.net/apidocs/net/sf/cglib/reflect/MethodDelegate.html
It can create an object that implements an interface but delegates the
implementation to a virtual or static method (with matching signature) of
your choice. Essentially it is a implementation of C# delegates for Java.
Chris
|