Created
August 21, 2012 01:22
-
-
Save ck1125/3410284 to your computer and use it in GitHub Desktop.
propertysource extension
This file contains hidden or 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
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