Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » Kura Services OsGI-Inf Metatype xml Editing(Is there anyway to edit values of the keys of the xml file inside the metatype folder from the main code?)
Kura Services OsGI-Inf Metatype xml Editing [message #1770105] Tue, 08 August 2017 11:51 Go to next message
Erdem Tuna is currently offline Erdem TunaFriend
Messages: 9
Registered: August 2017
Junior Member
Hi,

I've tried to edit value of a key component of the xml file in the metatype with "properties.put" and "properties.replace". However, when I call these functions, related key value is not being edited and relevant web UI in Kura disappears but bundle keeps running. For the sake of example, referring to "org.eclipse.kura.demo.heater", If I want to edit value of the "program.startTime" from the main code by typing
properties.replace("program.startTime", "08.00")
or
properties.put("program.startTime", "08.00")
, it doesn't make any effect on the value of the key. However, I can display the value of "program.startTime" by typing
properties.get("program.startTime")


The value can obviously be edited through web UI but, I want to ask that is it possible to edit a value of the key that is present in the xml file from the main code?
Re: Kura Services OsGI-Inf Metatype xml Editing [message #1770106 is a reply to message #1770105] Tue, 08 August 2017 11:55 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 264
Registered: July 2015
Location: Italy
Senior Member
Hi,
if you want to have your property persisted, you need to apply that change using the ConfigurationService APIs.

There are quite a few references in the code. And the same APIs are used by the web ui as well.

Best regards
Re: Kura Services OsGI-Inf Metatype xml Editing [message #1770126 is a reply to message #1770106] Tue, 08 August 2017 14:15 Go to previous messageGo to next message
Erdem Tuna is currently offline Erdem TunaFriend
Messages: 9
Registered: August 2017
Junior Member
Thanks Matteo for the answer, but "properties.put", "properties.replace", "properties.remove" are all giving "messagenull" exception when I run them inside the code. As I understand "properties.xyz" is the right way to edit a key value and ConfigurationService API is the right way to save the change. Although "properties.get" does what it's supposed to, the rest gives exception. Could you please be more specific, Matteo?
Re: Kura Services OsGI-Inf Metatype xml Editing [message #1770146 is a reply to message #1770126] Tue, 08 August 2017 15:26 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 264
Registered: July 2015
Location: Italy
Senior Member
Hi,
the properties received by the component can be changed like you said (I would prefer doing a copy though).
To persist them you need to take a dependency from the configuration service using the declarative services and invoke a method like "updateConfiguration" to update the configuration persisted by the framework.

An example you can take as reference: https://github.com/eclipse/kura/blob/develop/kura/org.eclipse.kura.core/src/main/java/org/eclipse/kura/core/ssl/SslManagerServiceImpl.java#L626

Best regards
Re: Kura Services OsGI-Inf Metatype xml Editing [message #1770245 is a reply to message #1770146] Wed, 09 August 2017 10:25 Go to previous message
Erdem Tuna is currently offline Erdem TunaFriend
Messages: 9
Registered: August 2017
Junior Member
Thank you Matteo, I could solve the problem with your example and this post https://www.eclipse.org/forums/index.php/t/1028102/. Have a good day.
Previous Topic:How to see the kura run state log?
Next Topic:Kura on Raspberry PI - Remote management is not working
Goto Forum:
  


Current Time: Wed Sep 26 08:28:18 GMT 2018

Powered by FUDForum. Page generated in 0.01943 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top