Re: Complex config

2017-06-15 Thread Guillaume Nodet
FileInstall is pluggable and can support additional file format.
For this, you need to register a org.apache.felix.fileinstall.
ArtifactUrlTransformer
or org.apache.felix.fileinstall.ArtifactInstaller class in the OSGi
registry.  We do leverage that in Karaf to provide support for blueprint
and spring xml files, on-the-fly jar -> bundle, kar files and feature
repositories.

This does not directly plug into the ConfigAdmin, so you'd have to do that
yourself.


2017-06-14 22:49 GMT+02:00 dynamodan <i...@dynamodan.com>:

> I found this thread because of a similar need -- I store a configuration in
> yaml format for a java application that I'm "OSGi-fying".  The flat
> dictionary isn't going to work for me, nor is the
> `${karaf.etc}/worker-config.yaml` method going to work (it won't monitor
> the
> worker-config.yaml for updates!).
>
> +jbonofre, you mentioned something about an adapter:
>
>
> jbonofre wrote
> > What do you mean exactly ? You want to load the yaml configuration in
> > ConfigAdmin ? In that case, it's possible in an adapter.
>
> That would be cool, but if it is even simpler, let's be format-agnostic,
> and
> just implement and register a ManagedService.updated() function that gets
> run any time the filesystem detects a change (along the lines of
> java.nio.file.WatchService).  Send a null java.util.Dictionary object and
> let the function sort out what changed, if anything.
>
> Thanks in advance!
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/Complex-config-tp4043584p4050746.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 

Guillaume Nodet


Re: Complex config

2017-06-14 Thread dynamodan
I found this thread because of a similar need -- I store a configuration in
yaml format for a java application that I'm "OSGi-fying".  The flat
dictionary isn't going to work for me, nor is the
`${karaf.etc}/worker-config.yaml` method going to work (it won't monitor the
worker-config.yaml for updates!).

+jbonofre, you mentioned something about an adapter:


jbonofre wrote
> What do you mean exactly ? You want to load the yaml configuration in 
> ConfigAdmin ? In that case, it's possible in an adapter.

That would be cool, but if it is even simpler, let's be format-agnostic, and
just implement and register a ManagedService.updated() function that gets
run any time the filesystem detects a change (along the lines of
java.nio.file.WatchService).  Send a null java.util.Dictionary object and
let the function sort out what changed, if anything.

Thanks in advance!



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Complex-config-tp4043584p4050746.html
Sent from the Karaf - User mailing list archive at Nabble.com.


Re: Complex config

2015-11-18 Thread Benson Margulies
On Wed, Nov 18, 2015 at 12:39 PM, Jean-Baptiste Onofré  
wrote:
> Hi Benson,
>
> It's something that we do in Decanter (with elasticsearch.yaml, but it's
> just a load), or in Cellar (with Hazelcast XML parsing), or in Pax Web (when
> refering the jetty.xml).
>
> What do you mean exactly ? You want to load the yaml configuration in
> ConfigAdmin ? In that case, it's possible in an adapter.
>
> Please, can you elaborate a bit ?

Here's what I do now, which might be the same as you:

foo.cfg
  workerConfig=${karaf.etc}/worker-config.yaml

Here's what I was wondering about: could I arrange for foo.'cfg' to
actually be a YAML file, and use Jackson to parse it so that the
 dictionaries would contain interesting objects.

Can you point me at more reading about 'adapters'? That sounds like
the line I would want to follow.




>
> Thanks,
> Regards
> JB
>
>
> On 11/18/2015 06:36 PM, Benson Margulies wrote:
>>
>> I've got some cases where I made a .cfg file point to a .yaml file
>> because I had a complex configuration. The API to config admin sort of
>> suggests that it might be possible to have more complex data
>> structures so long as the top-level is key-value; is this actually
>> doable, and, if so, how?
>>
>
> --
> Jean-Baptiste Onofré
> jbono...@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com


Re: Complex config

2015-11-18 Thread Jean-Baptiste Onofré

Hi Benson,

It's something that we do in Decanter (with elasticsearch.yaml, but it's 
just a load), or in Cellar (with Hazelcast XML parsing), or in Pax Web 
(when refering the jetty.xml).


What do you mean exactly ? You want to load the yaml configuration in 
ConfigAdmin ? In that case, it's possible in an adapter.


Please, can you elaborate a bit ?

Thanks,
Regards
JB

On 11/18/2015 06:36 PM, Benson Margulies wrote:

I've got some cases where I made a .cfg file point to a .yaml file
because I had a complex configuration. The API to config admin sort of
suggests that it might be possible to have more complex data
structures so long as the top-level is key-value; is this actually
doable, and, if so, how?



--
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


Complex config

2015-11-18 Thread Benson Margulies
I've got some cases where I made a .cfg file point to a .yaml file
because I had a complex configuration. The API to config admin sort of
suggests that it might be possible to have more complex data
structures so long as the top-level is key-value; is this actually
doable, and, if so, how?


Re: Complex config

2015-11-18 Thread Pavel E. Shirshov
Any complex structure may be flattened.

Example for HOCON: https://gist.github.com/FeiWongReed/44799f4461c43f8e83c2

On 18/11/15 17:44, Benson Margulies wrote:
> On Wed, Nov 18, 2015 at 12:39 PM, Jean-Baptiste Onofré  
> wrote:
>> Hi Benson,
>>
>> It's something that we do in Decanter (with elasticsearch.yaml, but it's
>> just a load), or in Cellar (with Hazelcast XML parsing), or in Pax Web (when
>> refering the jetty.xml).
>>
>> What do you mean exactly ? You want to load the yaml configuration in
>> ConfigAdmin ? In that case, it's possible in an adapter.
>>
>> Please, can you elaborate a bit ?
> Here's what I do now, which might be the same as you:
>
> foo.cfg
>   workerConfig=${karaf.etc}/worker-config.yaml
>
> Here's what I was wondering about: could I arrange for foo.'cfg' to
> actually be a YAML file, and use Jackson to parse it so that the
>  dictionaries would contain interesting objects.
>
> Can you point me at more reading about 'adapters'? That sounds like
> the line I would want to follow.
>
>
>
>
>> Thanks,
>> Regards
>> JB
>>
>>
>> On 11/18/2015 06:36 PM, Benson Margulies wrote:
>>> I've got some cases where I made a .cfg file point to a .yaml file
>>> because I had a complex configuration. The API to config admin sort of
>>> suggests that it might be possible to have more complex data
>>> structures so long as the top-level is key-value; is this actually
>>> doable, and, if so, how?
>>>
>> --
>> Jean-Baptiste Onofré
>> jbono...@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com




signature.asc
Description: OpenPGP digital signature


Re: Complex config

2015-11-18 Thread Benson Margulies
Pavel, as I haven't coded in scala, this will take some digesting.

On Wed, Nov 18, 2015 at 1:30 PM, Pavel E. Shirshov <pshirs...@gmail.com> wrote:
> That's exactly my sample about.
>
> It's simple idea how to implement complex config over Karaf k-v storage.
> Even with dynamic reload. Just look at the gist.
>
> On 18/11/15 18:12, Benson Margulies wrote:
>> I realize that I forgot to supply the motivation for this question.
>>
>> So long as the configuration is read-only (set up at
>> karaf-assembly-build time), then there's really nothing objectionable
>> about .cfg -> .yaml. I've started to think  about the possibility of
>> allowing for people to push changed configuration into the running
>> system. I could arrange this as 'new yaml file, tell config-admin new
>> prop value' and that would work, but I found myself wondering if
>> anyone had a scheme other than that or flattening.
>>
>>
>> On Wed, Nov 18, 2015 at 12:54 PM, Pavel E. Shirshov <pshirs...@gmail.com> 
>> wrote:
>>> Any complex structure may be flattened.
>>>
>>> Example for HOCON: https://gist.github.com/FeiWongReed/44799f4461c43f8e83c2
>>>
>>> On 18/11/15 17:44, Benson Margulies wrote:
>>>> On Wed, Nov 18, 2015 at 12:39 PM, Jean-Baptiste Onofré <j...@nanthrax.net> 
>>>> wrote:
>>>>> Hi Benson,
>>>>>
>>>>> It's something that we do in Decanter (with elasticsearch.yaml, but it's
>>>>> just a load), or in Cellar (with Hazelcast XML parsing), or in Pax Web 
>>>>> (when
>>>>> refering the jetty.xml).
>>>>>
>>>>> What do you mean exactly ? You want to load the yaml configuration in
>>>>> ConfigAdmin ? In that case, it's possible in an adapter.
>>>>>
>>>>> Please, can you elaborate a bit ?
>>>> Here's what I do now, which might be the same as you:
>>>>
>>>> foo.cfg
>>>>   workerConfig=${karaf.etc}/worker-config.yaml
>>>>
>>>> Here's what I was wondering about: could I arrange for foo.'cfg' to
>>>> actually be a YAML file, and use Jackson to parse it so that the
>>>> <String, Object> dictionaries would contain interesting objects.
>>>>
>>>> Can you point me at more reading about 'adapters'? That sounds like
>>>> the line I would want to follow.
>>>>
>>>>
>>>>
>>>>
>>>>> Thanks,
>>>>> Regards
>>>>> JB
>>>>>
>>>>>
>>>>> On 11/18/2015 06:36 PM, Benson Margulies wrote:
>>>>>> I've got some cases where I made a .cfg file point to a .yaml file
>>>>>> because I had a complex configuration. The API to config admin sort of
>>>>>> suggests that it might be possible to have more complex data
>>>>>> structures so long as the top-level is key-value; is this actually
>>>>>> doable, and, if so, how?
>>>>>>
>>>>> --
>>>>> Jean-Baptiste Onofré
>>>>> jbono...@apache.org
>>>>> http://blog.nanthrax.net
>>>>> Talend - http://www.talend.com
>>>
>
>


Re: Complex config

2015-11-18 Thread Pavel E. Shirshov
Oh, take it easy, it's just as java, but with [] instead of <>, type
inference and no returns :3

On 18/11/15 18:59, Benson Margulies wrote:
> Pavel, as I haven't coded in scala, this will take some digesting.
>
> On Wed, Nov 18, 2015 at 1:30 PM, Pavel E. Shirshov <pshirs...@gmail.com> 
> wrote:
>> That's exactly my sample about.
>>
>> It's simple idea how to implement complex config over Karaf k-v storage.
>> Even with dynamic reload. Just look at the gist.
>>
>> On 18/11/15 18:12, Benson Margulies wrote:
>>> I realize that I forgot to supply the motivation for this question.
>>>
>>> So long as the configuration is read-only (set up at
>>> karaf-assembly-build time), then there's really nothing objectionable
>>> about .cfg -> .yaml. I've started to think  about the possibility of
>>> allowing for people to push changed configuration into the running
>>> system. I could arrange this as 'new yaml file, tell config-admin new
>>> prop value' and that would work, but I found myself wondering if
>>> anyone had a scheme other than that or flattening.
>>>
>>>
>>> On Wed, Nov 18, 2015 at 12:54 PM, Pavel E. Shirshov <pshirs...@gmail.com> 
>>> wrote:
>>>> Any complex structure may be flattened.
>>>>
>>>> Example for HOCON: https://gist.github.com/FeiWongReed/44799f4461c43f8e83c2
>>>>
>>>> On 18/11/15 17:44, Benson Margulies wrote:
>>>>> On Wed, Nov 18, 2015 at 12:39 PM, Jean-Baptiste Onofré 
>>>>> <j...@nanthrax.net> wrote:
>>>>>> Hi Benson,
>>>>>>
>>>>>> It's something that we do in Decanter (with elasticsearch.yaml, but it's
>>>>>> just a load), or in Cellar (with Hazelcast XML parsing), or in Pax Web 
>>>>>> (when
>>>>>> refering the jetty.xml).
>>>>>>
>>>>>> What do you mean exactly ? You want to load the yaml configuration in
>>>>>> ConfigAdmin ? In that case, it's possible in an adapter.
>>>>>>
>>>>>> Please, can you elaborate a bit ?
>>>>> Here's what I do now, which might be the same as you:
>>>>>
>>>>> foo.cfg
>>>>>   workerConfig=${karaf.etc}/worker-config.yaml
>>>>>
>>>>> Here's what I was wondering about: could I arrange for foo.'cfg' to
>>>>> actually be a YAML file, and use Jackson to parse it so that the
>>>>> <String, Object> dictionaries would contain interesting objects.
>>>>>
>>>>> Can you point me at more reading about 'adapters'? That sounds like
>>>>> the line I would want to follow.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Thanks,
>>>>>> Regards
>>>>>> JB
>>>>>>
>>>>>>
>>>>>> On 11/18/2015 06:36 PM, Benson Margulies wrote:
>>>>>>> I've got some cases where I made a .cfg file point to a .yaml file
>>>>>>> because I had a complex configuration. The API to config admin sort of
>>>>>>> suggests that it might be possible to have more complex data
>>>>>>> structures so long as the top-level is key-value; is this actually
>>>>>>> doable, and, if so, how?
>>>>>>>
>>>>>> --
>>>>>> Jean-Baptiste Onofré
>>>>>> jbono...@apache.org
>>>>>> http://blog.nanthrax.net
>>>>>> Talend - http://www.talend.com
>>




signature.asc
Description: OpenPGP digital signature


Re: Complex config

2015-11-18 Thread David Jencks
(hope this is not showing up multiple times, I’ve been having mail problems, 
have now subscribed from a different account….).

I think some kind of flattening is a good idea as otherwise you have 
coordination problems between multiple configs.

Felix ds actually supports consuming flattening based on complex keys rather 
than complex values, mapping to nested config annotation/interfaces. (turn on 
config-with-interfaces) (I should have a felix annotation to add felix custom 
options to generated comonent xml available soon, especially if you lean on me 
a bit).

There’s also discussion of a conversion spec in OSGI which may be relevant.  
EnRoute already has some quite sophisticated conversions.

thanks
david jencks
> On Nov 18, 2015, at 1:12 PM, Benson Margulies  wrote:
> 
> I realize that I forgot to supply the motivation for this question.
> 
> So long as the configuration is read-only (set up at
> karaf-assembly-build time), then there's really nothing objectionable
> about .cfg -> .yaml. I've started to think  about the possibility of
> allowing for people to push changed configuration into the running
> system. I could arrange this as 'new yaml file, tell config-admin new
> prop value' and that would work, but I found myself wondering if
> anyone had a scheme other than that or flattening.
> 
> 
> On Wed, Nov 18, 2015 at 12:54 PM, Pavel E. Shirshov  
> wrote:
>> Any complex structure may be flattened.
>> 
>> Example for HOCON: https://gist.github.com/FeiWongReed/44799f4461c43f8e83c2
>> 
>> On 18/11/15 17:44, Benson Margulies wrote:
>>> On Wed, Nov 18, 2015 at 12:39 PM, Jean-Baptiste Onofré  
>>> wrote:
 Hi Benson,
 
 It's something that we do in Decanter (with elasticsearch.yaml, but it's
 just a load), or in Cellar (with Hazelcast XML parsing), or in Pax Web 
 (when
 refering the jetty.xml).
 
 What do you mean exactly ? You want to load the yaml configuration in
 ConfigAdmin ? In that case, it's possible in an adapter.
 
 Please, can you elaborate a bit ?
>>> Here's what I do now, which might be the same as you:
>>> 
>>>foo.cfg
>>>  workerConfig=${karaf.etc}/worker-config.yaml
>>> 
>>> Here's what I was wondering about: could I arrange for foo.'cfg' to
>>> actually be a YAML file, and use Jackson to parse it so that the
>>>  dictionaries would contain interesting objects.
>>> 
>>> Can you point me at more reading about 'adapters'? That sounds like
>>> the line I would want to follow.
>>> 
>>> 
>>> 
>>> 
 Thanks,
 Regards
 JB
 
 
 On 11/18/2015 06:36 PM, Benson Margulies wrote:
> I've got some cases where I made a .cfg file point to a .yaml file
> because I had a complex configuration. The API to config admin sort of
> suggests that it might be possible to have more complex data
> structures so long as the top-level is key-value; is this actually
> doable, and, if so, how?
> 
 --
 Jean-Baptiste Onofré
 jbono...@apache.org
 http://blog.nanthrax.net
 Talend - http://www.talend.com
>> 
>>