Sorry, I just re-read your email and what I think you are asking might
be if you can extend the functionality of a plugin.
The answer that has been given before is to contact the originator of
the plugin first before committing changes and re-releasing the plugin.
If you want to add functionality to a plugin, that is great.
My understanding is that plugins in the Grails repo are open-source and
as such are open to modification by the community. I have released
three plugins so far and am very happy for others to extend them.
I also made changes to my AOPish example to include methods with
arguments. I figured my last example was probably too simple.
Again, not a Groovy expert, but here it is.
// Plugin code
class A {
def meth(String s) {
println s
}
}
// method before modification
new A().meth("Hello") // prints 'hello'
// My code
A.metaClass.oldMeth = A.metaClass.getMetaMethod('meth',[String] as Object[])
A.metaClass.meth = { String s ->
oldMeth.doMethodInvoke(delegate, ["${s} World!"] as Object[])
}
// code using plugin
new A().meth("Hello") // prints 'Hello World!'
On Sun, 2009-07-05 at 10:07 -0700, altosz wrote:
> So I should create my own plugin which is loaded after the original plugin
> and there override the functionality I need?
>
> But still is it possible to override the functionality of the plugins not
> messing with other plugins? Just in the application structure. And if it is
> ok I should better create a patch to the plugin then issue another one.
>
>
>
> nycsailor wrote:
> >
> > Is it possible with what you want to do, that you can create a plugin
> > that modifies the other plugin through MetaProgramming. Groovy is very
> > flexible when it comes to modifying objects and classes and grails
> > allows you to specify plugins that need to be loaded before yours.
> >
> > I'm not sure what you want to do, but this might be the easiest.
> >
> > On Sun, 2009-07-05 at 09:36 -0700, altosz wrote:
> >> Good day, Grails and plugin developers,
> >>
> >> I've encountered the following question when developing an app. I have a
> >> plugin and would like to override (expand) it functionality. How should
> >> it
> >> be done?
> >>
> >> 1. Is it possible to create the same class in app plugin folder? Whould
> >> it
> >> override the same class of the plugin?
> >> 2. Or the only way is to modify plugin code?
> >>
> >> --
> >> Regards,
> >> Alexei
> >
> >
> > ---------------------------------------------------------------------
> > 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