Groovy variables management

View: New views
16 Messages — Rating Filter:   Alert me  

Groovy variables management

by Charles Souillard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Groovy users !

I am a newbie and I want to know how I can:
- know variables used by an expression before evaluating it ? I have a lot of variables available but only some of them are used by the expression, so I want to give only the necessary stuff
- know which variables have been updated in the expression so I can propagate the changes to my repository (I give a copy of my variables to GroovyShell)

Thanks a lot for your help
Regards,
Charles

Re: Groovy variables management

by Jochen Theodorou :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Charles Souillard schrieb:
> Hi Groovy users !
>
> I am a newbie and I want to know how I can:
> - know variables used by an expression before evaluating it ? I have a
> lot of variables available but only some of them are used by the
> expression, so I want to give only the necessary stuff

this appears as a common question... only I don't see why... why can't
you provide them on demand?

> - know which variables have been updated in the expression so I can
> propagate the changes to my repository (I give a copy of my variables to
> GroovyShell)

you will need a class and it has to be a script, then you can provide a
Binding to an instance of that script class which does the recording for you

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



Re: Groovy variables management

by Charles Souillard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for your quick answer !

I want to provide them on demand but I don't know how... Can you point me a tutorial ?
For the second point, I am ok to write such a Binding but again i don't know how.. Can you give me a link for that too ?

thanks a lot
Charles

2009/10/29 Jochen Theodorou <blackdrag@...>
Charles Souillard schrieb:

Hi Groovy users !

I am a newbie and I want to know how I can:
- know variables used by an expression before evaluating it ? I have a lot of variables available but only some of them are used by the expression, so I want to give only the necessary stuff

this appears as a common question... only I don't see why... why can't you provide them on demand?


- know which variables have been updated in the expression so I can propagate the changes to my repository (I give a copy of my variables to GroovyShell)

you will need a class and it has to be a script, then you can provide a Binding to an instance of that script class which does the recording for you

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




Re: Groovy variables management

by Guillaume Laforge-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

An example of this is Groovy's own ServletBinding class (used by
Groovlets, aka Groovy servlets):
http://fisheye.codehaus.org/browse/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/ServletBinding.java?r=HEAD

The binding provides some of the variables on-deman, lazily instanciating them.
And you could also override the setVariable() method to see when the
variable is reassigned in the binding.

If you just mutate the state of variables in the binding (like calling
some setter on those objects), perhaps you should also consider some
kind of Property Change Listener support (JavaBeans spec). You could
look at the @Bindable transformation:
http://groovy.codehaus.org/Bindable+and+Vetoable+transformation

On Thu, Oct 29, 2009 at 17:05, Charles Souillard
<charles.souillard@...> wrote:

> Thanks for your quick answer !
>
> I want to provide them on demand but I don't know how... Can you point me a
> tutorial ?
> For the second point, I am ok to write such a Binding but again i don't know
> how.. Can you give me a link for that too ?
>
> thanks a lot
> Charles
>
> 2009/10/29 Jochen Theodorou <blackdrag@...>
>>
>> Charles Souillard schrieb:
>>>
>>> Hi Groovy users !
>>>
>>> I am a newbie and I want to know how I can:
>>> - know variables used by an expression before evaluating it ? I have a
>>> lot of variables available but only some of them are used by the expression,
>>> so I want to give only the necessary stuff
>>
>> this appears as a common question... only I don't see why... why can't you
>> provide them on demand?
>>
>>> - know which variables have been updated in the expression so I can
>>> propagate the changes to my repository (I give a copy of my variables to
>>> GroovyShell)
>>
>> you will need a class and it has to be a script, then you can provide a
>> Binding to an instance of that script class which does the recording for you
>>
>> 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
>>
>>
>
>



--
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 variables management

by Jochen Theodorou :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Guillaume Laforge schrieb:

> An example of this is Groovy's own ServletBinding class (used by
> Groovlets, aka Groovy servlets):
> http://fisheye.codehaus.org/browse/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/ServletBinding.java?r=HEAD
>
> The binding provides some of the variables on-deman, lazily instanciating them.
> And you could also override the setVariable() method to see when the
> variable is reassigned in the binding.
>
> If you just mutate the state of variables in the binding (like calling
> some setter on those objects), perhaps you should also consider some
> kind of Property Change Listener support (JavaBeans spec). You could
> look at the @Bindable transformation:
> http://groovy.codehaus.org/Bindable+and+Vetoable+transformation

maybe we should provide an example for this in the wiki?

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



Re: Groovy variables management

by Charles Souillard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

thanks for your help.
I have been able to provide only necessary variables by overriding getVariable method in my own Binding.

For my second point, I am able to propagate values in some cases only...
The following case works:
test = "newValue"

but if I do something like :
employee.address.setZipCode, setVariable method is not called on my Binding... So I am not able to propagate it...

Do you know this problem ? If yes, do you have a workaround ?

thanks

Charles Souillard
Chief Technical Officer
BonitaSoft - Open your processes mobile : +33 (0)6 85 84 99 46
email : charles.souillard@...

This message and any attachment (the "message") is intended solely for the addressees and is confidential. If you receive this message by mistake, please delete it and notify the sender immediately. Any use not in accordance with its purpose, any out-spread or disclosure, either as a whole or partially, is prohibited except with formal approval. Internet cannot guarantee the integrity of this message, therefore BonitaSoft will not be liable for the message if modified.



2009/10/29 Jochen Theodorou <blackdrag@...>
Guillaume Laforge schrieb:

An example of this is Groovy's own ServletBinding class (used by
Groovlets, aka Groovy servlets):
http://fisheye.codehaus.org/browse/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/ServletBinding.java?r=HEAD

The binding provides some of the variables on-deman, lazily instanciating them.
And you could also override the setVariable() method to see when the
variable is reassigned in the binding.

If you just mutate the state of variables in the binding (like calling
some setter on those objects), perhaps you should also consider some
kind of Property Change Listener support (JavaBeans spec). You could
look at the @Bindable transformation:
http://groovy.codehaus.org/Bindable+and+Vetoable+transformation

maybe we should provide an example for this in the wiki?


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




Re: Groovy variables management

by Guillaume Laforge-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Perhaps the property change listeners are the way to go here.
Otherwise, we could envision some complicated AST visiting (Abstract Syntax Tree), but that's not trivial...

On Thu, Oct 29, 2009 at 17:35, Charles Souillard <charles.souillard@...> wrote:
Hi,

thanks for your help.
I have been able to provide only necessary variables by overriding getVariable method in my own Binding.

For my second point, I am able to propagate values in some cases only...
The following case works:
test = "newValue"

but if I do something like :
employee.address.setZipCode, setVariable method is not called on my Binding... So I am not able to propagate it...

Do you know this problem ? If yes, do you have a workaround ?

thanks

Charles Souillard
Chief Technical Officer

BonitaSoft - Open your processes mobile : +33 (0)6 85 84 99 46
email : charles.souillard@...

This message and any attachment (the "message") is intended solely for the addressees and is confidential. If you receive this message by mistake, please delete it and notify the sender immediately. Any use not in accordance with its purpose, any out-spread or disclosure, either as a whole or partially, is prohibited except with formal approval. Internet cannot guarantee the integrity of this message, therefore BonitaSoft will not be liable for the message if modified.



2009/10/29 Jochen Theodorou <blackdrag@...>
Guillaume Laforge schrieb:

An example of this is Groovy's own ServletBinding class (used by
Groovlets, aka Groovy servlets):
http://fisheye.codehaus.org/browse/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/ServletBinding.java?r=HEAD

The binding provides some of the variables on-deman, lazily instanciating them.
And you could also override the setVariable() method to see when the
variable is reassigned in the binding.

If you just mutate the state of variables in the binding (like calling
some setter on those objects), perhaps you should also consider some
kind of Property Change Listener support (JavaBeans spec). You could
look at the @Bindable transformation:
http://groovy.codehaus.org/Bindable+and+Vetoable+transformation

maybe we should provide an example for this in the wiki?


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






--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

Re: Groovy variables management

by Charles Souillard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can you point me an example of property change listener please ?

Thanks,
Charles

2009/10/29 Guillaume Laforge <glaforge@...>
Perhaps the property change listeners are the way to go here.
Otherwise, we could envision some complicated AST visiting (Abstract Syntax Tree), but that's not trivial...

On Thu, Oct 29, 2009 at 17:35, Charles Souillard <charles.souillard@...> wrote:
Hi,

thanks for your help.
I have been able to provide only necessary variables by overriding getVariable method in my own Binding.

For my second point, I am able to propagate values in some cases only...
The following case works:
test = "newValue"

but if I do something like :
employee.address.setZipCode, setVariable method is not called on my Binding... So I am not able to propagate it...

Do you know this problem ? If yes, do you have a workaround ?

thanks

Charles Souillard
Chief Technical Officer

BonitaSoft - Open your processes mobile : +33 (0)6 85 84 99 46
email : charles.souillard@...

This message and any attachment (the "message") is intended solely for the addressees and is confidential. If you receive this message by mistake, please delete it and notify the sender immediately. Any use not in accordance with its purpose, any out-spread or disclosure, either as a whole or partially, is prohibited except with formal approval. Internet cannot guarantee the integrity of this message, therefore BonitaSoft will not be liable for the message if modified.



2009/10/29 Jochen Theodorou <blackdrag@...>
Guillaume Laforge schrieb:

An example of this is Groovy's own ServletBinding class (used by
Groovlets, aka Groovy servlets):
http://fisheye.codehaus.org/browse/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/ServletBinding.java?r=HEAD

The binding provides some of the variables on-deman, lazily instanciating them.
And you could also override the setVariable() method to see when the
variable is reassigned in the binding.

If you just mutate the state of variables in the binding (like calling
some setter on those objects), perhaps you should also consider some
kind of Property Change Listener support (JavaBeans spec). You could
look at the @Bindable transformation:
http://groovy.codehaus.org/Bindable+and+Vetoable+transformation

maybe we should provide an example for this in the wiki?


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






--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one


Re: Groovy variables management

by Guillaume Laforge-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, there's the @Bindable transformation I've already mentioned to you in this thread.
And then, the property change listener stuff is standard JavaBeans technique, so you should be able to Google it easily.
It's often related to Swing techniques.

On Thu, Oct 29, 2009 at 17:46, Charles Souillard <charles.souillard@...> wrote:
Can you point me an example of property change listener please ?

Thanks,
Charles

2009/10/29 Guillaume Laforge <glaforge@...>

Perhaps the property change listeners are the way to go here.
Otherwise, we could envision some complicated AST visiting (Abstract Syntax Tree), but that's not trivial...

On Thu, Oct 29, 2009 at 17:35, Charles Souillard <charles.souillard@...> wrote:
Hi,

thanks for your help.
I have been able to provide only necessary variables by overriding getVariable method in my own Binding.

For my second point, I am able to propagate values in some cases only...
The following case works:
test = "newValue"

but if I do something like :
employee.address.setZipCode, setVariable method is not called on my Binding... So I am not able to propagate it...

Do you know this problem ? If yes, do you have a workaround ?

thanks

Charles Souillard
Chief Technical Officer

BonitaSoft - Open your processes mobile : +33 (0)6 85 84 99 46
email : charles.souillard@...

This message and any attachment (the "message") is intended solely for the addressees and is confidential. If you receive this message by mistake, please delete it and notify the sender immediately. Any use not in accordance with its purpose, any out-spread or disclosure, either as a whole or partially, is prohibited except with formal approval. Internet cannot guarantee the integrity of this message, therefore BonitaSoft will not be liable for the message if modified.



2009/10/29 Jochen Theodorou <blackdrag@...>
Guillaume Laforge schrieb:

An example of this is Groovy's own ServletBinding class (used by
Groovlets, aka Groovy servlets):
http://fisheye.codehaus.org/browse/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/ServletBinding.java?r=HEAD

The binding provides some of the variables on-deman, lazily instanciating them.
And you could also override the setVariable() method to see when the
variable is reassigned in the binding.

If you just mutate the state of variables in the binding (like calling
some setter on those objects), perhaps you should also consider some
kind of Property Change Listener support (JavaBeans spec). You could
look at the @Bindable transformation:
http://groovy.codehaus.org/Bindable+and+Vetoable+transformation

maybe we should provide an example for this in the wiki?


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






--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one




--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

Re: Groovy variables management

by Charles Souillard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

my problem is that I am not the bean owner/writer... My variables are defined by an external user so I only have the value (extends Serializable)...
I was looking for a mechanism from Grovvy which can notify me of all varaibles that have been modified. Is this available ?

If not, the only way I know is to iterate over all my initial variables and propagate the new value to my repository... This could generate a big overload as only a small part of my variables may have changed...

thanks,
Charles

2009/10/29 Guillaume Laforge <glaforge@...>
Well, there's the @Bindable transformation I've already mentioned to you in this thread.
And then, the property change listener stuff is standard JavaBeans technique, so you should be able to Google it easily.
It's often related to Swing techniques.


On Thu, Oct 29, 2009 at 17:46, Charles Souillard <charles.souillard@...> wrote:
Can you point me an example of property change listener please ?

Thanks,
Charles

2009/10/29 Guillaume Laforge <glaforge@...>

Perhaps the property change listeners are the way to go here.
Otherwise, we could envision some complicated AST visiting (Abstract Syntax Tree), but that's not trivial...

On Thu, Oct 29, 2009 at 17:35, Charles Souillard <charles.souillard@...> wrote:
Hi,

thanks for your help.
I have been able to provide only necessary variables by overriding getVariable method in my own Binding.

For my second point, I am able to propagate values in some cases only...
The following case works:
test = "newValue"

but if I do something like :
employee.address.setZipCode, setVariable method is not called on my Binding... So I am not able to propagate it...

Do you know this problem ? If yes, do you have a workaround ?

thanks

Charles Souillard
Chief Technical Officer

BonitaSoft - Open your processes mobile : +33 (0)6 85 84 99 46
email : charles.souillard@...

This message and any attachment (the "message") is intended solely for the addressees and is confidential. If you receive this message by mistake, please delete it and notify the sender immediately. Any use not in accordance with its purpose, any out-spread or disclosure, either as a whole or partially, is prohibited except with formal approval. Internet cannot guarantee the integrity of this message, therefore BonitaSoft will not be liable for the message if modified.



2009/10/29 Jochen Theodorou <blackdrag@...>
Guillaume Laforge schrieb:

An example of this is Groovy's own ServletBinding class (used by
Groovlets, aka Groovy servlets):
http://fisheye.codehaus.org/browse/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/ServletBinding.java?r=HEAD

The binding provides some of the variables on-deman, lazily instanciating them.
And you could also override the setVariable() method to see when the
variable is reassigned in the binding.

If you just mutate the state of variables in the binding (like calling
some setter on those objects), perhaps you should also consider some
kind of Property Change Listener support (JavaBeans spec). You could
look at the @Bindable transformation:
http://groovy.codehaus.org/Bindable+and+Vetoable+transformation

maybe we should provide an example for this in the wiki?


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






--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one




--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one


Re: Groovy variables management

by Guillaume Laforge-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, if you're not in control, you can then have a look at the various metaprogramming techniques:
For instance overriding set/getProperty and all the classes of your object graph that you need to be notified about changes.

On Thu, Oct 29, 2009 at 18:51, Charles Souillard <charles.souillard@...> wrote:
Hi,

my problem is that I am not the bean owner/writer... My variables are defined by an external user so I only have the value (extends Serializable)...
I was looking for a mechanism from Grovvy which can notify me of all varaibles that have been modified. Is this available ?

If not, the only way I know is to iterate over all my initial variables and propagate the new value to my repository... This could generate a big overload as only a small part of my variables may have changed...


thanks,
Charles

2009/10/29 Guillaume Laforge <glaforge@...>
Well, there's the @Bindable transformation I've already mentioned to you in this thread.
And then, the property change listener stuff is standard JavaBeans technique, so you should be able to Google it easily.
It's often related to Swing techniques.


On Thu, Oct 29, 2009 at 17:46, Charles Souillard <charles.souillard@...> wrote:
Can you point me an example of property change listener please ?

Thanks,
Charles

2009/10/29 Guillaume Laforge <glaforge@...>

Perhaps the property change listeners are the way to go here.
Otherwise, we could envision some complicated AST visiting (Abstract Syntax Tree), but that's not trivial...

On Thu, Oct 29, 2009 at 17:35, Charles Souillard <charles.souillard@...> wrote:
Hi,

thanks for your help.
I have been able to provide only necessary variables by overriding getVariable method in my own Binding.

For my second point, I am able to propagate values in some cases only...
The following case works:
test = "newValue"

but if I do something like :
employee.address.setZipCode, setVariable method is not called on my Binding... So I am not able to propagate it...

Do you know this problem ? If yes, do you have a workaround ?

thanks

Charles Souillard
Chief Technical Officer

BonitaSoft - Open your processes mobile : +33 (0)6 85 84 99 46
email : charles.souillard@...

This message and any attachment (the "message") is intended solely for the addressees and is confidential. If you receive this message by mistake, please delete it and notify the sender immediately. Any use not in accordance with its purpose, any out-spread or disclosure, either as a whole or partially, is prohibited except with formal approval. Internet cannot guarantee the integrity of this message, therefore BonitaSoft will not be liable for the message if modified.



2009/10/29 Jochen Theodorou <blackdrag@...>
Guillaume Laforge schrieb:

An example of this is Groovy's own ServletBinding class (used by
Groovlets, aka Groovy servlets):
http://fisheye.codehaus.org/browse/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/ServletBinding.java?r=HEAD

The binding provides some of the variables on-deman, lazily instanciating them.
And you could also override the setVariable() method to see when the
variable is reassigned in the binding.

If you just mutate the state of variables in the binding (like calling
some setter on those objects), perhaps you should also consider some
kind of Property Change Listener support (JavaBeans spec). You could
look at the @Bindable transformation:
http://groovy.codehaus.org/Bindable+and+Vetoable+transformation

maybe we should provide an example for this in the wiki?


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






--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one




--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one




--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

Re: Groovy variables management

by Jochen Theodorou :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Charles Souillard schrieb:

> Hi,
>
> my problem is that I am not the bean owner/writer... My variables are
> defined by an external user so I only have the value (extends
> Serializable)...
> I was looking for a mechanism from Grovvy which can notify me of all
> varaibles that have been modified. Is this available ?
>
> If not, the only way I know is to iterate over all my initial variables
> and propagate the new value to my repository... This could generate a
> big overload as only a small part of my variables may have changed...

I have a small understanding problem... a=1 changes the variable a.
a.b=1 gets the value for the variable a and then sets the property b on
that variable to 1. Here a is not changed, the contents of a are. The
Binding does not record the contents. You need that as well? That can be
done through the binding as well, but is a bit more complicated, since
then you have to provide some recording dummy objects.

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



Re: Groovy variables management

by Charles Souillard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is exactly  what I need !!! Can you give me an example of such a Binding ? Or some guidelines ?

In addition, I have seen that a.b = 2 calls getVariable but a = 2 doesn't. This is probably because, a is not used but directly replaced. I hope a = 2 calls setVariable...

Thanks a lot.
Regards,
Charles

2009/10/29 Jochen Theodorou <blackdrag@...>
Charles Souillard schrieb:

Hi,

my problem is that I am not the bean owner/writer... My variables are defined by an external user so I only have the value (extends Serializable)...
I was looking for a mechanism from Grovvy which can notify me of all varaibles that have been modified. Is this available ?

If not, the only way I know is to iterate over all my initial variables and propagate the new value to my repository... This could generate a big overload as only a small part of my variables may have changed...

I have a small understanding problem... a=1 changes the variable a. a.b=1 gets the value for the variable a and then sets the property b on that variable to 1. Here a is not changed, the contents of a are. The Binding does not record the contents. You need that as well? That can be done through the binding as well, but is a bit more complicated, since then you have to provide some recording dummy objects.


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




Re: Groovy variables management

by Charles Souillard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jochen,

can you give me a link where the complex binding you told about is described ?

Thanks a lot
Charles

2009/10/30 Charles Souillard <charles.souillard@...>
This is exactly  what I need !!! Can you give me an example of such a Binding ? Or some guidelines ?

In addition, I have seen that a.b = 2 calls getVariable but a = 2 doesn't. This is probably because, a is not used but directly replaced. I hope a = 2 calls setVariable...

Thanks a lot.
Regards,
Charles

2009/10/29 Jochen Theodorou <blackdrag@...>
Charles Souillard schrieb:

Hi,

my problem is that I am not the bean owner/writer... My variables are defined by an external user so I only have the value (extends Serializable)...
I was looking for a mechanism from Grovvy which can notify me of all varaibles that have been modified. Is this available ?

If not, the only way I know is to iterate over all my initial variables and propagate the new value to my repository... This could generate a big overload as only a small part of my variables may have changed...

I have a small understanding problem... a=1 changes the variable a. a.b=1 gets the value for the variable a and then sets the property b on that variable to 1. Here a is not changed, the contents of a are. The Binding does not record the contents. You need that as well? That can be done through the binding as well, but is a bit more complicated, since then you have to provide some recording dummy objects.


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





Re: Groovy variables management

by Guillaume Laforge-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Salut Charles,

There's no example available online, AFAIK, but the idea is to have a
binding that return some kind of proxy object.
So let's say you access a.b.c = 2.
First of all, Groovy will retrieve a from the binding.
So *that* a should be a kind of proxy, that records what's called on it.
So it records that you want to call b on a, and that can return itself
or another proxy, that then gets a call to c on itself.
So you record everything.
And on that proxy, to intercept those calls, override
get/setProperty(), like our previous suggestions for the binding.

Does it sound a bit clearer?

Guillaume

On Mon, Nov 2, 2009 at 08:49, Charles Souillard
<charles.souillard@...> wrote:

> Hi Jochen,
>
> can you give me a link where the complex binding you told about is described
> ?
>
> Thanks a lot
> Charles
>
> 2009/10/30 Charles Souillard <charles.souillard@...>
>>
>> This is exactly  what I need !!! Can you give me an example of such a
>> Binding ? Or some guidelines ?
>>
>> In addition, I have seen that a.b = 2 calls getVariable but a = 2 doesn't.
>> This is probably because, a is not used but directly replaced. I hope a = 2
>> calls setVariable...
>>
>> Thanks a lot.
>> Regards,
>> Charles
>>
>> 2009/10/29 Jochen Theodorou <blackdrag@...>
>>>
>>> Charles Souillard schrieb:
>>>>
>>>> Hi,
>>>>
>>>> my problem is that I am not the bean owner/writer... My variables are
>>>> defined by an external user so I only have the value (extends
>>>> Serializable)...
>>>> I was looking for a mechanism from Grovvy which can notify me of all
>>>> varaibles that have been modified. Is this available ?
>>>>
>>>> If not, the only way I know is to iterate over all my initial variables
>>>> and propagate the new value to my repository... This could generate a big
>>>> overload as only a small part of my variables may have changed...
>>>
>>> I have a small understanding problem... a=1 changes the variable a. a.b=1
>>> gets the value for the variable a and then sets the property b on that
>>> variable to 1. Here a is not changed, the contents of a are. The Binding
>>> does not record the contents. You need that as well? That can be done
>>> through the binding as well, but is a bit more complicated, since then you
>>> have to provide some recording dummy objects.
>>>
>>> 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
>>>
>>>
>>
>
>



--
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 variables management

by Charles Souillard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I manage to have something working well...
A big thank to you for your quick and detailed help.

Regards,
Charles

2009/11/2 Guillaume Laforge <glaforge@...>
Salut Charles,

There's no example available online, AFAIK, but the idea is to have a
binding that return some kind of proxy object.
So let's say you access a.b.c = 2.
First of all, Groovy will retrieve a from the binding.
So *that* a should be a kind of proxy, that records what's called on it.
So it records that you want to call b on a, and that can return itself
or another proxy, that then gets a call to c on itself.
So you record everything.
And on that proxy, to intercept those calls, override
get/setProperty(), like our previous suggestions for the binding.

Does it sound a bit clearer?

Guillaume

On Mon, Nov 2, 2009 at 08:49, Charles Souillard
<charles.souillard@...> wrote:
> Hi Jochen,
>
> can you give me a link where the complex binding you told about is described
> ?
>
> Thanks a lot
> Charles
>
> 2009/10/30 Charles Souillard <charles.souillard@...>
>>
>> This is exactly  what I need !!! Can you give me an example of such a
>> Binding ? Or some guidelines ?
>>
>> In addition, I have seen that a.b = 2 calls getVariable but a = 2 doesn't.
>> This is probably because, a is not used but directly replaced. I hope a = 2
>> calls setVariable...
>>
>> Thanks a lot.
>> Regards,
>> Charles
>>
>> 2009/10/29 Jochen Theodorou <blackdrag@...>
>>>
>>> Charles Souillard schrieb:
>>>>
>>>> Hi,
>>>>
>>>> my problem is that I am not the bean owner/writer... My variables are
>>>> defined by an external user so I only have the value (extends
>>>> Serializable)...
>>>> I was looking for a mechanism from Grovvy which can notify me of all
>>>> varaibles that have been modified. Is this available ?
>>>>
>>>> If not, the only way I know is to iterate over all my initial variables
>>>> and propagate the new value to my repository... This could generate a big
>>>> overload as only a small part of my variables may have changed...
>>>
>>> I have a small understanding problem... a=1 changes the variable a. a.b=1
>>> gets the value for the variable a and then sets the property b on that
>>> variable to 1. Here a is not changed, the contents of a are. The Binding
>>> does not record the contents. You need that as well? That can be done
>>> through the binding as well, but is a bit more complicated, since then you
>>> have to provide some recording dummy objects.
>>>
>>> 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
>>>
>>>
>>
>
>



--
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