Hi,

On 13.10.2010 14:50, LongkerDandy wrote:
> Hi
> 
> Try to using FileInstall and ConfigAdmin together.
> I can read the config properties from ConfigAdmin,
> But I have problem to write it back.
> Both FileInstall .cfg file and ConfigAdmin cache .config filw won't update.

Yes and no: Yes, FileInstall will not currently write back changes.
There is an enhancement request for this
(https://issues.apache.org/jira/browse/FELIX-2571).

But the ConfigurationAdmin internal persistance file is certainly
written back. But this is not your consumption ;-)

> My code is like:
> 
>             Configuration config =
> configAdmin.getConfiguration("xxx.xxx.xxx.xxx");
>             props = config.getProperties();
>             props = new Hashtable();

Beware: I suggest you only create a new Hashtable() if getProperties()
returns null (if the configuration is new). For an existing
configuration, I would rather just update the modified properties.

Regards
Felix

>             props.put("xxx", "xxx");
>             config.update(props);
> 
> Any clue?
> 
> Thanks
> LongkerDandy
> 
> 
> On Wed, Oct 13, 2010 at 3:21 PM, Felix Meschberger <[email protected]>wrote:
> 
>> Hi,
>>
>> Just to clarify what the OSGi Configuration Admin Service is all about:
>>
>>  - Allows Management Agents (administrators, tools, whatever) to manage
>>    configuration
>>  - Delivers configuration to interested parties
>>  - Persistently stores configuration
>>
>> A Configuration basically is just a Dictionary whose keys are strings
>> (case-insensitive) and whose values are of a limited set of types,
>> basically primitive types, their wrappers plus Collections or Arrays
>> thereof. (For the OSGi R 4.3 release it is planed to have more
>> interesting ways to describe configuration....)
>>
>> Back to your question: Yes you can use Configuration Admin for your
>> configuration and yes you can put into the configuration whatever you want.
>>
>> To manage configuration you have a number of tools at your disposal:
>>
>>  - Use the Web Console allowing for a simple GUI to configure values
>>     (makes use of the Metatype Service to describe configurations)
>>  - Use File Install to provide preconfigured configuration files to
>>     be loaded into the Configuration Admin service automatically.
>>     This tool also recognizes changes to files and thus updates
>>     configuration.
>>  - Do it yourself coding an application using the Configuration Admin
>>     Service API...
>>
>> IIRC the configuration files processed by File Install are more or less
>> pure property files.
>>
>> Regards
>> Felix
>>
>> On 13.10.2010 09:05, Christian Schneider wrote:
>>>  Hi,
>>>
>>> I am currently also evaluating the config admin service. I ported a
>>> spring application to osgi and now have the problem where to put the
>>> properties files. The property files contain db and jms connection infos.
>>> Is config admin service the right tool for this job?
>>>
>>> I already succeeded in creating the config programmatically and using it
>>> in spring with help of the spring osgi config admin support. As
>>> implementation I used the felix cm bundle. What I do not like is that
>>> the persisted files contain additional information compared to the
>>> normal property files. So it is quite difficult to create and change
>>> them by hand. If I only put the original properties into the file I even
>>> get a nullpointer exception.
>>> Is it possible to conffigure felix cm to work with pure propety files
>>> that do not contain additional information or would you recommand
>>> another aproach?
>>>
>>> Thanks
>>>
>>> Christian
>>>
>>>
>>> Am 13.10.2010 08:14, schrieb Felix Meschberger:
>>>> Hi,
>>>>
>>>> On 13.10.2010 05:55, LongkerDandy wrote:
>>>>> Hi
>>>>>
>>>>> I'm try to use ConfigAdmin to save and load configurations.
>>>>> The default place of the configurations is under the cache folder and
>>>>> deep
>>>>> into the ConfigAdmin bundle.
>>>>>
>>>>> I don't know it is designed like this.
>>>> Yes, the default location is the bundle private data area provided by
>>>> the framework through the BundleContext.getDataFile(String) method.
>>>>
>>>>> I should suppose to have some pre-defined configuration values,
>>>>> And when I deliver my software there is no cache folder, how can I put
>> i
>>>>> into this.
>>>>>
>>>>> I try to change the configuration location to the felix/conf folder
>> like
>>>>> this:
>>>>> felix.cm.dir=../../../conf
>>>>>
>>>>> But it complains about ".." reference.
>>>>>
>>>>> I also wondered if I can use the default "config.properties" with
>>>>> ConfigAdmin
>>>> You can use and you can change the setup.
>>>>
>>>> BUT: This is not to inject default configuration. This data area must be
>>>> configured private to the Configuration Admin service because changes
>>>> are expected to only be carried out by the Configuration Admin service.
>>>>
>>>> If you want to provide "default" configuration you might want to
>>>> consider FileInstall and provide respective .cfg files. See [1] for more
>>>> details.
>>>>
>>>> Hope this helps.
>>>>
>>>> Regards
>>>> Felix
>>>>
>>>> [1] http://felix.apache.org/site/apache-felix-file-install.html
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to