|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Groovy closure from Java codeHi,
how can I create a groovy closure in Java? In addition, how can I invoke a groovy closure in Java? For example, I have this Groovy code: ---groovy--- public method(closure) { closure() } ---groovy--- ---java--- public void main() { GroovyClass gclass = new GroovyClass(); ??? closure = new ??? gclass.method(closure); } ---java--- The additional question, how can I invoke the closure from Java: ---java--- public void main() { ??? closure = new ??? closure.invoke() ??? } ---java--- Thank you a lot for your help, Regards, Erwin -- Erwin Mueller, devent.ml@... http://www.global-scaling-institute.de/ http://www.deventm.org --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Groovy closure from Java codeYou can do something like that in Java:
Closure c = new Closure(someOwnerObject); c.call(someParameter); On Thu, Nov 5, 2009 at 23:54, Erwin Mueller <devent.ml@...> wrote: > Hi, > how can I create a groovy closure in Java? > In addition, how can I invoke a groovy closure in Java? > > For example, I have this Groovy code: > ---groovy--- > public method(closure) { > closure() > } > ---groovy--- > ---java--- > public void main() { > GroovyClass gclass = new GroovyClass(); > ??? closure = new ??? > gclass.method(closure); > } > ---java--- > > The additional question, how can I invoke the closure from Java: > ---java--- > public void main() { > ??? closure = new ??? > closure.invoke() ??? > } > ---java--- > > Thank you a lot for your help, > Regards, > Erwin > -- > Erwin Mueller, devent.ml@... > http://www.global-scaling-institute.de/ > http://www.deventm.org > > --------------------------------------------------------------------- > 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: Groovy closure from Java codeGuillaume Laforge schrieb:
> You can do something like that in Java: > > Closure c = new Closure(someOwnerObject); > c.call(someParameter); oh, that would fail, since there is no doCall method. It is needed to subclass Closure and give it a doCall method. using call is correct though, since call will call doCall. bye blackdrag -- Jochen "blackdrag" Theodorou The Groovy Project Tech Lead (http://groovy.codehaus.org) http://blackdragsview.blogspot.com/ --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |