« Return to Thread: Method created via ExpandoMetaClass is not recognized

Re: Method created via ExpandoMetaClass is not recognized

by roshandawrani :: Rate this Message:

Reply to Author | View in Thread

Yes. I have defined a Java interface whose implementation is a Groovy class and then I am invoking this impl groovy class again from a Java class using GroovyShell/GroovyClassLoader - I set it up exactly as you mentioned in your first mail. I am attaching the code files that worked for me.

It is just that even after seeing it work, I did not understand the meaning of "this.metaClass = null". Does setting it to null make it re-assign its own per instance metaClass using the newly modified global EMC?

rgds,
Roshan

On Sat, Aug 23, 2008 at 12:01 AM, Setya <jsetya@...> wrote:

Hi,

>
> I am also trying to learn Groovy and I tried this thing and for me both
> the
> things worked -
>
> 1) setting this.metaClass = null in the MyGroovyClassImpl constructor in
> MyGroovyClassImpl.groovy
>
> 2) setting MyGroovyClassImpl.metaClass.getNext in a static block so that
> it
> happens only once.
>
> Can you please take out a few moments and explain the effect
> "this.metaClass
> = null" internally has? Does setting it null make the instance use the
> global metaclass that has been affected by setting
> "MyGroovyClassImpl.metaClass.getNext"?

Does your class implement a Java (not Groovy) interface ? and you invoke the
script exactly the way I did it from Java (not Groovy) ?

Regards,

Setya

--
View this message in context: http://www.nabble.com/Method-created-via-ExpandoMetaClass-is-not-recognized-tp19108704p19113164.html
Sent from the groovy - user mailing list archive at Nabble.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

Test.java (1K) Download Attachment
MyJavaInterface.java (94 bytes) Download Attachment
MyGroovyClassImpl.groovy (436 bytes) Download Attachment

 « Return to Thread: Method created via ExpandoMetaClass is not recognized