Java Mailing List Archive

http://www.gg3721.com/

Home » user.groovy »

Re: [groovy-user] Method created via ExpandoMetaClass is not
recognized

Setya

2008-08-22

Replies: Find Java Web Hosting

Author LoginPost Reply

Hi blackdrag,

Thanks for quick response.

I've tried your suggestions, but none of them works.

Regarding ExpandoMetaClass.enableGlobally(), If I put it in
MyGroovyClassImpl.groovy than the GroovyClassLoader won't parse the file as
instance of MyJavaInterface. If I add it when evaluating the script, it
doesn't take effect.

But If I put those scripts in 1 file it works as expected as follows:

class MyGroovyClassImpl
{
  MyGroovyClassImpl()
  {
    MyGroovyClassImpl.metaClass.getNext = {->println 'This is next
command.';};
  }
}
ExpandoMetaClass.enableGlobally();
def context = new MyGroovyClassImpl();
context.next;

Regards,

Setya
--
Sent from the groovy - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


©2008 gg3721.com - Jax Systems, LLC, U.S.A.