Thanks a lot Bertrand, your answer really pointed me in the right direction.
What I did, I created .ConfigService.xml for each of my running modes, which looks like this:
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="sling:OsgiConfig" myconfig.config="{String}My Value"/>
Then in my ConfigService it was like this:
@Component(immediate = true, metatype = true) @Service(ConfigService.class) public class ConfigService { private Dictionary<String, String> properties; @SuppressWarnings("unchecked") protected void activate(ComponentContext context) { properties = context.getProperties(); } protected void deactivate(ComponentContext context) { properties = null; } public String getProperty(String key) { return properties.get(key); } }
Than I just use ConfigService if I need to get a configuration property that accesses it using @Reference.
I hope this can help someone!
source share