Quantcast

Adding properties failed with ExpandoMetaClass

classic Classic list List threaded Threaded
22 messages Options
123
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Adding properties failed with ExpandoMetaClass

daniel_sun
Hi all,

I tried to add properties with ExpandoMetaClass.
but failed :(
Could you tell what's wrong with the code which is shown below.

Any help is appreciated.

Thanks,
Daniel.Sun

======================================

class Book {
   String title
}

def metaClass = new ExpandoMetaClass(Book, true)
metaClass.author = "Stephen King"
//metaClass.getAuthor << { "Stephen King" }  
metaClass.initialize()

def b = new Book(title:"The Stand")

assert "Stephen King" == b.author

-------------------------------------------------------

groovy> class Book {
groovy>    String title
groovy> }
groovy> def metaClass = new ExpandoMetaClass(Book, true)
groovy> metaClass.author = "Stephen King"
groovy> //metaClass.getAuthor << { "Stephen King" }
groovy> metaClass.initialize()
groovy> def b = new Book(title:"The Stand")
groovy> assert "Stephen King" == b.author

Exception thrown: groovy.lang.MissingPropertyException: No such property: author for class: Book

groovy.lang.MissingPropertyException: No such property: author for class: Book
        at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
        at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
        at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
        at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
        at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
        at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
        at Book.getProperty(Script21)
        at org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
        at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
        at Script21.run(Script21:12)
        at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
        at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
        at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
        at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
        at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
        at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
        at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
        at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
        at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
        at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
        at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
        at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
        at groovy.lang.Closure.call(Closure.java:209)
        at groovy.lang.Closure.call(Closure.java:204)
        at groovy.lang.Closure.run(Closure.java:285)
        at java.lang.Thread.run(Thread.java:619)

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding properties failed with ExpandoMetaClass

paulk_asert

This works for me:

class Book {
   String title
}

def metaClass = new ExpandoMetaClass(Book, true)
metaClass.getAuthor << { -> "Stephen King" }
metaClass.initialize()

def b = new Book(title:"The Stand")

assert "Stephen King" == b.author


Daniel.Sun wrote:

> Hi all,
>
> I tried to add properties with ExpandoMetaClass.
> but failed :(
> Could you tell what's wrong with the code which is shown below.
>
> Any help is appreciated.
>
> Thanks,
> Daniel.Sun
>
> ======================================
>
> class Book {
>    String title
> }
>
> def metaClass = new ExpandoMetaClass(Book, true)
> metaClass.author = "Stephen King"
> //metaClass.getAuthor << { "Stephen King" }  
> metaClass.initialize()
>
> def b = new Book(title:"The Stand")
>
> assert "Stephen King" == b.author
>
> -------------------------------------------------------
>
> groovy> class Book {
> groovy>    String title
> groovy> }
> groovy> def metaClass = new ExpandoMetaClass(Book, true)
> groovy> metaClass.author = "Stephen King"
> groovy> //metaClass.getAuthor << { "Stephen King" }
> groovy> metaClass.initialize()
> groovy> def b = new Book(title:"The Stand")
> groovy> assert "Stephen King" == b.author
>
> Exception thrown: groovy.lang.MissingPropertyException: No such property:
> author for class: Book
>
> groovy.lang.MissingPropertyException: No such property: author for class:
> Book
> at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
> at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
> at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> at Book.getProperty(Script21)
> at org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
> at
> org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
> at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
> at Script21.run(Script21:12)
> at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
> at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
> at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
> at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
> at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
> at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> at groovy.lang.Closure.call(Closure.java:209)
> at groovy.lang.Closure.call(Closure.java:204)
> at groovy.lang.Closure.run(Closure.java:285)
> at java.lang.Thread.run(Thread.java:619)
>
>


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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding properties failed with ExpandoMetaClass

daniel_sun
Hi Paul,

Could you tell me what difference between { -> "Stephen King" } and { "Stephen King" } is?
{ -> "Stephen King" } is equivalent to { "Stephen King" }  ?

BTW, metaClass.author = "Stephen King" seems not to work.

Thanks,
Daniel.Sun

Paul King wrote
This works for me:

class Book {
   String title
}

def metaClass = new ExpandoMetaClass(Book, true)
metaClass.getAuthor << { -> "Stephen King" }
metaClass.initialize()

def b = new Book(title:"The Stand")

assert "Stephen King" == b.author


Daniel.Sun wrote:
> Hi all,
>
> I tried to add properties with ExpandoMetaClass.
> but failed :(
> Could you tell what's wrong with the code which is shown below.
>
> Any help is appreciated.
>
> Thanks,
> Daniel.Sun
>
> ======================================
>
> class Book {
>    String title
> }
>
> def metaClass = new ExpandoMetaClass(Book, true)
> metaClass.author = "Stephen King"
> //metaClass.getAuthor << { "Stephen King" }  
> metaClass.initialize()
>
> def b = new Book(title:"The Stand")
>
> assert "Stephen King" == b.author
>
> -------------------------------------------------------
>
> groovy> class Book {
> groovy>    String title
> groovy> }
> groovy> def metaClass = new ExpandoMetaClass(Book, true)
> groovy> metaClass.author = "Stephen King"
> groovy> //metaClass.getAuthor << { "Stephen King" }
> groovy> metaClass.initialize()
> groovy> def b = new Book(title:"The Stand")
> groovy> assert "Stephen King" == b.author
>
> Exception thrown: groovy.lang.MissingPropertyException: No such property:
> author for class: Book
>
> groovy.lang.MissingPropertyException: No such property: author for class:
> Book
> at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
> at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
> at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> at Book.getProperty(Script21)
> at org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
> at
> org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
> at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
> at Script21.run(Script21:12)
> at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
> at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
> at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
> at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
> at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
> at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> at groovy.lang.Closure.call(Closure.java:209)
> at groovy.lang.Closure.call(Closure.java:204)
> at groovy.lang.Closure.run(Closure.java:285)
> at java.lang.Thread.run(Thread.java:619)
>
>


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

    http://xircles.codehaus.org/manage_email
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding properties failed with ExpandoMetaClass

Guillaume Laforge
Administrator
{ -> "Stephen King" } is a closure with no parameter that returns a
String, while { "Stephen King" } is a closure with one default
parameter (it) and that returns a String.
A getter method has no parameter.

On 5/6/07, Daniel.Sun <[hidden email]> wrote:

>
> Hi Paul,
>
> Could you tell me what difference between { -> "Stephen King" } and {
> "Stephen King" } is?
> { -> "Stephen King" } is equivalent to { "Stephen King" }  ?
>
> BTW, metaClass.author = "Stephen King" seems not to work.
>
> Thanks,
> Daniel.Sun
>
>
> Paul King wrote:
> >
> >
> > This works for me:
> >
> > class Book {
> >    String title
> > }
> >
> > def metaClass = new ExpandoMetaClass(Book, true)
> > metaClass.getAuthor << { -> "Stephen King" }
> > metaClass.initialize()
> >
> > def b = new Book(title:"The Stand")
> >
> > assert "Stephen King" == b.author
> >
> >
> > Daniel.Sun wrote:
> >> Hi all,
> >>
> >> I tried to add properties with ExpandoMetaClass.
> >> but failed :(
> >> Could you tell what's wrong with the code which is shown below.
> >>
> >> Any help is appreciated.
> >>
> >> Thanks,
> >> Daniel.Sun
> >>
> >> ======================================
> >>
> >> class Book {
> >>    String title
> >> }
> >>
> >> def metaClass = new ExpandoMetaClass(Book, true)
> >> metaClass.author = "Stephen King"
> >> //metaClass.getAuthor << { "Stephen King" }
> >> metaClass.initialize()
> >>
> >> def b = new Book(title:"The Stand")
> >>
> >> assert "Stephen King" == b.author
> >>
> >> -------------------------------------------------------
> >>
> >> groovy> class Book {
> >> groovy>    String title
> >> groovy> }
> >> groovy> def metaClass = new ExpandoMetaClass(Book, true)
> >> groovy> metaClass.author = "Stephen King"
> >> groovy> //metaClass.getAuthor << { "Stephen King" }
> >> groovy> metaClass.initialize()
> >> groovy> def b = new Book(title:"The Stand")
> >> groovy> assert "Stephen King" == b.author
> >>
> >> Exception thrown: groovy.lang.MissingPropertyException: No such property:
> >> author for class: Book
> >>
> >> groovy.lang.MissingPropertyException: No such property: author for class:
> >> Book
> >>      at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
> >>      at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
> >>      at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
> >>      at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >>      at
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >>      at
> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >>      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >>      at
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >>      at
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >>      at Book.getProperty(Script21)
> >>      at org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
> >>      at
> >> org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
> >>      at
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
> >>      at Script21.run(Script21:12)
> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
> >>      at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
> >>      at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >>      at
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >>      at
> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >>      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >>      at
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >>      at
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >>      at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
> >>      at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
> >>      at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >>      at
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >>      at
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
> >>      at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
> >>      at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
> >>      at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >>      at
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >>      at groovy.lang.Closure.call(Closure.java:209)
> >>      at groovy.lang.Closure.call(Closure.java:204)
> >>      at groovy.lang.Closure.run(Closure.java:285)
> >>      at java.lang.Thread.run(Thread.java:619)
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343270
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding properties failed with ExpandoMetaClass

daniel_sun
I understand what you said ;)

but I don't know why *metaClass.author = "Stephen King"* does not work.

Thank you, Guillaume.

Cheers,
Daniel.Sun
glaforge wrote
{ -> "Stephen King" } is a closure with no parameter that returns a
String, while { "Stephen King" } is a closure with one default
parameter (it) and that returns a String.
A getter method has no parameter.

On 5/6/07, Daniel.Sun <realbluesun@hotmail.com> wrote:
>
> Hi Paul,
>
> Could you tell me what difference between { -> "Stephen King" } and {
> "Stephen King" } is?
> { -> "Stephen King" } is equivalent to { "Stephen King" }  ?
>
> BTW, metaClass.author = "Stephen King" seems not to work.
>
> Thanks,
> Daniel.Sun
>
>
> Paul King wrote:
> >
> >
> > This works for me:
> >
> > class Book {
> >    String title
> > }
> >
> > def metaClass = new ExpandoMetaClass(Book, true)
> > metaClass.getAuthor << { -> "Stephen King" }
> > metaClass.initialize()
> >
> > def b = new Book(title:"The Stand")
> >
> > assert "Stephen King" == b.author
> >
> >
> > Daniel.Sun wrote:
> >> Hi all,
> >>
> >> I tried to add properties with ExpandoMetaClass.
> >> but failed :(
> >> Could you tell what's wrong with the code which is shown below.
> >>
> >> Any help is appreciated.
> >>
> >> Thanks,
> >> Daniel.Sun
> >>
> >> ======================================
> >>
> >> class Book {
> >>    String title
> >> }
> >>
> >> def metaClass = new ExpandoMetaClass(Book, true)
> >> metaClass.author = "Stephen King"
> >> //metaClass.getAuthor << { "Stephen King" }
> >> metaClass.initialize()
> >>
> >> def b = new Book(title:"The Stand")
> >>
> >> assert "Stephen King" == b.author
> >>
> >> -------------------------------------------------------
> >>
> >> groovy> class Book {
> >> groovy>    String title
> >> groovy> }
> >> groovy> def metaClass = new ExpandoMetaClass(Book, true)
> >> groovy> metaClass.author = "Stephen King"
> >> groovy> //metaClass.getAuthor << { "Stephen King" }
> >> groovy> metaClass.initialize()
> >> groovy> def b = new Book(title:"The Stand")
> >> groovy> assert "Stephen King" == b.author
> >>
> >> Exception thrown: groovy.lang.MissingPropertyException: No such property:
> >> author for class: Book
> >>
> >> groovy.lang.MissingPropertyException: No such property: author for class:
> >> Book
> >>      at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
> >>      at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
> >>      at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
> >>      at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >>      at
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >>      at
> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >>      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >>      at
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >>      at
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >>      at Book.getProperty(Script21)
> >>      at org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
> >>      at
> >> org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
> >>      at
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
> >>      at Script21.run(Script21:12)
> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
> >>      at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
> >>      at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >>      at
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >>      at
> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >>      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >>      at
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >>      at
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >>      at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
> >>      at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
> >>      at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >>      at
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >>      at
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
> >>      at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
> >>      at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
> >>      at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >>      at
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >>      at groovy.lang.Closure.call(Closure.java:209)
> >>      at groovy.lang.Closure.call(Closure.java:204)
> >>      at groovy.lang.Closure.run(Closure.java:285)
> >>      at java.lang.Thread.run(Thread.java:619)
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343270
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

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

    http://xircles.codehaus.org/manage_email
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding properties failed with ExpandoMetaClass

Guillaume Laforge
Administrator
Oh I see.
Well, I guess it's not supported that way, you have to use closures
for that instead.

On 5/6/07, Daniel.Sun <[hidden email]> wrote:

>
> I understand what you said ;)
>
> but I don't know why *metaClass.author = "Stephen King"* does not work.
>
> Thank you, Guillaume.
>
> Cheers,
> Daniel.Sun
>
> glaforge wrote:
> >
> > { -> "Stephen King" } is a closure with no parameter that returns a
> > String, while { "Stephen King" } is a closure with one default
> > parameter (it) and that returns a String.
> > A getter method has no parameter.
> >
> > On 5/6/07, Daniel.Sun <[hidden email]> wrote:
> >>
> >> Hi Paul,
> >>
> >> Could you tell me what difference between { -> "Stephen King" } and {
> >> "Stephen King" } is?
> >> { -> "Stephen King" } is equivalent to { "Stephen King" }  ?
> >>
> >> BTW, metaClass.author = "Stephen King" seems not to work.
> >>
> >> Thanks,
> >> Daniel.Sun
> >>
> >>
> >> Paul King wrote:
> >> >
> >> >
> >> > This works for me:
> >> >
> >> > class Book {
> >> >    String title
> >> > }
> >> >
> >> > def metaClass = new ExpandoMetaClass(Book, true)
> >> > metaClass.getAuthor << { -> "Stephen King" }
> >> > metaClass.initialize()
> >> >
> >> > def b = new Book(title:"The Stand")
> >> >
> >> > assert "Stephen King" == b.author
> >> >
> >> >
> >> > Daniel.Sun wrote:
> >> >> Hi all,
> >> >>
> >> >> I tried to add properties with ExpandoMetaClass.
> >> >> but failed :(
> >> >> Could you tell what's wrong with the code which is shown below.
> >> >>
> >> >> Any help is appreciated.
> >> >>
> >> >> Thanks,
> >> >> Daniel.Sun
> >> >>
> >> >> ======================================
> >> >>
> >> >> class Book {
> >> >>    String title
> >> >> }
> >> >>
> >> >> def metaClass = new ExpandoMetaClass(Book, true)
> >> >> metaClass.author = "Stephen King"
> >> >> //metaClass.getAuthor << { "Stephen King" }
> >> >> metaClass.initialize()
> >> >>
> >> >> def b = new Book(title:"The Stand")
> >> >>
> >> >> assert "Stephen King" == b.author
> >> >>
> >> >> -------------------------------------------------------
> >> >>
> >> >> groovy> class Book {
> >> >> groovy>    String title
> >> >> groovy> }
> >> >> groovy> def metaClass = new ExpandoMetaClass(Book, true)
> >> >> groovy> metaClass.author = "Stephen King"
> >> >> groovy> //metaClass.getAuthor << { "Stephen King" }
> >> >> groovy> metaClass.initialize()
> >> >> groovy> def b = new Book(title:"The Stand")
> >> >> groovy> assert "Stephen King" == b.author
> >> >>
> >> >> Exception thrown: groovy.lang.MissingPropertyException: No such
> >> property:
> >> >> author for class: Book
> >> >>
> >> >> groovy.lang.MissingPropertyException: No such property: author for
> >> class:
> >> >> Book
> >> >>      at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
> >> >>      at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
> >> >>      at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
> >> >>      at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >> >>      at
> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >> >>      at Book.getProperty(Script21)
> >> >>      at
> >> org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
> >> >>      at Script21.run(Script21:12)
> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
> >> >>      at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
> >> >>      at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >> >>      at
> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >> >>      at
> >> groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
> >> >>      at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
> >> >>      at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
> >> >>      at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
> >> >>      at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
> >> >>      at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >>      at groovy.lang.Closure.call(Closure.java:209)
> >> >>      at groovy.lang.Closure.call(Closure.java:204)
> >> >>      at groovy.lang.Closure.run(Closure.java:285)
> >> >>      at java.lang.Thread.run(Thread.java:619)
> >> >>
> >> >>
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe from this list please visit:
> >> >
> >> >     http://xircles.codehaus.org/manage_email
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343270
> >> Sent from the groovy - user mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list please visit:
> >>
> >>     http://xircles.codehaus.org/manage_email
> >>
> >>
> >
> >
> > --
> > Guillaume Laforge
> > Groovy Project Manager
> > http://glaforge.free.fr/blog/groovy
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343514
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding properties failed with ExpandoMetaClass

daniel_sun
Hi Guillaume,

"Adding properties" in page (http://grails.codehaus.org/ExpandoMetaClass) show it should be ok.
If we only can use closures to add properties, adding properties will be unconvenient because we have to add get and set closures to metaclass.

Best regards,
Daniel.Sun
glaforge wrote
Oh I see.
Well, I guess it's not supported that way, you have to use closures
for that instead.

On 5/6/07, Daniel.Sun <realbluesun@hotmail.com> wrote:
>
> I understand what you said ;)
>
> but I don't know why *metaClass.author = "Stephen King"* does not work.
>
> Thank you, Guillaume.
>
> Cheers,
> Daniel.Sun
>
> glaforge wrote:
> >
> > { -> "Stephen King" } is a closure with no parameter that returns a
> > String, while { "Stephen King" } is a closure with one default
> > parameter (it) and that returns a String.
> > A getter method has no parameter.
> >
> > On 5/6/07, Daniel.Sun <realbluesun@hotmail.com> wrote:
> >>
> >> Hi Paul,
> >>
> >> Could you tell me what difference between { -> "Stephen King" } and {
> >> "Stephen King" } is?
> >> { -> "Stephen King" } is equivalent to { "Stephen King" }  ?
> >>
> >> BTW, metaClass.author = "Stephen King" seems not to work.
> >>
> >> Thanks,
> >> Daniel.Sun
> >>
> >>
> >> Paul King wrote:
> >> >
> >> >
> >> > This works for me:
> >> >
> >> > class Book {
> >> >    String title
> >> > }
> >> >
> >> > def metaClass = new ExpandoMetaClass(Book, true)
> >> > metaClass.getAuthor << { -> "Stephen King" }
> >> > metaClass.initialize()
> >> >
> >> > def b = new Book(title:"The Stand")
> >> >
> >> > assert "Stephen King" == b.author
> >> >
> >> >
> >> > Daniel.Sun wrote:
> >> >> Hi all,
> >> >>
> >> >> I tried to add properties with ExpandoMetaClass.
> >> >> but failed :(
> >> >> Could you tell what's wrong with the code which is shown below.
> >> >>
> >> >> Any help is appreciated.
> >> >>
> >> >> Thanks,
> >> >> Daniel.Sun
> >> >>
> >> >> ======================================
> >> >>
> >> >> class Book {
> >> >>    String title
> >> >> }
> >> >>
> >> >> def metaClass = new ExpandoMetaClass(Book, true)
> >> >> metaClass.author = "Stephen King"
> >> >> //metaClass.getAuthor << { "Stephen King" }
> >> >> metaClass.initialize()
> >> >>
> >> >> def b = new Book(title:"The Stand")
> >> >>
> >> >> assert "Stephen King" == b.author
> >> >>
> >> >> -------------------------------------------------------
> >> >>
> >> >> groovy> class Book {
> >> >> groovy>    String title
> >> >> groovy> }
> >> >> groovy> def metaClass = new ExpandoMetaClass(Book, true)
> >> >> groovy> metaClass.author = "Stephen King"
> >> >> groovy> //metaClass.getAuthor << { "Stephen King" }
> >> >> groovy> metaClass.initialize()
> >> >> groovy> def b = new Book(title:"The Stand")
> >> >> groovy> assert "Stephen King" == b.author
> >> >>
> >> >> Exception thrown: groovy.lang.MissingPropertyException: No such
> >> property:
> >> >> author for class: Book
> >> >>
> >> >> groovy.lang.MissingPropertyException: No such property: author for
> >> class:
> >> >> Book
> >> >>      at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
> >> >>      at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
> >> >>      at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
> >> >>      at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >> >>      at
> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >> >>      at Book.getProperty(Script21)
> >> >>      at
> >> org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
> >> >>      at Script21.run(Script21:12)
> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
> >> >>      at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
> >> >>      at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >> >>      at
> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >> >>      at
> >> groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
> >> >>      at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
> >> >>      at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
> >> >>      at groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
> >> >>      at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
> >> >>      at
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >>      at
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >>      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >>      at groovy.lang.Closure.call(Closure.java:209)
> >> >>      at groovy.lang.Closure.call(Closure.java:204)
> >> >>      at groovy.lang.Closure.run(Closure.java:285)
> >> >>      at java.lang.Thread.run(Thread.java:619)
> >> >>
> >> >>
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe from this list please visit:
> >> >
> >> >     http://xircles.codehaus.org/manage_email
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343270
> >> Sent from the groovy - user mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list please visit:
> >>
> >>     http://xircles.codehaus.org/manage_email
> >>
> >>
> >
> >
> > --
> > Guillaume Laforge
> > Groovy Project Manager
> > http://glaforge.free.fr/blog/groovy
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343514
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

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

    http://xircles.codehaus.org/manage_email
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding properties failed with ExpandoMetaClass

Guillaume Laforge
Administrator
We'll have to see what Graeme answers, since the ExpandoMetaClass
comes from Grails.


On 5/6/07, Daniel.Sun <[hidden email]> wrote:

>
> Hi Guillaume,
>
> "Adding properties" in page (http://grails.codehaus.org/ExpandoMetaClass)
> show it should be ok.
> If we only can use closures to add properties, adding properties will be
> unconvenient because we have to add get and set closures to metaclass.
>
> Best regards,
> Daniel.Sun
>
> glaforge wrote:
> >
> > Oh I see.
> > Well, I guess it's not supported that way, you have to use closures
> > for that instead.
> >
> > On 5/6/07, Daniel.Sun <[hidden email]> wrote:
> >>
> >> I understand what you said ;)
> >>
> >> but I don't know why *metaClass.author = "Stephen King"* does not work.
> >>
> >> Thank you, Guillaume.
> >>
> >> Cheers,
> >> Daniel.Sun
> >>
> >> glaforge wrote:
> >> >
> >> > { -> "Stephen King" } is a closure with no parameter that returns a
> >> > String, while { "Stephen King" } is a closure with one default
> >> > parameter (it) and that returns a String.
> >> > A getter method has no parameter.
> >> >
> >> > On 5/6/07, Daniel.Sun <[hidden email]> wrote:
> >> >>
> >> >> Hi Paul,
> >> >>
> >> >> Could you tell me what difference between { -> "Stephen King" } and {
> >> >> "Stephen King" } is?
> >> >> { -> "Stephen King" } is equivalent to { "Stephen King" }  ?
> >> >>
> >> >> BTW, metaClass.author = "Stephen King" seems not to work.
> >> >>
> >> >> Thanks,
> >> >> Daniel.Sun
> >> >>
> >> >>
> >> >> Paul King wrote:
> >> >> >
> >> >> >
> >> >> > This works for me:
> >> >> >
> >> >> > class Book {
> >> >> >    String title
> >> >> > }
> >> >> >
> >> >> > def metaClass = new ExpandoMetaClass(Book, true)
> >> >> > metaClass.getAuthor << { -> "Stephen King" }
> >> >> > metaClass.initialize()
> >> >> >
> >> >> > def b = new Book(title:"The Stand")
> >> >> >
> >> >> > assert "Stephen King" == b.author
> >> >> >
> >> >> >
> >> >> > Daniel.Sun wrote:
> >> >> >> Hi all,
> >> >> >>
> >> >> >> I tried to add properties with ExpandoMetaClass.
> >> >> >> but failed :(
> >> >> >> Could you tell what's wrong with the code which is shown below.
> >> >> >>
> >> >> >> Any help is appreciated.
> >> >> >>
> >> >> >> Thanks,
> >> >> >> Daniel.Sun
> >> >> >>
> >> >> >> ======================================
> >> >> >>
> >> >> >> class Book {
> >> >> >>    String title
> >> >> >> }
> >> >> >>
> >> >> >> def metaClass = new ExpandoMetaClass(Book, true)
> >> >> >> metaClass.author = "Stephen King"
> >> >> >> //metaClass.getAuthor << { "Stephen King" }
> >> >> >> metaClass.initialize()
> >> >> >>
> >> >> >> def b = new Book(title:"The Stand")
> >> >> >>
> >> >> >> assert "Stephen King" == b.author
> >> >> >>
> >> >> >> -------------------------------------------------------
> >> >> >>
> >> >> >> groovy> class Book {
> >> >> >> groovy>    String title
> >> >> >> groovy> }
> >> >> >> groovy> def metaClass = new ExpandoMetaClass(Book, true)
> >> >> >> groovy> metaClass.author = "Stephen King"
> >> >> >> groovy> //metaClass.getAuthor << { "Stephen King" }
> >> >> >> groovy> metaClass.initialize()
> >> >> >> groovy> def b = new Book(title:"The Stand")
> >> >> >> groovy> assert "Stephen King" == b.author
> >> >> >>
> >> >> >> Exception thrown: groovy.lang.MissingPropertyException: No such
> >> >> property:
> >> >> >> author for class: Book
> >> >> >>
> >> >> >> groovy.lang.MissingPropertyException: No such property: author for
> >> >> class:
> >> >> >> Book
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
> >> >> >>      at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown
> >> Source)
> >> >> >>      at
> >> >> >>
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >> >>      at
> >> >> >>
> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >> >> >>      at Book.getProperty(Script21)
> >> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
> >> >> >>      at Script21.run(Script21:12)
> >> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
> >> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
> >> >> >>      at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown
> >> Source)
> >> >> >>      at
> >> >> >>
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >> >>      at
> >> >> >>
> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >> >> >>      at
> >> >> groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
> >> >> >>      at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown
> >> Source)
> >> >> >>      at
> >> >> >>
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
> >> >> >>      at
> >> groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
> >> >> >>      at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown
> >> Source)
> >> >> >>      at
> >> >> >>
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >> >>      at groovy.lang.Closure.call(Closure.java:209)
> >> >> >>      at groovy.lang.Closure.call(Closure.java:204)
> >> >> >>      at groovy.lang.Closure.run(Closure.java:285)
> >> >> >>      at java.lang.Thread.run(Thread.java:619)
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > To unsubscribe from this list please visit:
> >> >> >
> >> >> >     http://xircles.codehaus.org/manage_email
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343270
> >> >> Sent from the groovy - user mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe from this list please visit:
> >> >>
> >> >>     http://xircles.codehaus.org/manage_email
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Guillaume Laforge
> >> > Groovy Project Manager
> >> > http://glaforge.free.fr/blog/groovy
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe from this list please visit:
> >> >
> >> >     http://xircles.codehaus.org/manage_email
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343514
> >> Sent from the groovy - user mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list please visit:
> >>
> >>     http://xircles.codehaus.org/manage_email
> >>
> >>
> >
> >
> > --
> > Guillaume Laforge
> > Groovy Project Manager
> > http://glaforge.free.fr/blog/groovy
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10344112
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding properties failed with ExpandoMetaClass

graemer
We removed this feature from the Groovy version of ExpandoMetaClass
because in Grails we store the variables in a map that is bound to a
ThreadLocal variable

This works ok in the context of a web application because each request
maps to a thread and when a thread finishes the data gets garbage
collected. However in the case where you don't have a multi threaded
system where threads go away you have a memory leak

Essentially you need some way of associating properties with instances
that results in the property values being garbage collected when the
instance goes away. This capability is not there in the case of a
single threaded scenario.

Thus we leave it up to the developer how they manage this and only
allow the closure mechanism in Groovy 1.1

Cheers

On 5/6/07, Guillaume Laforge <[hidden email]> wrote:

> We'll have to see what Graeme answers, since the ExpandoMetaClass
> comes from Grails.
>
>
> On 5/6/07, Daniel.Sun <[hidden email]> wrote:
> >
> > Hi Guillaume,
> >
> > "Adding properties" in page (http://grails.codehaus.org/ExpandoMetaClass)
> > show it should be ok.
> > If we only can use closures to add properties, adding properties will be
> > unconvenient because we have to add get and set closures to metaclass.
> >
> > Best regards,
> > Daniel.Sun
> >
> > glaforge wrote:
> > >
> > > Oh I see.
> > > Well, I guess it's not supported that way, you have to use closures
> > > for that instead.
> > >
> > > On 5/6/07, Daniel.Sun <[hidden email]> wrote:
> > >>
> > >> I understand what you said ;)
> > >>
> > >> but I don't know why *metaClass.author = "Stephen King"* does not work.
> > >>
> > >> Thank you, Guillaume.
> > >>
> > >> Cheers,
> > >> Daniel.Sun
> > >>
> > >> glaforge wrote:
> > >> >
> > >> > { -> "Stephen King" } is a closure with no parameter that returns a
> > >> > String, while { "Stephen King" } is a closure with one default
> > >> > parameter (it) and that returns a String.
> > >> > A getter method has no parameter.
> > >> >
> > >> > On 5/6/07, Daniel.Sun <[hidden email]> wrote:
> > >> >>
> > >> >> Hi Paul,
> > >> >>
> > >> >> Could you tell me what difference between { -> "Stephen King" } and {
> > >> >> "Stephen King" } is?
> > >> >> { -> "Stephen King" } is equivalent to { "Stephen King" }  ?
> > >> >>
> > >> >> BTW, metaClass.author = "Stephen King" seems not to work.
> > >> >>
> > >> >> Thanks,
> > >> >> Daniel.Sun
> > >> >>
> > >> >>
> > >> >> Paul King wrote:
> > >> >> >
> > >> >> >
> > >> >> > This works for me:
> > >> >> >
> > >> >> > class Book {
> > >> >> >    String title
> > >> >> > }
> > >> >> >
> > >> >> > def metaClass = new ExpandoMetaClass(Book, true)
> > >> >> > metaClass.getAuthor << { -> "Stephen King" }
> > >> >> > metaClass.initialize()
> > >> >> >
> > >> >> > def b = new Book(title:"The Stand")
> > >> >> >
> > >> >> > assert "Stephen King" == b.author
> > >> >> >
> > >> >> >
> > >> >> > Daniel.Sun wrote:
> > >> >> >> Hi all,
> > >> >> >>
> > >> >> >> I tried to add properties with ExpandoMetaClass.
> > >> >> >> but failed :(
> > >> >> >> Could you tell what's wrong with the code which is shown below.
> > >> >> >>
> > >> >> >> Any help is appreciated.
> > >> >> >>
> > >> >> >> Thanks,
> > >> >> >> Daniel.Sun
> > >> >> >>
> > >> >> >> ======================================
> > >> >> >>
> > >> >> >> class Book {
> > >> >> >>    String title
> > >> >> >> }
> > >> >> >>
> > >> >> >> def metaClass = new ExpandoMetaClass(Book, true)
> > >> >> >> metaClass.author = "Stephen King"
> > >> >> >> //metaClass.getAuthor << { "Stephen King" }
> > >> >> >> metaClass.initialize()
> > >> >> >>
> > >> >> >> def b = new Book(title:"The Stand")
> > >> >> >>
> > >> >> >> assert "Stephen King" == b.author
> > >> >> >>
> > >> >> >> -------------------------------------------------------
> > >> >> >>
> > >> >> >> groovy> class Book {
> > >> >> >> groovy>    String title
> > >> >> >> groovy> }
> > >> >> >> groovy> def metaClass = new ExpandoMetaClass(Book, true)
> > >> >> >> groovy> metaClass.author = "Stephen King"
> > >> >> >> groovy> //metaClass.getAuthor << { "Stephen King" }
> > >> >> >> groovy> metaClass.initialize()
> > >> >> >> groovy> def b = new Book(title:"The Stand")
> > >> >> >> groovy> assert "Stephen King" == b.author
> > >> >> >>
> > >> >> >> Exception thrown: groovy.lang.MissingPropertyException: No such
> > >> >> property:
> > >> >> >> author for class: Book
> > >> >> >>
> > >> >> >> groovy.lang.MissingPropertyException: No such property: author for
> > >> >> class:
> > >> >> >> Book
> > >> >> >>      at
> > >> groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
> > >> >> >>      at
> > >> groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
> > >> >> >>      at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown
> > >> Source)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> > >> >> >>      at
> > >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> > >> >> >>      at
> > >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> > >> >> >>      at
> > >> >> >>
> > >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> > >> >> >>      at
> > >> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> > >> >> >>      at Book.getProperty(Script21)
> > >> >> >>      at
> > >> >> org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
> > >> >> >>      at Script21.run(Script21:12)
> > >> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
> > >> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
> > >> >> >>      at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown
> > >> Source)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> > >> >> >>      at
> > >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> > >> >> >>      at
> > >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> > >> >> >>      at
> > >> >> >>
> > >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> > >> >> >>      at
> > >> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> > >> >> >>      at
> > >> >> groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
> > >> >> >>      at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown
> > >> Source)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> > >> >> >>      at
> > >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
> > >> >> >>      at
> > >> groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
> > >> >> >>      at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown
> > >> Source)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> > >> >> >>      at
> > >> >> >>
> > >> >>
> > >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> > >> >> >>      at
> > >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> > >> >> >>      at
> > >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> > >> >> >>      at groovy.lang.Closure.call(Closure.java:209)
> > >> >> >>      at groovy.lang.Closure.call(Closure.java:204)
> > >> >> >>      at groovy.lang.Closure.run(Closure.java:285)
> > >> >> >>      at java.lang.Thread.run(Thread.java:619)
> > >> >> >>
> > >> >> >>
> > >> >> >
> > >> >> >
> > >> >> >
> > >> ---------------------------------------------------------------------
> > >> >> > To unsubscribe from this list please visit:
> > >> >> >
> > >> >> >     http://xircles.codehaus.org/manage_email
> > >> >> >
> > >> >> >
> > >> >> >
> > >> >>
> > >> >> --
> > >> >> View this message in context:
> > >> >>
> > >> http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343270
> > >> >> Sent from the groovy - user mailing list archive at Nabble.com.
> > >> >>
> > >> >>
> > >> >> ---------------------------------------------------------------------
> > >> >> To unsubscribe from this list please visit:
> > >> >>
> > >> >>     http://xircles.codehaus.org/manage_email
> > >> >>
> > >> >>
> > >> >
> > >> >
> > >> > --
> > >> > Guillaume Laforge
> > >> > Groovy Project Manager
> > >> > http://glaforge.free.fr/blog/groovy
> > >> >
> > >> > ---------------------------------------------------------------------
> > >> > To unsubscribe from this list please visit:
> > >> >
> > >> >     http://xircles.codehaus.org/manage_email
> > >> >
> > >> >
> > >> >
> > >>
> > >> --
> > >> View this message in context:
> > >> http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343514
> > >> Sent from the groovy - user mailing list archive at Nabble.com.
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe from this list please visit:
> > >>
> > >>     http://xircles.codehaus.org/manage_email
> > >>
> > >>
> > >
> > >
> > > --
> > > Guillaume Laforge
> > > Groovy Project Manager
> > > http://glaforge.free.fr/blog/groovy
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe from this list please visit:
> > >
> > >     http://xircles.codehaus.org/manage_email
> > >
> > >
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10344112
> > Sent from the groovy - user mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>
>
> --
> Guillaume Laforge
> Groovy Project Manager
> http://glaforge.free.fr/blog/groovy
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding properties failed with ExpandoMetaClass

daniel_sun
In reply to this post by Guillaume Laforge
Thank you, Guillaume.
I have seen Graeme's detail answers :)

Cheers,
Daniel.Sun
glaforge wrote
We'll have to see what Graeme answers, since the ExpandoMetaClass
comes from Grails.


On 5/6/07, Daniel.Sun <realbluesun@hotmail.com> wrote:
>
> Hi Guillaume,
>
> "Adding properties" in page (http://grails.codehaus.org/ExpandoMetaClass)
> show it should be ok.
> If we only can use closures to add properties, adding properties will be
> unconvenient because we have to add get and set closures to metaclass.
>
> Best regards,
> Daniel.Sun
>
> glaforge wrote:
> >
> > Oh I see.
> > Well, I guess it's not supported that way, you have to use closures
> > for that instead.
> >
> > On 5/6/07, Daniel.Sun <realbluesun@hotmail.com> wrote:
> >>
> >> I understand what you said ;)
> >>
> >> but I don't know why *metaClass.author = "Stephen King"* does not work.
> >>
> >> Thank you, Guillaume.
> >>
> >> Cheers,
> >> Daniel.Sun
> >>
> >> glaforge wrote:
> >> >
> >> > { -> "Stephen King" } is a closure with no parameter that returns a
> >> > String, while { "Stephen King" } is a closure with one default
> >> > parameter (it) and that returns a String.
> >> > A getter method has no parameter.
> >> >
> >> > On 5/6/07, Daniel.Sun <realbluesun@hotmail.com> wrote:
> >> >>
> >> >> Hi Paul,
> >> >>
> >> >> Could you tell me what difference between { -> "Stephen King" } and {
> >> >> "Stephen King" } is?
> >> >> { -> "Stephen King" } is equivalent to { "Stephen King" }  ?
> >> >>
> >> >> BTW, metaClass.author = "Stephen King" seems not to work.
> >> >>
> >> >> Thanks,
> >> >> Daniel.Sun
> >> >>
> >> >>
> >> >> Paul King wrote:
> >> >> >
> >> >> >
> >> >> > This works for me:
> >> >> >
> >> >> > class Book {
> >> >> >    String title
> >> >> > }
> >> >> >
> >> >> > def metaClass = new ExpandoMetaClass(Book, true)
> >> >> > metaClass.getAuthor << { -> "Stephen King" }
> >> >> > metaClass.initialize()
> >> >> >
> >> >> > def b = new Book(title:"The Stand")
> >> >> >
> >> >> > assert "Stephen King" == b.author
> >> >> >
> >> >> >
> >> >> > Daniel.Sun wrote:
> >> >> >> Hi all,
> >> >> >>
> >> >> >> I tried to add properties with ExpandoMetaClass.
> >> >> >> but failed :(
> >> >> >> Could you tell what's wrong with the code which is shown below.
> >> >> >>
> >> >> >> Any help is appreciated.
> >> >> >>
> >> >> >> Thanks,
> >> >> >> Daniel.Sun
> >> >> >>
> >> >> >> ======================================
> >> >> >>
> >> >> >> class Book {
> >> >> >>    String title
> >> >> >> }
> >> >> >>
> >> >> >> def metaClass = new ExpandoMetaClass(Book, true)
> >> >> >> metaClass.author = "Stephen King"
> >> >> >> //metaClass.getAuthor << { "Stephen King" }
> >> >> >> metaClass.initialize()
> >> >> >>
> >> >> >> def b = new Book(title:"The Stand")
> >> >> >>
> >> >> >> assert "Stephen King" == b.author
> >> >> >>
> >> >> >> -------------------------------------------------------
> >> >> >>
> >> >> >> groovy> class Book {
> >> >> >> groovy>    String title
> >> >> >> groovy> }
> >> >> >> groovy> def metaClass = new ExpandoMetaClass(Book, true)
> >> >> >> groovy> metaClass.author = "Stephen King"
> >> >> >> groovy> //metaClass.getAuthor << { "Stephen King" }
> >> >> >> groovy> metaClass.initialize()
> >> >> >> groovy> def b = new Book(title:"The Stand")
> >> >> >> groovy> assert "Stephen King" == b.author
> >> >> >>
> >> >> >> Exception thrown: groovy.lang.MissingPropertyException: No such
> >> >> property:
> >> >> >> author for class: Book
> >> >> >>
> >> >> >> groovy.lang.MissingPropertyException: No such property: author for
> >> >> class:
> >> >> >> Book
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:975)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2216)
> >> >> >>      at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown
> >> Source)
> >> >> >>      at
> >> >> >>
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >> >>      at
> >> >> >>
> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >> >> >>      at Book.getProperty(Script21)
> >> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.getProperty(Invoker.java:198)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:205)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:500)
> >> >> >>      at Script21.run(Script21:12)
> >> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:485)
> >> >> >>      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:426)
> >> >> >>      at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown
> >> Source)
> >> >> >>      at
> >> >> >>
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >> >>      at
> >> >> >>
> >> org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
> >> >> >>      at
> >> >> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
> >> >> >>      at
> >> >> groovy.ui.Console$_runScript_closure8.doCall(Console.groovy:508)
> >> >> >>      at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown
> >> Source)
> >> >> >>      at
> >> >> >>
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:97)
> >> >> >>      at
> >> groovy.ui.Console$_runScript_closure8.doCall(Console.groovy)
> >> >> >>      at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown
> >> Source)
> >> >> >>      at
> >> >> >>
> >> >>
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> >> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
> >> >> >>      at
> >> >> >>
> >> >>
> >> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
> >> >> >>      at
> >> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
> >> >> >>      at groovy.lang.Closure.call(Closure.java:209)
> >> >> >>      at groovy.lang.Closure.call(Closure.java:204)
> >> >> >>      at groovy.lang.Closure.run(Closure.java:285)
> >> >> >>      at java.lang.Thread.run(Thread.java:619)
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > To unsubscribe from this list please visit:
> >> >> >
> >> >> >     http://xircles.codehaus.org/manage_email
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343270
> >> >> Sent from the groovy - user mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe from this list please visit:
> >> >>
> >> >>     http://xircles.codehaus.org/manage_email
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Guillaume Laforge
> >> > Groovy Project Manager
> >> > http://glaforge.free.fr/blog/groovy
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe from this list please visit:
> >> >
> >> >     http://xircles.codehaus.org/manage_email
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10343514
> >> Sent from the groovy - user mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list please visit:
> >>
> >>     http://xircles.codehaus.org/manage_email
> >>
> >>
> >
> >
> > --
> > Guillaume Laforge
> > Groovy Project Manager
> > http://glaforge.free.fr/blog/groovy
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Adding-properties-failed-with-ExpandoMetaClass-tf3698400.html#a10344112
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

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

    http://xircles.codehaus.org/manage_email
123
Loading...