beforeInterceptor added from plugin

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

beforeInterceptor added from plugin

by ihery :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'd like to add a "pre-action" behavior from a new grails plugin that
would look at all my controllers during startup. However I would like to
avoid extending a base controller (that would define the
beforeInterceptor logic) to keep my controllers untuched.

Here is my question : is it possible in a grails plugin to dynamically
add a "beforeInterceptor" to some actions. Can I use
doWithDynamicMethods for that purpose ?

Thanks,

--
..........................................................
Ismaël Héry
Architecte
OCTO Technology
 ..........................................................
50, Avenue des Champs-Elysées
75008 Paris
Tél : (33) 1 58 56 10 00
Fax : (33) 1 58 56 10 01
GSM : (33) 6 12 88 02 15
www.octo.com
...........................................................



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

    http://xircles.codehaus.org/manage_email


Re: beforeInterceptor added from plugin

by Peter Ledbrook :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 18/08/07, Ismaël Héry <ihery@...> wrote:

> Hello,
>
> I'd like to add a "pre-action" behavior from a new grails plugin that
> would look at all my controllers during startup. However I would like to
> avoid extending a base controller (that would define the
> beforeInterceptor logic) to keep my controllers untuched.
>
> Here is my question : is it possible in a grails plugin to dynamically
> add a "beforeInterceptor" to some actions. Can I use
> doWithDynamicMethods for that purpose ?
>
> Thanks,

Probably. The intention is to use Groovy-AOP for this, but as far as I
am aware, no one has tried it yet for this kind of thing. Check it out
here:

  http://chanwit.blogspot.com/search/label/Groovy

Cheers,

Peter

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

    http://xircles.codehaus.org/manage_email


Re: beforeInterceptor added from plugin

by Peter Mondlock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've tried adding afterInterceptors programmatically, and I didn't get
too far. It looks like Grails Controllers are stored as instances of
Spring's BeanWrapper. Since BeanWrapper doesn't know anything about
the metaClass, if an interceptor doesn't exist during compilation, the
BeanWrapper's isReadableProperty() for the interceptor will always be
false.

Check org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
line 235 to see what's happening there.

-Peter


On 8/18/07, Peter Ledbrook <peter@...> wrote:

> On 18/08/07, Ismaël Héry <ihery@...> wrote:
> > Hello,
> >
> > I'd like to add a "pre-action" behavior from a new grails plugin that
> > would look at all my controllers during startup. However I would like to
> > avoid extending a base controller (that would define the
> > beforeInterceptor logic) to keep my controllers untuched.
> >
> > Here is my question : is it possible in a grails plugin to dynamically
> > add a "beforeInterceptor" to some actions. Can I use
> > doWithDynamicMethods for that purpose ?
> >
> > Thanks,
>
> Probably. The intention is to use Groovy-AOP for this, but as far as I
> am aware, no one has tried it yet for this kind of thing. Check it out
> here:
>
>   http://chanwit.blogspot.com/search/label/Groovy
>
> Cheers,
>
> Peter
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

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

    http://xircles.codehaus.org/manage_email