|
Re: Storing preferences across bundle versions [message #521376 is a reply to message #521279] |
Wed, 17 March 2010 12:54 |
|
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 |
Eclipse User |
|
|
|
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/
>
|
|
|
Powered by
FUDForum. Page generated in 0.03032 seconds