-
Notifications
You must be signed in to change notification settings - Fork 13
PreferencesClass
Eric Bodden edited this page Mar 15, 2015
·
1 revision
package java.util.prefs;
Preferences.class
private static PreferencesFactory factory1() {
// 2. Try service provider interface
Iterator i = Service.providers(PreferencesFactory.class,
ClassLoader.getSystemClassLoader());
// choose first provider instance
while (i.hasNext()) {
try {
return (PreferencesFactory) i.next();
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore the security exception, try the next provider
continue;
}
throw sce;
}
}
// 3. Use platform-specific system-wide default
String platformFactory =
System.getProperty("os.name").startsWith("Windows")
? "java.util.prefs.WindowsPreferencesFactory"
: "java.util.prefs.FileSystemPreferencesFactory";
try {
return ()
Class.forName(platformFactory, false, null).newInstance();
} catch (Exception e) {
InternalError error = new InternalError(
"Can't instantiate platform default Preferences factory "PreferencesFactory
+ platformFactory);
error.initCause(e);
throw error;
}
}
// to recover a configuration made before