如何从另一个grails插件配置grails插件 [英] How to configure a grails plugin from another grails plugin

查看:89
本文介绍了如何从另一个grails插件配置grails插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个插件,可以在几个Grails应用程序中重用。
插件应该基本上是弹簧安全核心和ldap的包装插件。



这意味着它应该包含:


  • 用户/角色

  • Spring安全配置(映射到这些域类,一些默认的URL访问角色配置)


    我的问题是我无法获得我的插件中的配置工作。我对目前为止发现的例子感到困惑:有时我读到配置应该简单地转到Config.groovy,但是 grails docs 声明这个文件最终不是插件的一部分。在一些例子中,它说你必须把配置放在任何其他的.groovy文件中,并用如下的标识符来包装:

      myConfigName {
    //正常配置在这里
    }

    然后加载它在MyWrapperPlugin.groovy类的 doWithSpring 闭包中通过一些slurper。但是,如果我正确理解这一点,这只会将配置放置在 grails.plugin.mywrapper 名称空间中。



    我找不到任何试图达到同样目的的例子(在另一个插件中设置插件的配置)。



    赞赏任何示例/提示,谢谢!

    解决方案

    您可以使用 Grails Platform Core
    $ b


    提供了插件用于实现彼此更大集成的功能,与应用程序


    配置API ,这是你在找什么。只需将doWithConfig添加到插件描述符文件(* GrailsPlugin.groovy)中即可:

      def doWithConfig = {config  - > 
    application {
    grails.plugins.springsecurity.ldap.active = true
    ...
    }
    }


    I am trying to write a plugin which I can reuse in several grails applications. The plugin should basically be a wrapper for the spring security core and the ldap plugin.

    Which means it should contain:

    • The domain classes for the user/roles
    • The configuration for spring security (the mapping to these domain classes, some default URL access role configuration)

    My problem is that i can't get the configuration inside my plugin working. I am confused by the examples I found so far: sometimes I read that the configuration should simply go to "Config.groovy" however grails docs state that this file isn't part of a plugin in the end. In some examples it says that you have to put the configuration in any other .groovy file and wrap it with some identifier like so:

    myConfigName {
        // normal config here
    }
    

    and then load it in the doWithSpring closure in the MyWrapperPlugin.groovy class via some slurper. However if i understand this correctly, this will only put the configuration in a grails.plugin.mywrapper namespace.

    I could not find any example which tries to achieve the same thing (setting the configuraiton of a plugin inside another plugin) up to now.

    Any examples/hints are appreciated, thanks!

    解决方案

    You can use the Grails Platform Core that

    provides functionality for plugins to use to achieve greater integration with each other and with applications

    The Configuration API it's what you are looking for. Just add the doWithConfig in your plugin descriptor file (*GrailsPlugin.groovy):

    def doWithConfig = { config ->
      application {
        grails.plugins.springsecurity.ldap.active=true
        ...
      }
    }
    

    这篇关于如何从另一个grails插件配置grails插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆