-
Notifications
You must be signed in to change notification settings - Fork 53
Create Pref Service #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Pref Service #102
Conversation
Thank you for this carefully considered and long needed update! Please get rid of Secondly, please purge references to the Java Preferences API from the
If you need further guidance on how to update the All in all, this is a great update. I just want to be extra careful to "get it right" this time! |
@ctrueden good points on both. Agreed on the Thanks for pointing out the Let me know if there are any more issues, otherwise I'm happy with the patch. |
@ctrueden well I didn't check silly little details like whether this compiles or not (it doesn't). The |
@ctrueden ok, now everything compiles and passes tests as one would expect.. ready for final review |
I am loath to point this out, but... there are no unit tests for Also, regarding the package name: how about |
Also, this PR isn't auto-mergeable right now. Needs a rebase over latest master. |
Using a static utility method for Prefs is limiting - it provides no way to override preference saving/loading behavior. This creates problems when there are errors or negative interactions with the Preferences implementation - for example, in MATLAB there are known bugs regarding the Java Preferences implementation. By converting to a PrefService we can now control this behavior more precisely, as needed. The Prefs utility class will remain for now, but will delegate to the PrefService when it has been created - allowing the utility method behavior to be overridden similarly.
All Contextual classes that used the Prefs static utility class should now be using PrefService.
Added API to save/load ModuleItems. This will allow Contextual classes to move away from ModuleItem#loadValue and ModuleItem#saveValue, which are not Contextual and go directly through the Prefs utility class. Adds a default implementation in DefaultModuleService, using the PrefService if able (which requires an AbstractModuleItem). If necessary, still falls back to ModuleItem's saveValue and loadValue methods.
ModuleItem#saveValue and ModuleItem#loadValue are now deprecated in favor of ModuleService methods, which can be called from a Contextual environment and thus use the new PrefService API.
Updated classes that were using ModuleItem#saveValue and ModuleItem#loadValue to use the appropriate ModuleService methods.
It was discovered that the initialize method of multiple PrefService impls was being invoked - leading to the LOWEST priority overwriting the static service field in the Prefs utility class (since it was the last initialize method to execute). Added a check for priority so that lower priority services don't overwrite higher.
Appled Source > Clean Up in Eclipse, to update newest classes with the IJ2 style template.
Added comments detailing planned future for the pref service.
The Prefs utility class is now deprecated. PrefService should be used instead.
This was an unnecessary method. Originally thought that each service would need a reminder to set itself as the static PrefService... but that's exactly what the initialize method of AbstractPrefService is for.
The whole point of the PrefService is to allow for any preference implementation, while the DefaultPrefService uses java.util.Preferences. Thus the java.util.Preferences imports have been removed from the PrefService, and the necessary Class and String-based indexing methods have been added. Updated the DefaultPrefService implementation and usage of the service accordingly.
We have a short name PrefService, so we should use a short package name instead of a long package name.
The Prefs class is deprecated and we should not reference it in any way from non-deprecated code.
Added suppress warnings for the Prefs deprecation.
Migrates the static utility `Prefs` class to an extensible `PrefService`.
Moves from a static utility
Prefs
class to aPrefService
with default implementation.All functionality is the same, running through
java.lang.prefs.Preferences
.The
Prefs
class itself is retained but deprecated. It will delegate to aPrefService
instead. Note that, because thePrefs
class has noContext
and lacks a nice way to obtain it, it will default to theDefaultPrefService
until another service is set as the staticPrefService
of choice.To facilitate this, the
AbstractPrefService
sets this static field.As part of this patch, I also had to add
ModuleService
API to save/loadModuleItem
values, as these wereContext
-less entities using thePrefs
class.