Karaf Configuration Update

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Karaf Configuration Update

Miroslav Beranič
Hi all,

I would like to hook into configuration change made in etc/* file. I put configuration file there and when I change it, I see in Karaf's log the change was picked up and also file was rewritten.

But, how is this hooked in from the Java class ?


I manual I've only found:
Dynamic Configuration: Apache Karaf provides a set of commands focused on managing its own configuration. All configuration files are centralized in the etc folder. Any change in a configuration file is noticed and reloaded.

Back at the scheduler I've seen this:
@Managed("org.apache.karaf.scheduler.quartz")
and implements org.osgi.service.cm.ManagedService

That has method void updated(Dictionary<String, ?> var1) throws ConfigurationException;

this is great, but this method is not called.

Is there any example/code I can look at at take as an starting point?


Kind Regards,
Miroslav


--
Miroslav Beranič
MIBESIS
+386(0)40/814-843
[hidden email]
http://www.mibesis.si
Reply | Threaded
Open this post in threaded view
|

Re: Karaf Configuration Update

jbonofre
Hi,

If you want to add to a specific configuration, you have to use a
ManagedService (or ManagedServiceFactory if it's a configuration factory).

If you use scr with @Managed, it's a managed service listening change on
the org.apache.karaf.scheduler.quartz configuration (so
etc/org.apache.karaf.scheduler.quartz.cfg corresponding file). When you
want the configuration, the update() method is called.

If you want to listen for any config change, you can implement a
ConfigurationListener.

I will add a example showing this if you want.

Regards
JB

On 13/09/2018 11:06, Miroslav Beranič wrote:

> Hi all,
>
> I would like to hook into configuration change made in etc/* file. I put
> configuration file there and when I change it, I see in Karaf's log the
> change was picked up and also file was rewritten.
>
> But, how is this hooked in from the Java class ?
>
>
> I manual I've only found:
> Dynamic Configuration: Apache Karaf provides a set of commands focused
> on managing its own configuration. All configuration files are
> centralized in the etc folder. Any change in a configuration file is
> noticed and reloaded.
>
> Back at the scheduler I've seen this:
> @Managed("org.apache.karaf.scheduler.quartz")
> and implements org.osgi.service.cm.ManagedService
>
> That has method void updated(Dictionary<String, ?> var1) throws
> ConfigurationException;
>
> this is great, but this method is not called.
>
> Is there any example/code I can look at at take as an starting point?
>
>
> Kind Regards,
> Miroslav
>
>
> --
> Miroslav Beranič
> MIBESIS
> +386(0)40/814-843
> [hidden email] <mailto:[hidden email]>
> http://www.mibesis.si

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Karaf Configuration Update

jbonofre
I created: https://issues.apache.org/jira/browse/KARAF-5913

to add new example config module.

Regards
JB

On 13/09/2018 11:16, Jean-Baptiste Onofré wrote:

> Hi,
>
> If you want to add to a specific configuration, you have to use a
> ManagedService (or ManagedServiceFactory if it's a configuration factory).
>
> If you use scr with @Managed, it's a managed service listening change on
> the org.apache.karaf.scheduler.quartz configuration (so
> etc/org.apache.karaf.scheduler.quartz.cfg corresponding file). When you
> want the configuration, the update() method is called.
>
> If you want to listen for any config change, you can implement a
> ConfigurationListener.
>
> I will add a example showing this if you want.
>
> Regards
> JB
>
> On 13/09/2018 11:06, Miroslav Beranič wrote:
>> Hi all,
>>
>> I would like to hook into configuration change made in etc/* file. I put
>> configuration file there and when I change it, I see in Karaf's log the
>> change was picked up and also file was rewritten.
>>
>> But, how is this hooked in from the Java class ?
>>
>>
>> I manual I've only found:
>> Dynamic Configuration: Apache Karaf provides a set of commands focused
>> on managing its own configuration. All configuration files are
>> centralized in the etc folder. Any change in a configuration file is
>> noticed and reloaded.
>>
>> Back at the scheduler I've seen this:
>> @Managed("org.apache.karaf.scheduler.quartz")
>> and implements org.osgi.service.cm.ManagedService
>>
>> That has method void updated(Dictionary<String, ?> var1) throws
>> ConfigurationException;
>>
>> this is great, but this method is not called.
>>
>> Is there any example/code I can look at at take as an starting point?
>>
>>
>> Kind Regards,
>> Miroslav
>>
>>
>> --
>> Miroslav Beranič
>> MIBESIS
>> +386(0)40/814-843
>> [hidden email] <mailto:[hidden email]>
>> http://www.mibesis.si
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Karaf Configuration Update

Miroslav Beranič
In reply to this post by jbonofre
Hi JB,

( bow )

Thank you.

Kind Regards,
Miroslav


V V čet., 13. sep. 2018 ob 11:16 je oseba Jean-Baptiste Onofré <[hidden email]> napisala:
Hi,

If you want to add to a specific configuration, you have to use a
ManagedService (or ManagedServiceFactory if it's a configuration factory).

If you use scr with @Managed, it's a managed service listening change on
the org.apache.karaf.scheduler.quartz configuration (so
etc/org.apache.karaf.scheduler.quartz.cfg corresponding file). When you
want the configuration, the update() method is called.

If you want to listen for any config change, you can implement a
ConfigurationListener.

I will add a example showing this if you want.

Regards
JB

On 13/09/2018 11:06, Miroslav Beranič wrote:
> Hi all,
>
> I would like to hook into configuration change made in etc/* file. I put
> configuration file there and when I change it, I see in Karaf's log the
> change was picked up and also file was rewritten.
>
> But, how is this hooked in from the Java class ?
>
>
> I manual I've only found:
> Dynamic Configuration: Apache Karaf provides a set of commands focused
> on managing its own configuration. All configuration files are
> centralized in the etc folder. Any change in a configuration file is
> noticed and reloaded.
>
> Back at the scheduler I've seen this:
> @Managed("org.apache.karaf.scheduler.quartz")
> and implements org.osgi.service.cm.ManagedService
>
> That has method void updated(Dictionary<String, ?> var1) throws
> ConfigurationException;
>
> this is great, but this method is not called.
>
> Is there any example/code I can look at at take as an starting point?
>
>
> Kind Regards,
> Miroslav
>
>
> --
> Miroslav Beranič
> MIBESIS
> +386(0)40/814-843
> [hidden email] <mailto:[hidden email]>
> http://www.mibesis.si

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com


--
Miroslav Beranič
MIBESIS
+386(0)40/814-843
[hidden email]
http://www.mibesis.si