Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » Configure default instance of a service
Configure default instance of a service [message #1801849] Mon, 28 January 2019 12:19 Go to next message
Pedro de Arquer is currently offline Pedro de ArquerFriend
Messages: 34
Registered: December 2018
Member
Hi,

I've created a service to be used as singleton. I was wondering if there is a way to create the instance by default and make it non-deletable similarly to, for example, the ClockService?

Kind regards,
Re: Configure default instance of a service [message #1802029 is a reply to message #1801849] Thu, 31 January 2019 07:25 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hello,
I believe you should replicate the configuration of ClockService into your bundle files.
Furthermore, you could customise the config.ini file to locate and start the jar that wraps your bundle at Kura boot.

Best regards,
Matteo
Re: Configure default instance of a service [message #1803672 is a reply to message #1802029] Wed, 06 March 2019 14:28 Go to previous messageGo to next message
Pedro de Arquer is currently offline Pedro de ArquerFriend
Messages: 34
Registered: December 2018
Member
Thank you for your response.

I've replicated ClockService configuration to hide the service implementation and avoid a recreation, but I was unable to avoid deletion of the service.

About the config.ini file, could you point me more precisely to one example. I've configured the snapshot_0.xml to include the service in the initial execution, is there a better approach? This method is vulnerable if a configuration without the service is uploaded as there would be no way to create the service from the interface.
Re: Configure default instance of a service [message #1803765 is a reply to message #1803672] Fri, 08 March 2019 16:53 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Sorry, I don't understand this:
Quote:
but I was unable to avoid deletion of the service

A singleton cannot be deleted from the Kura web ui.

If you had a look at the clock service configuration, https://github.com/eclipse/kura/blob/develop/kura/org.eclipse.kura.linux.clock/OSGI-INF/clock.xml
it says:
configuration-policy="require" enabled="true" immediate="true"
Re: Configure default instance of a service [message #1803811 is a reply to message #1803765] Mon, 11 March 2019 11:21 Go to previous messageGo to next message
Pedro de Arquer is currently offline Pedro de ArquerFriend
Messages: 34
Registered: December 2018
Member
Quote:
A singleton cannot be deleted from the Kura web ui


Then maybe I've configured wrongly the component. I've used the following annotation over the class:

@Component(scope = ServiceScope.SINGLETON)


I'll test the immediate clause soon. Thanks for the indication
Re: Configure default instance of a service [message #1803959 is a reply to message #1803811] Thu, 14 March 2019 10:48 Go to previous messageGo to next message
Pedro de Arquer is currently offline Pedro de ArquerFriend
Messages: 34
Registered: December 2018
Member
I've tried the immediate clause and the service effectively gets instantiated but it can be configured in the web UI as it is not listed among Kura services. Not even in the snapshot file.
Re: Configure default instance of a service [message #1803963 is a reply to message #1803959] Thu, 14 March 2019 13:08 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Maybe the service did not start.
Please have a look at the OSGi console.

Re: Configure default instance of a service [message #1804463 is a reply to message #1803963] Tue, 26 March 2019 12:08 Go to previous message
Pedro de Arquer is currently offline Pedro de ArquerFriend
Messages: 34
Registered: December 2018
Member
Well, definitively I got it. Thanks for all the help provided.

The Singleton declaration was completely counter-productive. Besides it was needed to remove factoryPid from Designate in the configuration file. With these two modifications (ClockService was made this way, so the initial indication you made was correct) the service works like a charm.
Previous Topic:Is Raspberry Pi 3 Model B+ fully supported?
Next Topic:Connect Wireless Devices to Kura
Goto Forum:
  


Current Time: Sat May 04 03:53:00 GMT 2024

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

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

Back to the top