|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
InvokeMethod and @Delegate TogetherI have a mixed Java and Groovy application. In it I have a Java interface called IFoo. There is also an implementation of this interface. I want to wrap this implementation in a Groovy class and delegate to the foo instance. The groovy class will intercept the calls and make a few modifications before calling the implementation. To do this, I want to use invokeMethod().
The problem is that @Delegate does not seem to play well with invokeMethod(). When I use the @Delegate transaformation, the method calls going to the delegated methods do not go through invokeMethod().
Here is a sample application that shows this scenario. interface IFoo { public String someMethod(String arg1); } class Foo implements IFoo {
public String someMethod(String arg1) { arg1+arg1 } } class Bar1 { Foo foo = new Foo() def invokeMethod(String name, args) {
println "Invoke" return foo.invokeMethod(name, args) } } class Bar2 implements IFoo { @Delegate Foo foo = new Foo()
def invokeMethod(String name, args) { println "Invoke" return foo.invokeMethod(name, args) } } println new Bar1().someMethod("abc")
println new Bar2().someMethod("abc") The output from Bar1 produces (as expected): Invoke abcabc The output from Bar2 produces:
abcabc The reason I want to use @Delegate here is so that I can implement the IFoo interface. This allows my Java code that is calling this to be able to call it as if it is any other IFoo Java class.
Is there some reason why @Delegate cannot be used with invokeMethod or is this a bug? Thanks Chris Dail
|
|
|
Re: InvokeMethod and @Delegate TogetherinvokeMethod() is called by groovy only when a matching method is not found.
When you use @Delegate, the methods of the Delegate type get added to your class itself at compile time, which means the compiled Bar2 class has the method someMethod(String) in it, so the invokeMethod() is not invoked for it. Same as below: ----------------------------------------------------- class Test { def foo() {println "foo() called"} // when this is removed, invokeMethod() is called, otherwise not. def invokeMethod(String name, args) { println "invokeMethod() called" } } new Test().foo() ----------------------------------------------------- --Roshan On Tue, Nov 3, 2009 at 2:10 AM, Chris Dail <chrisdail@...> wrote: I have a mixed Java and Groovy application. In it I have a Java interface called IFoo. There is also an implementation of this interface. I want to wrap this implementation in a Groovy class and delegate to the foo instance. The groovy class will intercept the calls and make a few modifications before calling the implementation. To do this, I want to use invokeMethod(). |
|
|
Re: InvokeMethod and @Delegate TogetherIf you implement GroovyInterceptable, you'll get everything in invokeMethod.
~~ Robert Fischer, Smokejumper IT Consulting. Enfranchised Mind Blog http://EnfranchisedMind.com/blog Grails Expert Retainer Services http://smokejumperit.com/grails-retainer/ Roshan Dawrani wrote: > invokeMethod() is called by groovy only when a matching method is not found. > > When you use @Delegate, the methods of the Delegate type get added to > your class itself at compile time, which means the compiled Bar2 class > has the method someMethod(String) in it, so the invokeMethod() is not > invoked for it. > > Same as below: > ----------------------------------------------------- > class Test { > def foo() {println "foo() called"} // when this is removed, > invokeMethod() is called, otherwise not. > > def invokeMethod(String name, args) { > println "invokeMethod() called" > } > } > > new Test().foo() > ----------------------------------------------------- > > --Roshan > > > > On Tue, Nov 3, 2009 at 2:10 AM, Chris Dail <chrisdail@... > <mailto:chrisdail@...>> wrote: > > I have a mixed Java and Groovy application. In it I have a Java > interface called IFoo. There is also an implementation of this > interface. I want to wrap this implementation in a Groovy class and > delegate to the foo instance. The groovy class will intercept the > calls and make a few modifications before calling the > implementation. To do this, I want to use invokeMethod(). > > The problem is that @Delegate does not seem to play well with > invokeMethod(). When I use the @Delegate transaformation, the method > calls going to the delegated methods do not go through invokeMethod(). > > Here is a sample application that shows this scenario. > > interface IFoo { > public String someMethod(String arg1); > } > > class Foo implements IFoo { > public String someMethod(String arg1) { > arg1+arg1 > } > } > > class Bar1 { > Foo foo = new Foo() > > def invokeMethod(String name, args) { > println "Invoke" > return foo.invokeMethod(name, args) > } > } > > class Bar2 implements IFoo { > @Delegate Foo foo = new Foo() > > def invokeMethod(String name, args) { > println "Invoke" > return foo.invokeMethod(name, args) > } > } > > println new Bar1().someMethod("abc") > println new Bar2().someMethod("abc") > > The output from Bar1 produces (as expected): > Invoke > abcabc > > The output from Bar2 produces: > abcabc > > The reason I want to use @Delegate here is so that I can implement > the IFoo interface. This allows my Java code that is calling this to > be able to call it as if it is any other IFoo Java class. > > Is there some reason why @Delegate cannot be used with invokeMethod > or is this a bug? > > Thanks > > Chris Dail > http://chrisdail.com/ > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: InvokeMethod and @Delegate TogetherSure? Code below fails with java.lang.StackOverflowError.
==================================== class Test implements GroovyInterceptable { def invokeMethod(String name, args) { println "invoke - $name" } } new Test().foo() ==================================== -- Roshan On Tue, Nov 3, 2009 at 8:56 AM, Robert Fischer <robert.fischer@...> wrote: If you implement GroovyInterceptable, you'll get everything in invokeMethod. |
|
|
Re: InvokeMethod and @Delegate TogetherRoshan,
GroovyInterceptable should to my best knowledge do the job Robert describes. In your code, however, you.re intercepting calls to println, too. That should explain the StackOverflowError. Try: class Printer { static def report(s) { println s } } class Test implements GroovyInterceptable { def invokeMethod(String name, args) { Printer.report "invoke - $name" } } new Test().foo() That works fine for me. Regards, Vaclav Roshan Dawrani wrote: > Sure? Code below fails with java.lang.StackOverflowError. > > ==================================== > class Test implements GroovyInterceptable { > def invokeMethod(String name, args) { > println "invoke - $name" > } > } > new Test().foo() > ==================================== > > -- Roshan > > On Tue, Nov 3, 2009 at 8:56 AM, Robert Fischer > <robert.fischer@... > <mailto:robert.fischer@...>> wrote: > > If you implement GroovyInterceptable, you'll get everything in > invokeMethod. > > ~~ Robert Fischer, Smokejumper IT Consulting. > Enfranchised Mind Blog http://EnfranchisedMind.com/blog > > Grails Expert Retainer Services > http://smokejumperit.com/grails-retainer/ > > > Roshan Dawrani wrote: > > invokeMethod() is called by groovy only when a matching method > is not found. > > When you use @Delegate, the methods of the Delegate type get > added to your class itself at compile time, which means the > compiled Bar2 class has the method someMethod(String) in it, > so the invokeMethod() is not invoked for it. > > Same as below: > ----------------------------------------------------- > class Test { > def foo() {println "foo() called"} // when this is > removed, invokeMethod() is called, otherwise not. > > def invokeMethod(String name, args) { > println "invokeMethod() called" > } > } > > new Test().foo() > ----------------------------------------------------- > > --Roshan > > > > On Tue, Nov 3, 2009 at 2:10 AM, Chris Dail > <chrisdail@... <mailto:chrisdail@...> > <mailto:chrisdail@... <mailto:chrisdail@...>>> wrote: > > I have a mixed Java and Groovy application. In it I have a Java > interface called IFoo. There is also an implementation of this > interface. I want to wrap this implementation in a Groovy > class and > delegate to the foo instance. The groovy class will > intercept the > calls and make a few modifications before calling the > implementation. To do this, I want to use invokeMethod(). > > The problem is that @Delegate does not seem to play well with > invokeMethod(). When I use the @Delegate transaformation, > the method > calls going to the delegated methods do not go through > invokeMethod(). > > Here is a sample application that shows this scenario. > > interface IFoo { > public String someMethod(String arg1); > } > > class Foo implements IFoo { > public String someMethod(String arg1) { > arg1+arg1 > } > } > > class Bar1 { > Foo foo = new Foo() > def invokeMethod(String name, args) { > println "Invoke" > return foo.invokeMethod(name, args) > } > } > > class Bar2 implements IFoo { > @Delegate Foo foo = new Foo() > def invokeMethod(String name, args) { > println "Invoke" > return foo.invokeMethod(name, args) > } > } > > println new Bar1().someMethod("abc") > println new Bar2().someMethod("abc") > > The output from Bar1 produces (as expected): > Invoke > abcabc > > The output from Bar2 produces: > abcabc > > The reason I want to use @Delegate here is so that I can > implement > the IFoo interface. This allows my Java code that is > calling this to > be able to call it as if it is any other IFoo Java class. > > Is there some reason why @Delegate cannot be used with > invokeMethod > or is this a bug? > > Thanks > > Chris Dail > http://chrisdail.com/ > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: InvokeMethod and @Delegate TogetherYes, that variation works for me too, but I had no intention to intercept the println method call in my code as that method has nothing to do with my Test class.
In fact none of the GDK methods seem to work with GroovyInterceptable - all variations below fail. There may be internal reasons for the behavior, but not a very useful technique (GroovyInterceptable) without the ability to use any Object (GDK/JDK) methods in a groovy class, is it? --------------------------------------------------------------- class Test implements GroovyInterceptable { def invokeMethod(String name, args) { println name // fails dump() // fails getClass() // fails toString() // fails } } new Test().foo() --------------------------------------------------------------- Thanks. Roshan On Tue, Nov 3, 2009 at 1:02 PM, Vaclav Pech <vaclav.pech@...> wrote: Roshan, |
|
|
Re: InvokeMethod and @Delegate TogetherThat's indeed one of the drawbacks for GroovyInterceptable :-(
GroovyInterceptable is then more interesting when implementing a class in Java and adding that interface to it, as the "static" calls to methods are hard-wired and can't be intercepted by Groovy. This marker interface is something we would like to get rid off soon. On Tue, Nov 3, 2009 at 09:29, Roshan Dawrani <roshandawrani@...> wrote: > Yes, that variation works for me too, but I had no intention to intercept > the println method call in my code as that method has nothing to do with my > Test class. > > In fact none of the GDK methods seem to work with GroovyInterceptable - all > variations below fail. > > There may be internal reasons for the behavior, but not a very useful > technique (GroovyInterceptable) without the ability to use any Object > (GDK/JDK) methods in a groovy class, is it? > > --------------------------------------------------------------- > class Test > implements GroovyInterceptable > { > def invokeMethod(String name, args) { > println name // fails > dump() // fails > getClass() // fails > toString() // fails > } > } > new Test().foo() > --------------------------------------------------------------- > > Thanks. > Roshan > > On Tue, Nov 3, 2009 at 1:02 PM, Vaclav Pech <vaclav.pech@...> wrote: >> >> Roshan, >> >> GroovyInterceptable should to my best knowledge do the job Robert >> describes. In your code, however, you.re intercepting calls to println, too. >> That should explain the StackOverflowError. >> Try: >> >> class Printer { >> static def report(s) { >> println s >> } >> } >> >> class Test implements GroovyInterceptable { >> def invokeMethod(String name, args) { >> Printer.report "invoke - $name" >> } >> } >> new Test().foo() >> >> That works fine for me. >> >> Regards, >> >> Vaclav >> >> >> Roshan Dawrani wrote: >>> >>> Sure? Code below fails with java.lang.StackOverflowError. >>> >>> ==================================== >>> class Test implements GroovyInterceptable { >>> def invokeMethod(String name, args) { >>> println "invoke - $name" >>> } >>> } >>> new Test().foo() >>> ==================================== >>> >>> -- Roshan >>> >>> On Tue, Nov 3, 2009 at 8:56 AM, Robert Fischer >>> <robert.fischer@... <mailto:robert.fischer@...>> >>> wrote: >>> >>> If you implement GroovyInterceptable, you'll get everything in >>> invokeMethod. >>> >>> ~~ Robert Fischer, Smokejumper IT Consulting. >>> Enfranchised Mind Blog http://EnfranchisedMind.com/blog >>> >>> Grails Expert Retainer Services >>> http://smokejumperit.com/grails-retainer/ >>> >>> >>> Roshan Dawrani wrote: >>> >>> invokeMethod() is called by groovy only when a matching method >>> is not found. >>> >>> When you use @Delegate, the methods of the Delegate type get >>> added to your class itself at compile time, which means the >>> compiled Bar2 class has the method someMethod(String) in it, >>> so the invokeMethod() is not invoked for it. >>> >>> Same as below: >>> ----------------------------------------------------- >>> class Test { >>> def foo() {println "foo() called"} // when this is >>> removed, invokeMethod() is called, otherwise not. >>> >>> def invokeMethod(String name, args) { >>> println "invokeMethod() called" >>> } >>> } >>> >>> new Test().foo() >>> ----------------------------------------------------- >>> >>> --Roshan >>> >>> >>> >>> On Tue, Nov 3, 2009 at 2:10 AM, Chris Dail >>> <chrisdail@... <mailto:chrisdail@...> >>> <mailto:chrisdail@... <mailto:chrisdail@...>>> wrote: >>> >>> I have a mixed Java and Groovy application. In it I have a Java >>> interface called IFoo. There is also an implementation of this >>> interface. I want to wrap this implementation in a Groovy >>> class and >>> delegate to the foo instance. The groovy class will >>> intercept the >>> calls and make a few modifications before calling the >>> implementation. To do this, I want to use invokeMethod(). >>> >>> The problem is that @Delegate does not seem to play well with >>> invokeMethod(). When I use the @Delegate transaformation, >>> the method >>> calls going to the delegated methods do not go through >>> invokeMethod(). >>> >>> Here is a sample application that shows this scenario. >>> >>> interface IFoo { >>> public String someMethod(String arg1); >>> } >>> >>> class Foo implements IFoo { >>> public String someMethod(String arg1) { >>> arg1+arg1 >>> } >>> } >>> >>> class Bar1 { >>> Foo foo = new Foo() >>> def invokeMethod(String name, args) { >>> println "Invoke" >>> return foo.invokeMethod(name, args) >>> } >>> } >>> >>> class Bar2 implements IFoo { >>> @Delegate Foo foo = new Foo() >>> def invokeMethod(String name, args) { >>> println "Invoke" >>> return foo.invokeMethod(name, args) >>> } >>> } >>> >>> println new Bar1().someMethod("abc") >>> println new Bar2().someMethod("abc") >>> >>> The output from Bar1 produces (as expected): >>> Invoke >>> abcabc >>> >>> The output from Bar2 produces: >>> abcabc >>> >>> The reason I want to use @Delegate here is so that I can >>> implement >>> the IFoo interface. This allows my Java code that is >>> calling this to >>> be able to call it as if it is any other IFoo Java class. >>> >>> Is there some reason why @Delegate cannot be used with >>> invokeMethod >>> or is this a bug? >>> >>> Thanks >>> >>> Chris Dail >>> http://chrisdail.com/ >>> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe from this list, please visit: >>> >>> http://xircles.codehaus.org/manage_email >>> >>> >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > > -- Guillaume Laforge Groovy Project Manager Head of Groovy Development at SpringSource http://www.springsource.com/g2one --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: InvokeMethod and @Delegate TogetherThanks for concurring, Guillaume.
So the original question, kind-of, still remains - is there any working technique you suggest for intercepting the calls when using @Delegate? JDK Proxy mechanism, is it? rgds, Roshan On Tue, Nov 3, 2009 at 2:35 PM, Guillaume Laforge <glaforge@...> wrote: That's indeed one of the drawbacks for GroovyInterceptable :-( |
|
|
Re: InvokeMethod and @Delegate TogetherTrue, the original question!
Hmm... yeah, I don't really see a good solution here. You could still do something like that? class Foo { def m() { println "Foo#m()" } } class Bar { @Delegate Foo foo = new Foo() } def bar = new Bar() Foo.metaClass.invokeMethod = { String name, args -> println "MC#m()" } bar.m() Or probably better a custom metaclass for that specific instance, as I guess you may not want to intercept all the methods on all instances of Foo but just for the one we're delegating too? On Tue, Nov 3, 2009 at 10:10, Roshan Dawrani <roshandawrani@...> wrote: > Thanks for concurring, Guillaume. > > So the original question, kind-of, still remains - is there any working > technique you suggest for intercepting the calls when using @Delegate? > > JDK Proxy mechanism, is it? > > rgds, > Roshan > > On Tue, Nov 3, 2009 at 2:35 PM, Guillaume Laforge <glaforge@...> > wrote: >> >> That's indeed one of the drawbacks for GroovyInterceptable :-( >> GroovyInterceptable is then more interesting when implementing a class >> in Java and adding that interface to it, as the "static" calls to >> methods are hard-wired and can't be intercepted by Groovy. >> This marker interface is something we would like to get rid off soon. >> >> On Tue, Nov 3, 2009 at 09:29, Roshan Dawrani <roshandawrani@...> >> wrote: >> > Yes, that variation works for me too, but I had no intention to >> > intercept >> > the println method call in my code as that method has nothing to do with >> > my >> > Test class. >> > >> > In fact none of the GDK methods seem to work with GroovyInterceptable - >> > all >> > variations below fail. >> > >> > There may be internal reasons for the behavior, but not a very useful >> > technique (GroovyInterceptable) without the ability to use any Object >> > (GDK/JDK) methods in a groovy class, is it? >> > >> > --------------------------------------------------------------- >> > class Test >> > implements GroovyInterceptable >> > { >> > def invokeMethod(String name, args) { >> > println name // fails >> > dump() // fails >> > getClass() // fails >> > toString() // fails >> > } >> > } >> > new Test().foo() >> > --------------------------------------------------------------- >> > >> > Thanks. >> > Roshan >> > >> > On Tue, Nov 3, 2009 at 1:02 PM, Vaclav Pech <vaclav.pech@...> >> > wrote: >> >> >> >> Roshan, >> >> >> >> GroovyInterceptable should to my best knowledge do the job Robert >> >> describes. In your code, however, you.re intercepting calls to println, >> >> too. >> >> That should explain the StackOverflowError. >> >> Try: >> >> >> >> class Printer { >> >> static def report(s) { >> >> println s >> >> } >> >> } >> >> >> >> class Test implements GroovyInterceptable { >> >> def invokeMethod(String name, args) { >> >> Printer.report "invoke - $name" >> >> } >> >> } >> >> new Test().foo() >> >> >> >> That works fine for me. >> >> >> >> Regards, >> >> >> >> Vaclav >> >> >> >> >> >> Roshan Dawrani wrote: >> >>> >> >>> Sure? Code below fails with java.lang.StackOverflowError. >> >>> >> >>> ==================================== >> >>> class Test implements GroovyInterceptable { >> >>> def invokeMethod(String name, args) { >> >>> println "invoke - $name" >> >>> } >> >>> } >> >>> new Test().foo() >> >>> ==================================== >> >>> >> >>> -- Roshan >> >>> >> >>> On Tue, Nov 3, 2009 at 8:56 AM, Robert Fischer >> >>> <robert.fischer@... >> >>> <mailto:robert.fischer@...>> >> >>> wrote: >> >>> >> >>> If you implement GroovyInterceptable, you'll get everything in >> >>> invokeMethod. >> >>> >> >>> ~~ Robert Fischer, Smokejumper IT Consulting. >> >>> Enfranchised Mind Blog http://EnfranchisedMind.com/blog >> >>> >> >>> Grails Expert Retainer Services >> >>> http://smokejumperit.com/grails-retainer/ >> >>> >> >>> >> >>> Roshan Dawrani wrote: >> >>> >> >>> invokeMethod() is called by groovy only when a matching method >> >>> is not found. >> >>> >> >>> When you use @Delegate, the methods of the Delegate type get >> >>> added to your class itself at compile time, which means the >> >>> compiled Bar2 class has the method someMethod(String) in it, >> >>> so the invokeMethod() is not invoked for it. >> >>> >> >>> Same as below: >> >>> ----------------------------------------------------- >> >>> class Test { >> >>> def foo() {println "foo() called"} // when this is >> >>> removed, invokeMethod() is called, otherwise not. >> >>> >> >>> def invokeMethod(String name, args) { >> >>> println "invokeMethod() called" >> >>> } >> >>> } >> >>> >> >>> new Test().foo() >> >>> ----------------------------------------------------- >> >>> >> >>> --Roshan >> >>> >> >>> >> >>> >> >>> On Tue, Nov 3, 2009 at 2:10 AM, Chris Dail >> >>> <chrisdail@... <mailto:chrisdail@...> >> >>> <mailto:chrisdail@... <mailto:chrisdail@...>>> >> >>> wrote: >> >>> >> >>> I have a mixed Java and Groovy application. In it I have a >> >>> Java >> >>> interface called IFoo. There is also an implementation of >> >>> this >> >>> interface. I want to wrap this implementation in a Groovy >> >>> class and >> >>> delegate to the foo instance. The groovy class will >> >>> intercept the >> >>> calls and make a few modifications before calling the >> >>> implementation. To do this, I want to use invokeMethod(). >> >>> >> >>> The problem is that @Delegate does not seem to play well >> >>> with >> >>> invokeMethod(). When I use the @Delegate transaformation, >> >>> the method >> >>> calls going to the delegated methods do not go through >> >>> invokeMethod(). >> >>> >> >>> Here is a sample application that shows this scenario. >> >>> >> >>> interface IFoo { >> >>> public String someMethod(String arg1); >> >>> } >> >>> >> >>> class Foo implements IFoo { >> >>> public String someMethod(String arg1) { >> >>> arg1+arg1 >> >>> } >> >>> } >> >>> >> >>> class Bar1 { >> >>> Foo foo = new Foo() >> >>> def invokeMethod(String name, args) { >> >>> println "Invoke" >> >>> return foo.invokeMethod(name, args) >> >>> } >> >>> } >> >>> >> >>> class Bar2 implements IFoo { >> >>> @Delegate Foo foo = new Foo() >> >>> def invokeMethod(String name, args) { >> >>> println "Invoke" >> >>> return foo.invokeMethod(name, args) >> >>> } >> >>> } >> >>> >> >>> println new Bar1().someMethod("abc") >> >>> println new Bar2().someMethod("abc") >> >>> >> >>> The output from Bar1 produces (as expected): >> >>> Invoke >> >>> abcabc >> >>> >> >>> The output from Bar2 produces: >> >>> abcabc >> >>> >> >>> The reason I want to use @Delegate here is so that I can >> >>> implement >> >>> the IFoo interface. This allows my Java code that is >> >>> calling this to >> >>> be able to call it as if it is any other IFoo Java class. >> >>> >> >>> Is there some reason why @Delegate cannot be used with >> >>> invokeMethod >> >>> or is this a bug? >> >>> >> >>> Thanks >> >>> >> >>> Chris Dail >> >>> http://chrisdail.com/ >> >>> >> >>> >> >>> >> >>> >> >>> --------------------------------------------------------------------- >> >>> To unsubscribe from this list, please visit: >> >>> >> >>> http://xircles.codehaus.org/manage_email >> >>> >> >>> >> >>> >> >> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe from this list, please visit: >> >> >> >> http://xircles.codehaus.org/manage_email >> >> >> >> >> > >> > >> >> >> >> -- >> Guillaume Laforge >> Groovy Project Manager >> Head of Groovy Development at SpringSource >> http://www.springsource.com/g2one >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > > -- Guillaume Laforge Groovy Project Manager Head of Groovy Development at SpringSource http://www.springsource.com/g2one --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: InvokeMethod and @Delegate TogetherI guess I do not need to use the @Delegate here at all in that case. The reason I wanted it in the first place was so that my Bar proxy would implement the foo interface. If I use the metaClass, I can add this to foo itself and then do not need the @Delegate at all. This allows my Java code to still use Foo with the IFoo interface.
Using my original sample, Foo foo = new Foo() foo.metaClass.invokeMethod = {String name, args-> println "Invoke: $name"
return foo.&"$name"(args) } foo.someMethod("abc") Invoke: someMethod abcabc
This is exactly what I needed. Thanks for your help
Chris On Tue, Nov 3, 2009 at 5:25 AM, Guillaume Laforge <glaforge@...> wrote: True, the original question! |
| Free embeddable forum powered by Nabble | Forum Help |