Skip to content

Instantly share code, notes, and snippets.

@ck1125
Created August 21, 2012 01:22
Show Gist options
  • Save ck1125/3410284 to your computer and use it in GitHub Desktop.
Save ck1125/3410284 to your computer and use it in GitHub Desktop.
propertysource extension
package com.in3k8.javaconfig.config.propertysource
import org.springframework.core.env.PropertySource
import org.springframework.core.io.Resource
class GroovyConfigPropertySource extends PropertySource {
Resource resource
Map configObject = [:]
GroovyConfigPropertySource(String name,Resource resource) {
super(name)
this.resource = resource
if (new File(resource.URL.file).exists()) {
configObject << new ConfigSlurper().parse(resource.URL).flatten()
}
}
@Override
Object getProperty(String name) {
configObject.get(name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment