[
https://issues.apache.org/jira/browse/KARAF-5843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jean-Baptiste Onofré resolved KARAF-5843.
-----------------------------------------
Resolution: Not A Problem
Fix Version/s: (was: 4.1.7)
(was: 4.2.1)
That's the expected behavior.
If you use {{ConfigAdmin}} only, the {{Configuration}} is stored in memory and
in the framework cache. If you want to store the configuration in the
{{karaf.etc}}, than you have to use Karaf Config {{ConfigRepository}} service.
So you have to do something like:
{code}
<reference id="configRepository"
interface="org.apache.karaf.config.core.ConfigRepository"/>
{code}
Then, you use the {{ConfigRepository}} service like:
{code}
configRepository.update("my.pid", props);
{code}
The {{ConfigRepository}} service is dedicated to manipulating the config in
{{karaf.etc}}.
> Programmatically Created Configs are not persisted in `karaf.etc`
> -----------------------------------------------------------------
>
> Key: KARAF-5843
> URL: https://issues.apache.org/jira/browse/KARAF-5843
> Project: Karaf
> Issue Type: Bug
> Components: karaf-config
> Affects Versions: 4.1.5
> Reporter: Cetra Free
> Assignee: Jean-Baptiste Onofré
> Priority: Major
>
> When using OSGi's ConfigurationAdmin via a blueprint bean, it doesn't save
> the configuration in the `etc` directory if the file doesn't exist before
> calling {{update(props)}}.
> Rather it saves it in the file cache.
> I.e, if I update a config of `com.example.config` I'd expect that to be
> persisted in the following location:
> {code:java}
> etc/com.example.config.cfg
> {code}
> Instead, I see it in this location:
> {code:java}
> data/cache/bundle8/data/config/com/example/config.config
> {code}
> If the file exists in the location beforehand, this appears to work OK.
> Example blueprint:
> {code:xml}
> <reference id="configurationAdmin"
> interface="org.osgi.service.cm.ConfigurationAdmin"/>
> <bean id="persistCheck" class="com.example.PersistCheck" init-method=" init" >
> <property name="configurationAdmin" ref="configurationAdmin" />
> </bean>
> {code}
> Example Java Class:
> {code:java}
> import org.osgi.service.cm.Configuration;
> import org.osgi.service.cm.ConfigurationAdmin;
> import java.io.IOException;
> import java.util.Dictionary;
> import java.util.Hashtable;
> public class PersistCheck {
> public ConfigurationAdmin getConfigurationAdmin() {
> return configurationAdmin;
> }
> public void setConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
> this.configurationAdmin = configurationAdmin;
> }
> ConfigurationAdmin configurationAdmin;
> public void init() throws IOException {
> Configuration configuration =
> configurationAdmin.getConfiguration("com.example.config", "?");
> Dictionary<String, Object> props = new Hashtable<>();
> configuration.update(props);
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)