Rewiring dynamic methods

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

Rewiring dynamic methods

Jon Brisbin-2
I'm writing a plugin that I'd like to use a builder with in controllers and services. It appears I have to choose which method of access I prefer to have, either the dot notation (builder.myoperation(){}) or the DSL notation (builder { myoperation(){} }) but it doesn't look like I can do both. Am I wrong here?

I've added this to my plugin (in doWithDynamicMethods):

    application.controllerClasses.each {
      it.metaClass.riak = { Closure cl -> doWithRiak(ctx, cl) }
    }
    application.serviceClasses.each {
      it.metaClass.riak = { Closure cl -> doWithRiak(ctx, cl) }
    }

Which works great for the DSL notation until my app is reloaded. Even though I have code in the onChange to reset this on the metaClass, it seems to be getting an error of some kind because the method is never available after a reload.

Any suggestions on what I'm doing wrong here?

Jon Brisbin
Portal Webmaster
NPC International, Inc.

Twitter: @j_brisbin
Skype: jon.brisbin


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Rewiring dynamic methods

Jeff Scott Brown
On Tue, Dec 28, 2010 at 12:00 PM, Jon Brisbin
<[hidden email]> wrote:
>
>
> Which works great for the DSL notation until my app is reloaded. Even though I have code in the onChange to reset this on the metaClass, it seems to be getting an error of some kind because the method is never available after a reload.
>
> Any suggestions on what I'm doing wrong here?

Has your plugin expressed that it wants to observe the controller plugin?



jb

--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Rewiring dynamic methods

Jeff Scott Brown
On Tue, Dec 28, 2010 at 12:07 PM, Jeff Brown <[hidden email]> wrote:

> On Tue, Dec 28, 2010 at 12:00 PM, Jon Brisbin
> <[hidden email]> wrote:
>>
>>
>> Which works great for the DSL notation until my app is reloaded. Even though I have code in the onChange to reset this on the metaClass, it seems to be getting an error of some kind because the method is never available after a reload.
>>
>> Any suggestions on what I'm doing wrong here?
>
> Has your plugin expressed that it wants to observe the controller plugin?
>

Since you are dealing with controllers and services, you probably want
to observe each of those plugins...

def observe = ['controllers', 'services']

Does that help?




jb

--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Rewiring dynamic methods

Jon Brisbin-2
Arg.

I had "observes" (plural).

Changed it to "observe" (singular) and it magically works! ;)

I thought I was on the right track and couldn't figure out what I was doing wrong.

Thanks for the help!

jb


On Dec 28, 2010, at 12:11 PM, Jeff Brown wrote:

> On Tue, Dec 28, 2010 at 12:07 PM, Jeff Brown <[hidden email]> wrote:
>> On Tue, Dec 28, 2010 at 12:00 PM, Jon Brisbin
>> <[hidden email]> wrote:
>>>
>>>
>>> Which works great for the DSL notation until my app is reloaded. Even though I have code in the onChange to reset this on the metaClass, it seems to be getting an error of some kind because the method is never available after a reload.
>>>
>>> Any suggestions on what I'm doing wrong here?
>>
>> Has your plugin expressed that it wants to observe the controller plugin?
>>
>
> Since you are dealing with controllers and services, you probably want
> to observe each of those plugins...
>
> def observe = ['controllers', 'services']
>
> Does that help?
>
>
>
>
> jb
>
> --
> Jeff Brown
> SpringSource
> http://www.springsource.com/
>
> Autism Strikes 1 in 166
> Find The Cause ~ Find The Cure
> http://www.autismspeaks.org/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


Jon Brisbin
Portal Webmaster
NPC International, Inc.

Twitter: @j_brisbin
Skype: jon.brisbin


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

    http://xircles.codehaus.org/manage_email