Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » [neon] How to replace org.osgi.service.prefs.Preferences
[neon] How to replace org.osgi.service.prefs.Preferences [message #1752482] Tue, 24 January 2017 11:12 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
One of the applications I am migrating from Mars to Neon makes use of org.osgi.service.prefs.Preferences to store user settings.

Obviously, this class is no longer available in Neon. I did not find anything in the Migration Guide and the Technical Guide. Is there a new Scout equivalent to be used instead or are we on our own in covering this functionality?
Re: [neon] How to replace org.osgi.service.prefs.Preferences [message #1752490 is a reply to message #1752482] Tue, 24 January 2017 12:59 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Never mind, I found org.eclipse.scout.rt.shared.services.common.prefs.Preferences Smile
Re: [neon] How to replace org.osgi.service.prefs.Preferences [message #1752497 is a reply to message #1752490] Tue, 24 January 2017 13:55 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Hm, it seems my elation was premature.

In Mars we had the following structure:

MyPreferences extends org.eclipse.scout.commons.prefs.AbstractPreferences implements org.osgi.service.prefs.Preferences

I'm trying to map things to Neon but am struggling. For starters, there seem to be two different classes called Preferences and I am not sure which one to use

There is:
java.util.prefs.AbstractPreferences extends java.util.prefs.Preferences

But then, there also is:
org.eclipse.scout.rt.shared.services.common.prefs.Preferences

Which of the two should I use instead of org.osgi.service.prefs.Preferences?

java.util.prefs.AbstractPreferences extends java.util.prefs.Preferences, so that led me to think that this is the choice.

However, then, there is org.eclipse.scout.rt.shared.services.common.prefs.IUserPreferencesStorageService which in Mars used org.osgi.service.prefs.Preferences loadPreferences().

In Neon this seems to have been replaced with org.eclipse.scout.rt.shared.services.common.prefs.IUserPreferencesStorageService which instead has org.eclipse.scout.rt.shared.services.common.prefs.IPreferences getPreferences(). This interface however is implemented by org.eclipse.scout.rt.shared.services.common.prefs.Preferences which seems to suggest to the exact opposite.

Besides this confusion, I am not sure how I need to transfer the former loadPreferences() to the new getPreferences() which has parameters the old method lacked. Also, the Preferences now seem to require some kind of tree form instead of just key/value pairs.

Is there any documentation how we can implement our own preference store using the new Neon mechanisms?

[Updated on: Tue, 24 January 2017 14:05]

Report message to a moderator

Re: [neon] How to replace org.osgi.service.prefs.Preferences [message #1752502 is a reply to message #1752497] Tue, 24 January 2017 14:36 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
On further analysis I think it's not even a matter of just replacing the existing code. The more I look at it, the more I realise it has been totally tied to the eclipse mechanism (including registering our own IUserPreferencesStorageService as an extension point).

So I guess, my rephrased question is:


  • how does Scout Neon store user settings (such as column order, sorting on tables etc)?
  • how can we intercept this storage mechanism in order to persist it to the database, so users can transfer these settings from machine to machine?

Re: [neon] How to replace org.osgi.service.prefs.Preferences [message #1752589 is a reply to message #1752482] Wed, 25 January 2017 12:42 Go to previous messageGo to next message
Michael Rudolf is currently offline Michael RudolfFriend
Messages: 2
Registered: May 2012
Junior Member
Hi Urs

User Preferences in Neon are stored using
org.eclipse.scout.rt.shared.services.common.prefs.Preferences

By default there is the org.eclipse.scout.rt.client.services.common.prefs.FileSystemUserPreferencesStorageService which stores the preferences in a file in the users home directory.

To provide your own implementation you can create an implementation of the org.eclipse.scout.rt.shared.services.common.prefs.IUserPreferencesStorageService Interface. Using a lower @Order annotation than 5000 (default) your service implementation will be preferred over the default file based service.

For example:
@Order(1000)
public class DatabaseUserPreferencesStorageService implements IUserPreferencesStorageService {

  @Override
  public IPreferences getPreferences(ISession userScope, String nodeId) {
    //load preferences from database...
  }

  @Override
  public void flush(IPreferences prefs) {
    // write preferences to database...
}



Cheers,
Michael
Re: [neon] How to replace org.osgi.service.prefs.Preferences [message #1752684 is a reply to message #1752589] Thu, 26 January 2017 08:08 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Hi Michael

Thank you for your feedback, that should help me solve this.
Previous Topic:[general] Experiences with Search/Filter and/or pagination
Next Topic:How to connect two Scout Projects?
Goto Forum:
  


Current Time: Thu Apr 25 19:07:26 GMT 2024

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

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

Back to the top