|Can I ensure that third party code uses my configured SettngStore [message #1115908]
||Tue, 24 September 2013 19:21
| Mark Leone
Registered: April 2012
I have a single-source RCP/RAP app, and the RAP instance requires user-specific preferences to be persisted indefinitely between user sessions or launches of the RAP app. I've made this work by configuring the app to use a WorkbenchFileSettingStoreFactory, which creates a FileSettigStore that persists its data in the configured location. My code calls loadById() on the setting store for each UISession, passing it a hash of the user's Distinguished Name obtained from a certificate.|
In my RAP app, I obtain a reference to a PreferenceStore by calling PlatformUI.getPreferenceStore(). This returns the configured SettingStore. If I obtain a PreferenceStore the way I do in my RCP app
myPreferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, myPlugin.getDefault().getBundle().getSymbolicName());
I get a PreferenceStore that is not persisted beyond that UISession (or maybe for all UISessions in the current HttpSession). This is because at ScopedPreferenceStore line 162, a decision is made to use the configured SettingStore only if the IScopeContext passed in to the ScopedPreferenceStore is an instance of SessionScope.
Throughout our app, we obtain a PreferenceStore, when needed, by creating a ScopedPreferenceStore with an InstanceScope context and a qualifier equal to the plugin symbolic name, as shown above. I can insert code to call PlatformUI.getPreferenceStore() if the runtime is RAP, and create an instance-scoped ScopedPreferenceStore if the runtime is RCP. I could also use PlatformUI.getPreferenceStore() in the RCP app (with the side effect that preferences from all plugins will be stored in the instance area for org.eclipse.core.runtime, keyed to plugin org.eclipse.ui), but I can't assume that third party code incorporated into my app does this. The common pattern in RCP is to use an instance-scoped PreferenceStore, which stores the settings in the instance area for the specified plugin. If I incorporate any such code and don't make changes to the way PreferenceStores are obtained, then the preferences managed by third party apps will be scoped to the current session, and will not be persisted using the configured SettingStore.
In sum, I'd like to verify the following:
1. Am I correct that any third party RCP code that does not obtain its PreferencfeStores via PlatformUI.getPreferenceStore() will have preferences that are not persisted by the configured SettingStore?
2. Can I assume that all preferences used by the RAP runtime will use the configured SettingStore? So far in what I've examined it seems to be the case that the paltform uses PlatformUI.getPrererenceStore(), but I don't know if I can assume this will always be the case.
3. Is there a way to make RAP use the configured SettingStore for any ScopedPreferenceStore created with instance scope?
There seems to be a fundamental divergence because in RCP instance scopes are bound to a workspace location, while in RAP there is one workspace. Unless I'm missing something, it seems that there is no way in RAP to ensure that my configured SettingStore is used unless PlatformUI.getPreferenceStore() is used to obtain the PreferenceStore.
(I could also use
myPreferenceStore = new ScopedPreferenceStore(new SessionScope(), myPlugin.getDefault().getBundle().getSymbolicName());
but SessionScope is a non-API class and also RAP-specific, so the static call to PlatformUI seems to be the provided mechanism.)
[Updated on: Tue, 24 September 2013 20:06]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.14790 seconds