Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Storing preferences across bundle versions
Storing preferences across bundle versions [message #521279] Wed, 17 March 2010 02:31 Go to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
I use the OSGi PreferencesService to store some persistent data for my
Eclipse plugin. Unfortunately it seems that this data is erased whenever I
deploy a new version of the plugin. The data is never available to the new
plugin version. Is there a recommended way to store persistent data across
different bundle versions?

Thanks, Felix
Re: Storing preferences across bundle versions [message #521376 is a reply to message #521279] Wed, 17 March 2010 12:54 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Am 17.03.2010 03:31, schrieb Felix LJ Mayer:
> I use the OSGi PreferencesService to store some persistent data for my
> Eclipse plugin. Unfortunately it seems that this data is erased whenever I
> deploy a new version of the plugin. The data is never available to the new
> plugin version.

The Equinox implementation of the OSGi PreferenceService is
o.e.c.i.p.OSGiPreferencesServiceImpl. Instanced are created per bundle
using a service factory (OSGiPreferencesServiceManager).

Unfortunately, the OSGiPreferencesServiceManager associates the bundle
preferences with the bundle id. The bundle id is unique and newer
versions of a bundle get a different id.

I wonder if this is intended behavior or if it's a bug.

> Is there a recommended way to store persistent data across
> different bundle versions?

Don't know whether you are able to use the Eclipse preferences API. But
provides much better preferences capabilities (including different
scopes and complete control over the preferences tree).

For example, you could define default preferences:
IEclipsePreferences defaultPrefs = new
DefaultScope().getNode("my.bundle.symbolic.name");

or installation wide preferences:
IEclipsePreferences installPrefs = new
ConfigurationScope().getNode("my.bundle.symbolic.name");

or preferences which only exists "per instance" (i.e. workspace):
IEclipsePreferences instancePrefs = new
InstanceScope().getNode("my.bundle.symbolic.name");

Then you can perform scope based lookups (using
org.eclipse.core.runtime.preferences.IPreferencesService).

-Gunnar


--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Storing preferences across bundle versions [message #521527 is a reply to message #521376] Wed, 17 March 2010 17:34 Go to previous message
Eclipse UserFriend
Originally posted by: felix.mayer.erdas.com

Thanks, IEclipsePreferences sound like a good idea.

With respect to the OSGi PreferencesService, I would think that a bundle is
identified by its symbolic name and not its id. Anything seems useless in
many cases. However, the Preferences Class Diagram in the OSGi R4 Service
Compendium shows the bundle id in the relationship between a bundle and the
PreferencesService, so the bug could be in the specification instead of
Equinox.

"Gunnar Wagenknecht" <gunnar@wagenknecht.org> wrote in message
news:hnqjd9$gt9$1@build.eclipse.org...
> Am 17.03.2010 03:31, schrieb Felix LJ Mayer:
>> I use the OSGi PreferencesService to store some persistent data for my
>> Eclipse plugin. Unfortunately it seems that this data is erased whenever
>> I
>> deploy a new version of the plugin. The data is never available to the
>> new
>> plugin version.
>
> The Equinox implementation of the OSGi PreferenceService is
> o.e.c.i.p.OSGiPreferencesServiceImpl. Instanced are created per bundle
> using a service factory (OSGiPreferencesServiceManager).
>
> Unfortunately, the OSGiPreferencesServiceManager associates the bundle
> preferences with the bundle id. The bundle id is unique and newer
> versions of a bundle get a different id.
>
> I wonder if this is intended behavior or if it's a bug.
>
>> Is there a recommended way to store persistent data across
>> different bundle versions?
>
> Don't know whether you are able to use the Eclipse preferences API. But
> provides much better preferences capabilities (including different
> scopes and complete control over the preferences tree).
>
> For example, you could define default preferences:
> IEclipsePreferences defaultPrefs = new
> DefaultScope().getNode("my.bundle.symbolic.name");
>
> or installation wide preferences:
> IEclipsePreferences installPrefs = new
> ConfigurationScope().getNode("my.bundle.symbolic.name");
>
> or preferences which only exists "per instance" (i.e. workspace):
> IEclipsePreferences instancePrefs = new
> InstanceScope().getNode("my.bundle.symbolic.name");
>
> Then you can perform scope based lookups (using
> org.eclipse.core.runtime.preferences.IPreferencesService).
>
> -Gunnar
>
>
> --
> Gunnar Wagenknecht
> gunnar@wagenknecht.org
> http://wagenknecht.org/
>
Previous Topic:Problems when exporting a product.
Next Topic:Generated configuration file overwrites specified properties (since Eclipse 3.5.2)
Goto Forum:
  


Current Time: Sat Apr 20 00:39:11 GMT 2024

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

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

Back to the top