Plugins and their default configuration

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

Plugins and their default configuration

Daniel Henrique Alves Lima
   Hi, everybody. Please let me know if I should post this message in
the user mailing list instead.

   What do you think of providing a mechanism to merge the plugin
default configuration into grailsApplication.config? For example,
suppose that the plugin X has some defaults stored in
grails-app/conf/XConfig.groovy. Then when
org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper.loadConfigFromClasspath

get called, the default configuration will automatically be merged into
the main configuration.

   Using SSC as example, its default configuration will be stored in
grails-app/conf/SpringSecurityCoreConfig.groovy (or
SpringSecurityCoreDefaultConfig.groovy):

        grails{            
            plugins{                
                springsecurity
{                                                
                    /** misc properties */
                   
                    active = true
                   
                    ajaxHeader = 'X-Requested-With'
                   
                    registerLoggerListener = false
                   
                    // 'strict' mode where an explicit grant is required
to access any resource;
                    // if true make sure to allow
IS_AUTHENTICATED_ANONYMOUSLY
                    // for /, /js/**, /css/**, /images/**, /login/**,
/logout/**, etc.
                    rejectIfNoRule = false

                    // (...)
                }
            }      
        }


Suppose now that the user have  defined Config.groovy in this way:

// (...)
grails.plugins.springsecurity.rejectIfNoRule = true


After the automatic merge, the plugin or the application will "see" the
following *unified* configuration:

      grails{            
           plugins{                
               springsecurity
{                                                
                   /** misc properties */
                   
                   active = true
                   ajaxHeader = 'X-Requested-With'
                   registerLoggerListener = false
                   rejectIfNoRule = true // user overriden

                   // (...)
               }
           }      
       }

    It is something similar to the automatic inclusion of XConfig.groovy
or XDefaultConfig.groovy to grails.config.locations.

    Does it make any sense?

    Best regards,

        Daniel.


 


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
    Sorry for the indentation of the source code.

http://pastie.org/2193744

http://pastie.org/2193752

Daniel Henrique Alves Lima wrote:
>  
(...)

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

rlovtangen
In reply to this post by Daniel Henrique Alves Lima

On Jul 10, 2011, at 11:21 PM, Daniel Henrique Alves Lima wrote:

>  Hi, everybody. Please let me know if I should post this message in the user mailing list instead.
>
>  What do you think of providing a mechanism to merge the plugin default configuration into grailsApplication.config? For example,
> suppose that the plugin X has some defaults stored in grails-app/conf/XConfig.groovy. Then when org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper.loadConfigFromClasspath
> get called, the default configuration will automatically be merged into the main configuration.
>
>  Using SSC as example, its default configuration will be stored in grails-app/conf/SpringSecurityCoreConfig.groovy (or SpringSecurityCoreDefaultConfig.groovy):
>
>       grails{                       plugins{                               springsecurity {                                                                   /** misc properties */
>                                      active = true
>                                      ajaxHeader = 'X-Requested-With'
>                                      registerLoggerListener = false
>                                      // 'strict' mode where an explicit grant is required to access any resource;
>                   // if true make sure to allow IS_AUTHENTICATED_ANONYMOUSLY
>                   // for /, /js/**, /css/**, /images/**, /login/**, /logout/**, etc.
>                   rejectIfNoRule = false
>
>                   // (...)
>               }
>           }             }
>
>
> Suppose now that the user have  defined Config.groovy in this way:
>
> // (...)
> grails.plugins.springsecurity.rejectIfNoRule = true
>
>
> After the automatic merge, the plugin or the application will "see" the following *unified* configuration:
>
>     grails{                      plugins{                              springsecurity {                                                                  /** misc properties */
>                                    active = true
>                  ajaxHeader = 'X-Requested-With'
>                  registerLoggerListener = false
>                  rejectIfNoRule = true // user overriden
>
>                  // (...)
>              }
>          }            }
>
>   It is something similar to the automatic inclusion of XConfig.groovy or XDefaultConfig.groovy to grails.config.locations.
>
>   Does it make any sense?
>

Yes! This is very welcome. Something I was really surprised Grails didn't do already, when I changed one of my applications to use a plugin based architecture.

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
In reply to this post by Daniel Henrique Alves Lima
    In this way, if my plugin depends on SCC default config
(https://github.com/daniel-lima/grails-spring-security-core/blob/master/grails-app/conf/DefaultSecurityConfig.groovy),
I won't need to know which class should I load or which config file
should I parse. All the required configuration will be merged into the
the main config.

    What do you think?
>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

ld@ldaley.com

On 11/07/2011, at 7:34 AM, Daniel Henrique Alves Lima wrote:

>   In this way, if my plugin depends on SCC default config (https://github.com/daniel-lima/grails-spring-security-core/blob/master/grails-app/conf/DefaultSecurityConfig.groovy), I won't need to know which class should I load or which config file should I parse. All the required configuration will be merged into the the main config.
>
>   What do you think?

This has been raised before many times, and every time we get to a point where we hit a tricky issue and then the discussion stops. For the life of me, I can't think of what the issue(s) were now.


There's a glaring hole for plugins providing default configuration and a lot of plugins do this manually. I'm in favour of a conventional support being added here.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

basejump (Josh)
+1
It seems like the wheel has been re-invented a number of ways in a number of plugins and it certainly would be very nice to have "standard" way of doing this.

On Jul 10, 2011, at 6:57 PM, Luke Daley wrote:

>
> On 11/07/2011, at 7:34 AM, Daniel Henrique Alves Lima wrote:
>
>>  In this way, if my plugin depends on SCC default config (https://github.com/daniel-lima/grails-spring-security-core/blob/master/grails-app/conf/DefaultSecurityConfig.groovy), I won't need to know which class should I load or which config file should I parse. All the required configuration will be merged into the the main config.
>>
>>  What do you think?
>
> This has been raised before many times, and every time we get to a point where we hit a tricky issue and then the discussion stops. For the life of me, I can't think of what the issue(s) were now.
>
>
> There's a glaring hole for plugins providing default configuration and a lot of plugins do this manually. I'm in favour of a conventional support being added here.
> ---------------------------------------------------------------------
> 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


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Sebastian Gozin
This is indeed a wheel I've reinvented in that manner as well so a way to handle default configuration would be great.

As for possible issues, I know of one I ran into with one of my own implementation of a default configuration scheme.
In my plugin I would have done a simple slurper.parse(classLoader.loadClass('MyDefaultConfig')) which works fine in the functional phase or at application bootstrap but not in the integration phase. I haven't been able to figure out why yet.

To explain just how this can cause strange problems...
When running the test-app process and during the integration test phase something seems wrong with the bootstrapping to the point that some or all of the loaded configuration is just empty. Then as this bootstrapped environment appears to be reused for the following phases (e.g: functional) you may run into unexpected issues. Say if you used the fixtures plugin to create some test data based on default configuration which of course wasn't there during the integration phase.

Hope this helps to figure out what snags are preventing a real default plugin configuration scheme.

On 11 Jul 2011, at 03:08, basejump (Josh) wrote:

> +1
> It seems like the wheel has been re-invented a number of ways in a number of plugins and it certainly would be very nice to have "standard" way of doing this.
>
> On Jul 10, 2011, at 6:57 PM, Luke Daley wrote:
>
>>
>> On 11/07/2011, at 7:34 AM, Daniel Henrique Alves Lima wrote:
>>
>>> In this way, if my plugin depends on SCC default config (https://github.com/daniel-lima/grails-spring-security-core/blob/master/grails-app/conf/DefaultSecurityConfig.groovy), I won't need to know which class should I load or which config file should I parse. All the required configuration will be merged into the the main config.
>>>
>>> What do you think?
>>
>> This has been raised before many times, and every time we get to a point where we hit a tricky issue and then the discussion stops. For the life of me, I can't think of what the issue(s) were now.
>>
>>
>> There's a glaring hole for plugins providing default configuration and a lot of plugins do this manually. I'm in favour of a conventional support being added here.
>> ---------------------------------------------------------------------
>> 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
>
>


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
In reply to this post by ld@ldaley.com
    Hi Luke. Hi everybody.

    It is far from useful and initial implementation is still (very)
ugly, but I'm trying to (re-)start the discussion based on something
"concrete".

    https://github.com/daniel-lima/grails-plugin-config-plugin
    (there is also an attached plugin package)

    I'm searching for something simple: Each plugin will have a
grails-app/conf/PluginClassDefaultConfig.groovy and these files will be
merged together and "in order". You will get a merged configuration
every time you access grailsApplication.mergedConfig. Of course the
ideal would be if grailsApplication.config itself could be the mergedConfig.
    I think there is no need of a new Grails Artifact, but I can be
wrong... BTW, can a plugin register a bean in the parent context of the
GrailsApplication?

    Thanks in advance.

       Best regards,

          Daniel.

Luke Daley wrote:

> On 11/07/2011, at 7:34 AM, Daniel Henrique Alves Lima wrote:
>
>  
>>   In this way, if my plugin depends on SCC default config (https://github.com/daniel-lima/grails-spring-security-core/blob/master/grails-app/conf/DefaultSecurityConfig.groovy), I won't need to know which class should I load or which config file should I parse. All the required configuration will be merged into the the main config.
>>
>>   What do you think?
>>    
>
> This has been raised before many times, and every time we get to a point where we hit a tricky issue and then the discussion stops. For the life of me, I can't think of what the issue(s) were now.
>
>
> There's a glaring hole for plugins providing default configuration and a lot of plugins do this manually. I'm in favour of a conventional support being added here.
>
>  

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

    http://xircles.codehaus.org/manage_email

grails-plugin-config-0.1.zip (16K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
    To get the idea:

https://github.com/daniel-lima/grails-plugin-config-plugin/blob/master/src/java/org/grails/plugin/config/AbstractDefaultConfigHelper.java#L75

    Feel free to add your comments.

    Thanks.

Daniel Henrique Alves Lima wrote:

>    Hi Luke. Hi everybody.
>
>    It is far from useful and initial implementation is still (very)
> ugly, but I'm trying to (re-)start the discussion based on something
> "concrete".
>
>    https://github.com/daniel-lima/grails-plugin-config-plugin
>    (there is also an attached plugin package)
>
>    I'm searching for something simple: Each plugin will have a
> grails-app/conf/PluginClassDefaultConfig.groovy and these files will
> be merged together and "in order". You will get a merged configuration
> every time you access grailsApplication.mergedConfig. Of course the
> ideal would be if grailsApplication.config itself could be the
> mergedConfig.
>    I think there is no need of a new Grails Artifact, but I can be
> wrong... BTW, can a plugin register a bean in the parent context of
> the GrailsApplication?
>
>    Thanks in advance.
>
>       Best regards,
>
>          Daniel.
>
> Luke Daley wrote:
>> On 11/07/2011, at 7:34 AM, Daniel Henrique Alves Lima wrote:
>>
>>  
>>>   In this way, if my plugin depends on SCC default config
>>> (https://github.com/daniel-lima/grails-spring-security-core/blob/master/grails-app/conf/DefaultSecurityConfig.groovy),
>>> I won't need to know which class should I load or which config file
>>> should I parse. All the required configuration will be merged into
>>> the the main config.
>>>
>>>   What do you think?
>>>    
>>
>> This has been raised before many times, and every time we get to a
>> point where we hit a tricky issue and then the discussion stops. For
>> the life of me, I can't think of what the issue(s) were now.
>>
>>
>> There's a glaring hole for plugins providing default configuration
>> and a lot of plugins do this manually. I'm in favour of a
>> conventional support being added here.
>>
>>  

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
http://grails.1312388.n4.nabble.com/ANN-Plugin-config-plugin-td3689642.html

Thanks.

Daniel Henrique Alves Lima wrote:

>    To get the idea:
>
> https://github.com/daniel-lima/grails-plugin-config-plugin/blob/master/src/java/org/grails/plugin/config/AbstractDefaultConfigHelper.java#L75 
>
>
>    Feel free to add your comments.
>
>    Thanks.
>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
http://jira.grails.org/browse/GRAILS-7775

Daniel Henrique Alves Lima wrote:

> http://grails.1312388.n4.nabble.com/ANN-Plugin-config-plugin-td3689642.html 
>
>
> Thanks.
>
> Daniel Henrique Alves Lima wrote:
>>    To get the idea:
>>
>> https://github.com/daniel-lima/grails-plugin-config-plugin/blob/master/src/java/org/grails/plugin/config/AbstractDefaultConfigHelper.java#L75 
>>
>>
>>    Feel free to add your comments.
>>
>>    Thanks.
>>
>>
>
> -

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
    Documentation updated: http://grails.org/plugin/plugin-config

    Please, let me know if I'm missing some common requirement.

    Thanks.

Daniel Henrique Alves Lima wrote:
> http://jira.grails.org/browse/GRAILS-7775
>
> Daniel Henrique Alves Lima wrote:
>> http://grails.1312388.n4.nabble.com/ANN-Plugin-config-plugin-td3689642.html 
>>
>>
>> Thanks.
>>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

pledbrook
>   Documentation updated: http://grails.org/plugin/plugin-config
>
>   Please, let me know if I'm missing some common requirement.

I'm definitely in favour of Grails automatically loading config files
containing default values. I can't see this happening in Grails core
at this stage since we're feature complete, so the plugin is a useful
alternative.

On the documentation front, I think you should recommend using the
dependency DSL for Grails 1.3.7 and above, in which case you do not
need to add it to the dependsOn property. In fact, for Grails 2
'dependsOn' will be deprecated.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

pledbrook
In reply to this post by Daniel Henrique Alves Lima
>   Documentation updated: http://grails.org/plugin/plugin-config
>
>   Please, let me know if I'm missing some common requirement.

Oh, and I would replace your plugin 'title' with something more
appropriate and but the current title in the 'description' property.

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
In reply to this post by pledbrook
        Hi Peter.

        I've asked about 'dependsOn' here:
http://grails.1312388.n4.nabble.com/Grails-2-0-0-and-deprecated-dependsOn-td3692988.html
        It doesn't appear as deprecated in beta.grails.org.

        For plugins, will the dependency DSL influence/change the
plugin load order (DefaultGrailsPluginManager.sortPlugins and etc.)?

        Thanks.



2011/7/27, Peter Ledbrook <[hidden email]>:

>>   Documentation updated: http://grails.org/plugin/plugin-config
>>
>>   Please, let me know if I'm missing some common requirement.
>
> I'm definitely in favour of Grails automatically loading config files
> containing default values. I can't see this happening in Grails core
> at this stage since we're feature complete, so the plugin is a useful
> alternative.
>
> On the documentation front, I think you should recommend using the
> dependency DSL for Grails 1.3.7 and above, in which case you do not
> need to add it to the dependsOn property. In fact, for Grails 2
> 'dependsOn' will be deprecated.
>
> Peter
>
> --
> Peter Ledbrook
> Grails Advocate
> SpringSource - A Division of VMware
>
> ---------------------------------------------------------------------
> 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


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
In reply to this post by pledbrook
        Hi Peter.

        So should the plugin title be something "similar" to the
plugin class name?

https://github.com/grails-plugins/grails-coffeescript/blob/master/CoffeescriptGrailsPlugin.groovy#L21
https://github.com/grails-plugins/grails-hibernate-plugin/blob/master/HibernateGrailsPlugin.groovy#L29
https://github.com/grails-plugins/grails-database-migration/blob/master/DatabaseMigrationGrailsPlugin.groovy#L46
https://github.com/grails-plugins/grails-spring-security-acl/blob/master/SpringSecurityAclGrailsPlugin.groovy#L90
https://github.com/grails-plugins/grails-freemarker/blob/master/FreemarkerGrailsPlugin.groovy#L43
https://github.com/grails-plugins/grails-release/blob/master/ReleaseGrailsPlugin.groovy#L28

        Is this the recommended practice?

        Thanks.



2011/7/27, Peter Ledbrook <[hidden email]>:

>>   Documentation updated: http://grails.org/plugin/plugin-config
>>
>>   Please, let me know if I'm missing some common requirement.
>
> Oh, and I would replace your plugin 'title' with something more
> appropriate and but the current title in the 'description' property.
>
> --
> Peter Ledbrook
> Grails Advocate
> SpringSource - A Division of VMware
>
> ---------------------------------------------------------------------
> 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


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

pledbrook
>        So should the plugin title be something "similar" to the
> plugin class name?

Correct. It appears as the title on the plugin portal page as well as
in the tweets and forum posts published by the Release plugin. Note
that the Grails 2.0 plugin descriptor template has more sensible
default values.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

pledbrook
In reply to this post by Daniel Henrique Alves Lima
>        I've asked about 'dependsOn' here:
> http://grails.1312388.n4.nabble.com/Grails-2-0-0-and-deprecated-dependsOn-td3692988.html

OK. So 'dependsOn' in Grails 2 will only verify that the dependencies
are installed - it doesn't affect plugin publishing and it only
affects plugin installation in that it will throw an error if a
required dependency is not installed.

That said, I now realise that you need 'dependsOn' for older versions
of Grails, so you're right to have it there.

>        It doesn't appear as deprecated in beta.grails.org.

Sorry, don't know what you mean here. In the user guide?

>        For plugins, will the dependency DSL influence/change the
> plugin load order (DefaultGrailsPluginManager.sortPlugins and etc.)?

I think it does, but I'm not 100% sure.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
In the new (beta.grails) user guide.

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Plugins and their default configuration

Daniel Henrique Alves Lima
In reply to this post by pledbrook
    I often forget to ask these (probably non dev) questions:

    1. Can a plugin have multiple authors and authorsEmail?

    author = ['John', 'Mary']
    authorEmail =['[hidden email]', '[hidden email]']

    ?

    2. How can I keep different versions of a plugin for different
versions of Grails? For example, I have one version for Grails between
1.2.0 and 1.3.7 and a different version for Grails 2.0.0+.

    grailsVersion = '1.2.0 < * < 1.3.7'
    grailsVersion = '* > 2.0.0'

    ?

    Thanks.

Peter Ledbrook wrote:

>>        So should the plugin title be something "similar" to the
>> plugin class name?
>>    
>
> Correct. It appears as the title on the plugin portal page as well as
> in the tweets and forum posts published by the Release plugin. Note
> that the Grails 2.0 plugin descriptor template has more sensible
> default values.
>
> Peter
>
>  

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

    http://xircles.codehaus.org/manage_email


12