Grails Config Annotation Plugin

  • Tags: /
  • Latest: 1.1
  • Last Updated: 14 September 2013
  • Grails version: 2.0 > *
1 vote
Dependency:
compile ":config-annotation:1.1"

 Documentation  Source  Issues

Summary

This plugin adds `@GrailsConfig` annotation that gives you simple way toinject config value into your beans (services, controllers, tagLibs and etc.)

Installation

compile ":config-annotation:1.1"

Description

It's sad but I don't recommend you to use current version of plugin (1.1) on heavy load - it affects performance because of prototype nature of Grails controllers. It should be completely refactored to fix performance issue

This plugin simplifies process of using config value in your Spring beans (controllers, services, taglibs and etc.). It adds @GrailsConfig annotation that gives you simple way to inject config value into your beans.

Let's check how you can use config value now:

import grails.util.Holders

import javax.annotation.PostConstruct

class MyService {

private myVariable

@PostConstruct private setUp() { myVariable = Holders.config.app.myVariable }

void doSomeCoolStuff() { println myVariable }

}

Not so bad. But with this plugin you can do it even simpler way:

import ru.grails.config.GrailsConfig

class MyService {

@GrailsConfig("app.myVariable") private myVariable

void doSomeCoolStuff() { println myVariable }

}

This plugin supports grails run-app mode so you shouldn't restart your application to update config value!

Pls check documentation for more info and samples

2013.09.14: Version 1.1