Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > java.util.prefs

Reply
Thread Tools

java.util.prefs

 
 
kimbuba
Guest
Posts: n/a
 
      07-16-2003
Hello all.
I'm playing with this new api.

But i have some questions about it.

I read that in windows preferences resides in:
HKEY_CURRENT_USER\Software\JavaSoft\Prefs (for the user tree)
On linux plat pref resides in: <user's home directory>/.java/.userPrefs

The problem arises when i'm building a web application. If i write on the
system tree i could read and write others preferences!

My question is: is it possible to have a local pref tree? like a File? so
that i can store that file locally on my hosting space?
i'd like to be indipendent of my hosting provider, since i could have
problems in writing on System tree or User tree (if they didn't configure
well my account)

Thanx all in advance.


 
Reply With Quote
 
 
 
 
Mohun Biswas
Guest
Posts: n/a
 
      07-17-2003
Roedy Green wrote:
>
>>HKEY_CURRENT_USER\Software\JavaSoft\Prefs

>
>
> Is HKEY_CURRENT_USER an alias for whomever is actually signed on right
> now?


Yes.

It seems when you poke around in the registry there are large
> parts duplicated.


True.

> I found Javasoft/prefs directories also in HKEY_LOCAL_MACHINE and
> HKEY_USERS.
>
> Sun loves to play the shell game.


That's as may be but what you describe is an artifact of the Windows
registry. Many of the per-user settings are "backed" by per-machine
settings in the HKEY_LOCAL_MACHINE tree. And in general, any search
through the registry turns up huge duplicate trees, presumably as a
result of some kind of aliasing/linking.

MB

 
Reply With Quote
 
 
 
 
Mohun Biswas
Guest
Posts: n/a
 
      07-17-2003
Roedy Green wrote:
>
>>HKEY_CURRENT_USER\Software\JavaSoft\Prefs

>
>
> Is HKEY_CURRENT_USER an alias for whomever is actually signed on right
> now?


Yes.

It seems when you poke around in the registry there are large
> parts duplicated.


True.

> I found Javasoft/prefs directories also in HKEY_LOCAL_MACHINE and
> HKEY_USERS.
>
> Sun loves to play the shell game.


That's as may be but what you describe is an artifact of the Windows
registry. Many of the per-user settings are "backed" by per-machine
settings in the HKEY_LOCAL_MACHINE tree. And in general, any search
through the registry turns up huge duplicate trees, presumably as a
result of some kind of aliasing/linking.

MB

 
Reply With Quote
 
Joseph Millar
Guest
Posts: n/a
 
      07-17-2003
On Wed, 16 Jul 2003 19:33:30 GMT, Roedy Green <(E-Mail Removed)> wrote:
> On Wed, 16 Jul 2003 13:44:27 +0200, "kimbuba"
> <(E-Mail Removed)> wrote or quoted :
>
> >HKEY_CURRENT_USER\Software\JavaSoft\Prefs

>
> Is HKEY_CURRENT_USER an alias for whomever is actually signed on right
> now? It seems when you poke around in the registry there are large
> parts duplicated.
>
> I found Javasoft/prefs directories also in HKEY_LOCAL_MACHINE and
> HKEY_USERS.
>
> Sun loves to play the shell game.


Sun's implementation of the Preferences on Windows
goes something like this:

User Root:
HKEY_CURRENT_USER\Software\JavaSoft\Prefs

System Root:
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs

The effect is that is you want to share preferences across
different users, put them in the System tree, not the User
tree. The User tree will change based on the currently
logged in user, so the preferences will necessarily be
different. THe HKEY_CURRENT_USER hive is actually an
alias for one of the hives in the HKEY_USERS hive, matching
whoever the current user is.

--Joe
 
Reply With Quote
 
Andy Flowers
Guest
Posts: n/a
 
      07-18-2003
Try looking at the Preferences & PreferencesFactory classes for details of
how you can provide your own preferences store.

"kimbuba" <(E-Mail Removed)> wrote in message
news:U0PRa.14337$(E-Mail Removed). ..
> is it possible to store the trees on a separate file?
> If i put on the hosting's system tree, others people could read and modify
> my preferences.
>
> Thnx.
>
>
>
>
>
> "Joseph Millar" <(E-Mail Removed)> ha scritto nel messaggio
> news:(E-Mail Removed)...
> > On Wed, 16 Jul 2003 19:33:30 GMT, Roedy Green <(E-Mail Removed)>

wrote:
> > > On Wed, 16 Jul 2003 13:44:27 +0200, "kimbuba"
> > > <(E-Mail Removed)> wrote or quoted :
> > >
> > > >HKEY_CURRENT_USER\Software\JavaSoft\Prefs
> > >
> > > Is HKEY_CURRENT_USER an alias for whomever is actually signed on right
> > > now? It seems when you poke around in the registry there are large
> > > parts duplicated.
> > >
> > > I found Javasoft/prefs directories also in HKEY_LOCAL_MACHINE and
> > > HKEY_USERS.
> > >
> > > Sun loves to play the shell game.

> >
> > Sun's implementation of the Preferences on Windows
> > goes something like this:
> >
> > User Root:
> > HKEY_CURRENT_USER\Software\JavaSoft\Prefs
> >
> > System Root:
> > HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs
> >
> > The effect is that is you want to share preferences across
> > different users, put them in the System tree, not the User
> > tree. The User tree will change based on the currently
> > logged in user, so the preferences will necessarily be
> > different. THe HKEY_CURRENT_USER hive is actually an
> > alias for one of the hives in the HKEY_USERS hive, matching
> > whoever the current user is.
> >
> > --Joe

>
>



 
Reply With Quote
 
kimbuba
Guest
Posts: n/a
 
      07-18-2003

>Try looking at the Preferences & PreferencesFactory classes for details of
> how you can provide your own preferences store.
>


yes but in that way i'll break library standard.
I think i'm going to go with the java.util.Properties
I'll use preferences only for stand alone app.

Thnx.


 
Reply With Quote
 
Patrick Thrapp
Guest
Posts: n/a
 
      07-18-2003
"kimbuba" <(E-Mail Removed)> wrote in message
news:0BSRa.14774$(E-Mail Removed). ..
>
> >Try looking at the Preferences & PreferencesFactory classes for details

of
> > how you can provide your own preferences store.
> >

>
> yes but in that way i'll break library standard.
> I think i'm going to go with the java.util.Properties
> I'll use preferences only for stand alone app.


You might also have a look at the following article.

XML for Flexible Configuration
Use XML as the basis for flexible configuration files by implementing the
XMLConfig infrastructure
by Claude Duguay
http://www.fawcette.com/xmlmag/2001_...ak/default.asp



 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-18-2003
On Fri, 18 Jul 2003 15:27:23 +0200, "kimbuba"
<(E-Mail Removed)> wrote or quoted :

>
> >Try looking at the Preferences & PreferencesFactory classes for details of
>> how you can provide your own preferences store.


If you don't need the nested structure, plain old Properties will do
fine. They are effectively Hashtables with a simple key1=value text
file external representation.

see http://mindprod.com/jgloss/properties.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
kimbuba
Guest
Posts: n/a
 
      07-20-2003
i guess ur right.
I will try to understand java's Preferences implementation.

Thnx!


"Andy Flowers" <(E-Mail Removed)> ha scritto nel messaggio
news:R26Sa.760$(E-Mail Removed)...
> Why would it break the standard library ?
>
> All you do is provide a PreferencesFactory which returns an instance of

some
> subclass of AbstractPreferences you create. You then provide the right
> command line parameter to your application to specify which
> PreferencesFactory to use and voila, preferences are stord where you want
> them to be stored which may be a database or a centralised file system.
>
> To the application you write there will be no difference. It will still

use
> the Preferences API in all it's glory, all that will be different is that
> operations will use you class.
>
> "kimbuba" <(E-Mail Removed)> wrote in message
> news:0BSRa.14774$(E-Mail Removed). ..
> >
> > >Try looking at the Preferences & PreferencesFactory classes for

details
> of
> > > how you can provide your own preferences store.
> > >

> >
> > yes but in that way i'll break library standard.
> > I think i'm going to go with the java.util.Properties
> > I'll use preferences only for stand alone app.
> >
> > Thnx.
> >
> >

>
>



 
Reply With Quote
 
kimbuba
Guest
Posts: n/a
 
      07-20-2003
thnx 4 the mini tutorial!



"Roedy Green" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
> On Fri, 18 Jul 2003 15:27:23 +0200, "kimbuba"
> <(E-Mail Removed)> wrote or quoted :
>
> >
> > >Try looking at the Preferences & PreferencesFactory classes for details

of
> >> how you can provide your own preferences store.

>
> If you don't need the nested structure, plain old Properties will do
> fine. They are effectively Hashtables with a simple key1=value text
> file external representation.
>
> see http://mindprod.com/jgloss/properties.html
>
> --
> Canadian Mind Products, Roedy Green.
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments