In my application, I'm currently creating a single instance of a
UserPrefs object at startup, then passing a reference to that object to multiple other objects through their constructors.
I am doing this because it's important that multiple classes have immediate access to any real-time changes the user makes to their preferences during runtime.
The problem is that passing this object to many different constructors seems messy to me, and I'd like to move away from this. So I'm interested in possibly using the
java.util.prefs.Preferences API in each class that needs access to this information. But I get the sense that the
Preferences API is more commonly used to simply save a snapshot of user preferences at application shutdown, then to load them back in during startup.
So my question is: Would
java.util.prefs.Preferences be appropriate in this situation? If not, is there some other way I can share preferences state in real-time across multiple classes?