Last active
October 15, 2015 22:50
-
-
Save biancarosa/19c9cac8f6db52113b9b to your computer and use it in GitHub Desktop.
MyPluginGrailsPlugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grails.util.Environment | |
class MyGrailsPlugin { | |
/* plugin definitions */ | |
def doWithSpring = { | |
loadPluginConfig(application.config) | |
} | |
/** | |
* Loads the asynchronous mail configuration. | |
* | |
* 1. Loads the grails configuration. | |
* 2. Merges it with the default plugin configuration. | |
* 3. Merges it with the user plugin configuration. | |
*/ | |
private void loadPluginConfig(def config) { | |
GroovyClassLoader classLoader = new GroovyClassLoader(getClass().classLoader) | |
// merging default config into main application config | |
config.merge(new ConfigSlurper(Environment.current.name).parse( | |
classLoader.loadClass("DefaultMyPluginConfig")) | |
) | |
// merging user-defined config into main application config if provided | |
try { | |
config.merge(new ConfigSlurper(Environment.current.name).parse( | |
classLoader.loadClass("MyPluginConfig")) | |
) | |
} catch (Exception ignored) { | |
// ignore, just use the defaults | |
} | |
} | |
/* other methods */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment