This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 73474 - Permit use of Preferences API in NetBeans as a replacement for SystemOption
Summary: Permit use of Preferences API in NetBeans as a replacement for SystemOption
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: rmatous
URL:
Keywords: API_REVIEW
Depends on: 65229 73794 77029 77030 77031 86997 87251
Blocks: 47737
  Show dependency tree
 
Reported: 2006-03-10 09:33 UTC by rmatous
Modified: 2008-12-23 14:26 UTC (History)
6 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
Preferences API in NetBeans (2.22 KB, text/html)
2006-03-10 09:38 UTC, rmatous
Details
NetBeans specific implementation (3.25 KB, text/html)
2006-03-10 09:39 UTC, rmatous
Details
Motivation (5.18 KB, text/html)
2006-03-13 16:06 UTC, rmatous
Details
preferences guide (10.86 KB, text/html)
2006-10-03 10:53 UTC, rmatous
Details
sligthly modified preferences guide (11.46 KB, text/html)
2006-10-04 10:47 UTC, rmatous
Details
API change: NbPreferences (1.95 KB, patch)
2006-10-04 12:26 UTC, rmatous
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rmatous 2006-03-10 09:33:21 UTC
Get rid of deficiencies connected with NetBeans settings infrastructure
represented by SystemOption for developers by adopting java Preferences API
standard to use in NetBeans as a replacement.
Comment 1 rmatous 2006-03-10 09:38:14 UTC
Created attachment 29200 [details]
Preferences API in NetBeans
Comment 2 rmatous 2006-03-10 09:39:49 UTC
Created attachment 29201 [details]
NetBeans specific implementation
Comment 4 rmatous 2006-03-13 16:06:19 UTC
Created attachment 29230 [details]
Motivation
Comment 5 tk_fhd_aui 2006-03-20 21:34:34 UTC
If I'm not wrong this would allow JNLP deployed platform applications to use 
the JNLP Preferences implementation insteaf of the UserDir implementation of 
NetBeans, right?
If that's true it would be really good so .... in some time .... platform 
applications can run in the JNLP sandbox without needing all-privileges. When 
I'm not wrong the UserDir is one of the major stoppers for this.

Regards
     Torsten
Comment 6 Jesse Glick 2006-03-21 00:34:27 UTC
Re. last comment:

1. Last I checked, JNLP doesn't provide a special Preferences impl that would
work in a sandbox, but this is being worked on (maybe for JDK 7, don't
remember). Anyway, if and when Preferences in JNLP is treated sensibly (i.e.
made available to all JNLP apps) then that would benefit NB if you omit the
NB-specific preferences impl module. This may however break modules relying on
default values expressed in the NB impl.

2. Re. use of userdir in a sandbox - see contrib/zeroadmin and ask on
dev@openide.netbeans.org for assistance if needed (David Strupl is maintainer of
this neat utility).
Comment 7 tk_fhd_aui 2006-03-21 06:37:24 UTC
1.) I thought it works also in JNLP, bad. But it isn't really a stopper for 
it, as the PreferencesFactory is pluggable. So it can be replaced by a 
implementation working with JNLP Persistence. Default values can also be 
handled this way, simply by chaining implementations (requires you know the 
name of the above implementation).

2.) I already took a look on it. The problem is that it requires remote 
storage, Preferences or JNLP Persistence or whatever work locally.
Comment 8 rmatous 2006-03-21 09:18:55 UTC
JNLP: running NetBeans in restricted environment like sandbox must be considered
in wider context than just in implementation of Preferences API.
SystemFileSystem is probably the central key to userdir in NetBeans. From this
perspective seems to be right decision to implement preferences on top of
SystemFileSystem. 
Comment 10 rmatous 2006-10-03 10:53:06 UTC
Created attachment 34793 [details]
preferences guide
Comment 11 rmatous 2006-10-04 10:47:42 UTC
Created attachment 34854 [details]
sligthly modified preferences guide
Comment 12 David Simonek 2006-10-04 11:14:09 UTC
I have another API use-case: Preferences API will perfectly fit for storing of
paths of recently closed files, which I am working on now. See issue 2710 for
details.
Comment 13 rmatous 2006-10-04 12:26:11 UTC
Created attachment 34855 [details]
API change: NbPreferences
Comment 14 rmatous 2006-10-04 15:26:38 UTC
I would like to announce that I'm ready to integrate fixes for #77031, #73794 as
a part of #73474 into trunk.

Integration includes :
- NbPreferences API  + implementation
- support in ide/launcher/upgrade for import systemoptions into preferences
- simple view of preferences trees in Runtime tab
- extension of arch questions

If I don't receive any objection by Tuesday next week, I'm going to integrate it
into milestone 4.
Issue #77030 (SystemOptions migration) - will be fixed gradually in next milestones.

links:
http://openide.netbeans.org/tutorial/reviews/opinions_73474.html
http://www.netbeans.org/nonav/issues/showattachment.cgi/34854/nbprefs.html
http://www.netbeans.org/nonav/issues/showattachment.cgi/34855/apichanges.diff 
Comment 15 Jesse Glick 2006-10-06 19:35:56 UTC
Can I confirm that in the current impl, Preferences.user/systemRoot() will
behave as in any application (using default JDK impl) while NbPreferences always
uses the userdir storage?


config/Preferences/UserRoot/ can be simplified to just config/Preferences/ I think.


"How to migrate from SystemOptions into Preferences API ?" - delete space before
'?' in questions, it looks bad.

Step #4 should suggest deleting the entire block.

BTW step #4 is misindented and missing a final </folder>.

Step #6 should say "...if still needed".

Step #8 should simply recommend deleting the BeanInfo in most cases. The
reference to "deserialization" is misleading (BeanInfo is not even typically
used for SystemOption deserialization, just for display).


"Hints how to replace SystemOption?" is not a question.

Step #2 could be simplified to remove the singleton and just use static methods.
In fact you can delete your whole settings class in most cases and just inline
the preferences methods into their use points.

Step #3: this should not be in the code IMHO. Shouldn't the upgrade tool handle
this?


"How to document usage of Preferences API?":
url="http://java.sun.com/j2se/1.4.2/docs/api/java/util/prefs/Preferences.html"
is gratuitous, delete.

typo: "emtpy"


"How to ensure import from previous version?" : s/overwritten/overridden/

http://www.netbeans.org/source/browse/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/Attic/TaskTagsProcessor.java?rev=1.1.2.2&only_with_tag=preferences_prototype&view=markup
and
http://www.netbeans.org/source/browse/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/Attic/ExampleSettingsTest.java?rev=1.1.2.1&only_with_tag=preferences_prototype&view=markup
links will need to be changed when these are merged to trunk.
Comment 16 rmatous 2006-10-11 14:23:47 UTC
Modified document according to Jesse's coments and fixed into trunk: 
/cvs/core/startup/nbproject/project.xml,v  <--  project.xml
new revision: 1.12; previous revision: 1.11
 
/cvs/core/startup/src/META-INF/services/org.netbeans.modules.openide.util.PreferencesProvider,v
 <--  org.netbeans.modules.openide.util.PreferencesProvider
new revision: 1.2; previous revision: 1.1
 
new revision: 1.2; previous revision: 1.1
 
/cvs/core/startup/src/org/netbeans/core/startup/preferences/NbPreferencesFactory.java,v
 <--  NbPreferencesFactory.java
new revision: 1.2; previous revision: 1.1
 
/cvs/core/startup/src/org/netbeans/core/startup/preferences/PreferencesProviderImpl.java,v
 <--  PreferencesProviderImpl.java
new revision: 1.2; previous revision: 1.1
 
/cvs/core/startup/src/org/netbeans/core/startup/preferences/PropertiesStorage.java,v
 <--  PropertiesStorage.java
new revision: 1.2; previous revision: 1.1
 
/cvs/core/startup/src/org/netbeans/core/startup/preferences/Statistics.java,v 
<--  Statistics.java
new revision: 1.2; previous revision: 1.1
 
/cvs/core/startup/test/unit/src/org/netbeans/core/startup/preferences/NbPreferencesTest.java,v
 <--  NbPreferencesTest.java
new revision: 1.2; previous revision: 1.1
 
/cvs/core/startup/test/unit/src/org/netbeans/core/startup/preferences/PreferencesProviderImplTest.java,v
 <--  PreferencesProviderImplTest.java
initial revision: 1.1
 
/cvs/core/startup/test/unit/src/org/netbeans/core/startup/preferences/TestFileStorage.java,v
 <--  TestFileStorage.java
new revision: 1.2; previous revision: 1.1
 
/cvs/core/startup/test/unit/src/org/netbeans/core/startup/preferences/TestNbPreferencesFactory.java,v
 <--  TestNbPreferencesFactory.java
new revision: 1.2; previous revision: 1.1
 
/cvs/core/startup/test/unit/src/org/netbeans/core/startup/preferences/TestPreferences.java,v
 <--  TestPreferences.java
new revision: 1.2; previous revision: 1.1
 
/cvs/core/startup/test/unit/src/org/netbeans/core/startup/preferences/TestPropertiesStorage.java,v
 <--  TestPropertiesStorage.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/golden/impl-deps.txt,v  <--  impl-deps.txt
new revision: 1.50; previous revision: 1.49
 
/cvs/ide/launcher/upgrade/nbproject/project.xml,v  <--  project.xml
new revision: 1.10; previous revision: 1.9
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/AutoUpgrade.java,v  <-- 
AutoUpgrade.java
new revision: 1.23; previous revision: 1.22
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/ContentProcessor.java,v
 <--  ContentProcessor.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/DefaultResult.java,v
 <--  DefaultResult.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/FileProcessor.java,v
 <--  FileProcessor.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/HashMapProcessor.java,v
 <--  HashMapProcessor.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/HostPropertyProcessor.java,v
 <--  HostPropertyProcessor.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/Importer.java,v
 <--  Importer.java
new revision: 1.2; previous revision: 1.1
 
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/IntrospectedInfoProcessor.java,v
 <--  IntrospectedInfoProcessor.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/JUnitContentProcessor.java,v
 <--  JUnitContentProcessor.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/NbClassPathProcessor.java,v
 <--  NbClassPathProcessor.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/PropertiesStorage.java,v
 <--  PropertiesStorage.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/PropertyProcessor.java,v
 <--  PropertyProcessor.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/Result.java,v 
<--  Result.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/SerParser.java,v
 <--  SerParser.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/SettingsRecognizer.java,v
 <--  SettingsRecognizer.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/SystemOptionsParser.java,v
 <--  SystemOptionsParser.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/TaskTagsProcessor.java,v
 <--  TaskTagsProcessor.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/Utils.java,v 
<--  Utils.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/src/org/netbeans/upgrade/systemoptions/systemoptionsimport,v
 <--  systemoptionsimport
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/AntSettingsTest.java,v
 <--  AntSettingsTest.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/BasicTestForImport.java,v
 <--  BasicTestForImport.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/CoreSettingsTest.java,v
 <--  CoreSettingsTest.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/DataBaseOptionTest.java,v
 <--  DataBaseOptionTest.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/DerbyOptionsTest.java,v
 <--  DerbyOptionsTest.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/ExampleSettingsTest.java,v
 <--  ExampleSettingsTest.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/HttpServerSettingsTest.java,v
 <--  HttpServerSettingsTest.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/I18nOptionsTest.java,v
 <--  I18nOptionsTest.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/IDESettingsTest.java,v
 <--  IDESettingsTest.java
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/JUnitSettingsTest.java,v
 <--  JUnitSettingsTest.java
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/org-apache-tools-ant-module-AntSettings.settings,v
 <--  org-apache-tools-ant-module-AntSettings.settings
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/org-netbeans-core-IDESettings.settings,v
 <--  org-netbeans-core-IDESettings.settings
new revision: 1.2; previous revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/org-netbeans-modules-derby-DerbyOptions.settings,v
 <--  org-netbeans-modules-derby-DerbyOptions.settings
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/org-netbeans-modules-httpserver-HttpServerSettings.settings,v
 <--  org-netbeans-modules-httpserver-HttpServerSettings.settings
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/org-netbeans-modules-i18n-I18nOptions.settings,v
 <--  org-netbeans-modules-i18n-I18nOptions.settings
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/org-netbeans-modules-junit-JUnitSettings.settings,v
 <--  org-netbeans-modules-junit-JUnitSettings.settings
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/org-netbeans-modules-xml-core-settings-CoreSettings.settings,v
 <--  org-netbeans-modules-xml-core-settings-CoreSettings.settings
initial revision: 1.1
 
/cvs/ide/launcher/upgrade/test/unit/src/org/netbeans/upgrade/systemoptions/org-netbeans-upgrade-systemoptions-ExampleSettings.settings,v
 <--  org-netbeans-upgrade-systemoptions-ExampleSettings.settings
new revision: 1.2; previous revision: 1.1
 
/cvs/openide/util/apichanges.xml,v  <--  apichanges.xml
new revision: 1.18; previous revision: 1.17
 
/cvs/openide/util/nbproject/project.properties,v  <--  project.properties
new revision: 1.22; previous revision: 1.21
 
/cvs/openide/util/src/org/netbeans/modules/openide/util/PreferencesProvider.java,v
 <--  PreferencesProvider.java
new revision: 1.2; previous revision: 1.1
 
/cvs/openide/util/src/org/openide/util/NbPreferences.java,v  <--  NbPreferences.java
new revision: 1.2; previous revision: 1.1
 
/cvs/openide/util/src/org/openide/util/doc-files/preferences.html,v  <-- 
preferences.html
initial revision: 1.1
 
/cvs/apisupport/beanbrowser/src/org/netbeans/modules/apisupport/beanbrowser/PreferencesNode.java,v
 <--  PreferencesNode.java
new revision: 1.2; previous revision: 1.1
 
/cvs/apisupport/beanbrowser/src/org/netbeans/modules/apisupport/beanbrowser/layer.xml,v
 <--  layer.xml
new revision: 1.3; previous revision: 1.2
 
/cvs/nbbuild/antsrc/org/netbeans/nbbuild/Arch-api-questions.xml,v  <-- 
Arch-api-questions.xml
new revision: 1.43; previous revision: 1.42
 
/cvs/nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd,v  <--  Arch.dtd
new revision: 1.25; previous revision: 1.24
 
/cvs/nbbuild/test/unit/src/org/netbeans/nbbuild/ArchQuestionsTest.java,v  <-- 
ArchQuestionsTest.java
new revision: 1.14; previous revision: 1.13
 
/cvs/nbbuild/test/unit/src/org/netbeans/nbbuild/arch-preferences.xml,v  <-- 
arch-preferences.xml
initial revision: 1.1
 

Comment 17 Jesse Glick 2006-10-11 14:58:56 UTC
So this is then FIXED w/ TM = Dev? or what?
Comment 18 rmatous 2006-10-11 16:12:07 UTC
Fixed
Comment 19 Jesse Glick 2006-10-17 02:20:13 UTC
This suggestion re. the preferences guide was neither implemented nor explicitly
rejected:

"Step #3: this should not be in the code IMHO. Shouldn't the upgrade tool handle
this?"
Comment 20 rmatous 2006-10-17 13:27:51 UTC
I think its handled by upgrade tool. After upgrade process is finished all
*.settings files are not deleted but renamed not to be recognized by
InstanceDataObject anymore. Is it OK for you? 
Comment 21 Jesse Glick 2006-10-17 19:04:00 UTC
It's fine for .settings files to be either deleted or renamed by the upgrade
tool. The problem is that

http://www.netbeans.org/download/dev/javadoc/org-openide-util/org/openide/util/doc-files/preferences.html

says in "Hints how to replace SystemOption" item #3 that you should write code
in your module to delete the old .settings file. If this is to be done by the
upgrade tool then I don't understand why you would clutter your module code with it.
Comment 22 rmatous 2006-10-18 08:03:10 UTC
Nothing like "Hints how to replace SystemOption" item #3 .." is there anymore.
I'm sorry, but javadoc build probably fails everyday. 
Comment 23 Quality Engineering 2008-12-23 14:26:19 UTC
This issue had *2 votes* before move to platform component