More 2.0 ideas

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

More 2.0 ideas

Pascal DeMilly (Groovy)
What about calling a post initialization method after a bean creation

class MyBean {
        def name
        def street
        def city
        def state
        def zip

        def postInitialization () {
                assert name != null
                assert street != null
                assert city != null
                assert state != null
                assert zip != null
        }
}

def mybean = new MyBean (
        name:'George Washington',
        street:'1600 Pennsylvania Ave.'
)

Caught: java.lang.AssertionError: Expression: (city != null). Values: city =
null
        at MyBean.postInitialization(testPostInitialization.groovy:11)

such mechanism would help making sure a bean is properly initialized without
requiring an explicit call to postInitialization.

Another cool feature could be to be notified when a property is changed. This
would make binders easy to use.

Just a thought

Pascal

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: More 2.0 ideas

Pascal DeMilly (Groovy)
Actually a more general idea would be to include Aspect weaving into
Groovy with some out of the box aspects like bean instantiation (a la
spring) and property change support.

On Tuesday 16 January 2007 16:13, Pascal DeMilly wrote:

> What about calling a post initialization method after a bean
> creation
>
> class MyBean {
> def name
> def street
> def city
> def state
> def zip
>
> def postInitialization () {
> assert name != null
> assert street != null
> assert city != null
> assert state != null
> assert zip != null
> }
> }
>
> def mybean = new MyBean (
> name:'George Washington',
> street:'1600 Pennsylvania Ave.'
> )
>
> Caught: java.lang.AssertionError: Expression: (city != null).
> Values: city = null
>         at
> MyBean.postInitialization(testPostInitialization.groovy:11)
>
> such mechanism would help making sure a bean is properly
> initialized without requiring an explicit call to
> postInitialization.
>
> Another cool feature could be to be notified when a property is
> changed. This would make binders easy to use.
>
> Just a thought
>
> Pascal

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

    http://xircles.codehaus.org/manage_email