Skip to main content



      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 06:12 Go to next message
Eclipse UserFriend
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 07:59 Go to previous messageGo to next message
Eclipse UserFriend
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 08:55 Go to previous messageGo to next message
Eclipse UserFriend
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 09:05] by Moderator

Re: [neon] How to replace org.osgi.service.prefs.Preferences [message #1752502 is a reply to message #1752497] Tue, 24 January 2017 09:36 Go to previous messageGo to next message
Eclipse UserFriend
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 07:42 Go to previous messageGo to next message
Eclipse UserFriend
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 03:08 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 08:30:34 EDT 2025

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

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

Back to the top