This patch makes gconf the default backend.

The patch works adding a new configure option that let the user to
specify a default implementation (like FileBased or GConfBased ones).

If the user does not provides this option, than the preference backend
is FileBased (current default).

Only if the GConf backend is built, than it is used, unless the flag
specify a different default.

To make this possible, I have added a new field to
gnu.classpath.Configuration.in, this is inherited from the configure.ac.

Not sure if it is the right place but this avoid to check for the
existence of a class generating exceptions that can slow down the code.

The final change is in java.util.prefs.PreferencesFactory: the
getFactory method now gets the system property from the Configuration
class.

There are no other change in this last class, I left the ability to
revert to a sane default if the user supply an invalid backend.

The property is accessed by this class and not by SystemProperties to
allow checks from the security manager.

Please, remember that I do not have cvs write access: someone should
commit this one for me (and the old one too!!)...

This is the ChangeLog:


2006-07-01  Mario Torre  <[EMAIL PROTECTED]>

        * configure.ac: Added new option --enable-default-preferences-peer
        to pass user specified default preference backend.
        The default backend in now GConf.
        * gnu/classpath/Configuration.java.in (DEFAULT_PREFS_PEER): added new
        field inherited from configure.ac 
        * java/util/prefs/Preferences.java: New inclusion for
        gnu.classpath.Configuration. 
        (getFactory): gets java.util.prefs.PreferencesFactory system property
        from Configuration class.


-- 
Lima Software, SO.PR.IND. s.r.l.
http://www.limasoftware.net/
pgp key: http://subkeys.pgp.net/

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
Index: configure.ac
===================================================================
RCS file: /sources/classpath/classpath/configure.ac,v
retrieving revision 1.168
diff -u -r1.168 configure.ac
--- configure.ac	30 Jun 2006 11:39:15 -0000	1.168
+++ configure.ac	1 Jul 2006 22:29:13 -0000
@@ -83,6 +83,18 @@
 AM_CONDITIONAL(CREATE_CORE_JNI_LIBRARIES, test "x${COMPILE_CORE_JNI}" = xyes)
 
 dnl -----------------------------------------------------------
+dnl Default Preference Backend
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE(default-preferences-peer,
+  AS_HELP_STRING([--enable-default-preferences-peer],
+                 [fully qualified class name of default Preferences API Backend]))
+DEFAULT_PREFS_PEER=$enable_default_preferences_peer
+if test "$DEFAULT_PREFS_PEER" = ""; then
+   DEFAULT_PREFS_PEER=gnu.java.util.prefs.FileBasedFactory
+fi
+dnl AC_SUBST(DEFAULT_PREFS_PEER)
+
+dnl -----------------------------------------------------------
 dnl GConf native peer (enabled by default)
 dnl -----------------------------------------------------------
 AC_ARG_ENABLE([gconf-peer],
@@ -100,7 +112,6 @@
 dnl -----------------------------------------------------------
 AC_ARG_ENABLE([gconf-peers],,AC_MSG_ERROR([No --enable-gconf-peers (or --disable-gconf-peers) option; you want --enable-gconf-peer]))
 
-
 dnl ------------------------------------------------------------
 dnl Whether to compile with -Werror or not (disabled by default)
 dnl ------------------------------------------------------------
@@ -456,6 +467,13 @@
     PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.11.2)
     AC_SUBST(GCONF_CFLAGS)
     AC_SUBST(GCONF_LIBS)
+    dnl check if the config value was given form the command line,
+    dnl if not, overwrite the default if we have the gconf backend
+    dnl compiled in
+    USE_GCONF_PREFS_PEER=$enable_default_preferences_peer
+    if test "$USE_GCONF_PREFS_PEER" = ""; then
+   	DEFAULT_PREFS_PEER=gnu.java.util.prefs.GConfBasedFactory
+    fi
   fi
 
   dnl Check for AWT related Qt4
@@ -745,6 +763,10 @@
 fi
 AM_CONDITIONAL(ENABLE_LOCAL_SOCKETS, test "x$ENABLE_LOCAL_SOCKETS" = "xyes")
 
+dnl -----------------------------------------------------------
+dnl Add the default preference peer
+dnl -----------------------------------------------------------
+AC_SUBST(DEFAULT_PREFS_PEER)
 
 dnl -----------------------------------------------------------
 dnl output files
Index: gnu/classpath/Configuration.java.in
===================================================================
RCS file: /sources/classpath/classpath/gnu/classpath/Configuration.java.in,v
retrieving revision 1.18
diff -u -r1.18 Configuration.java.in
--- gnu/classpath/Configuration.java.in	25 May 2006 15:29:36 -0000	1.18
+++ gnu/classpath/Configuration.java.in	1 Jul 2006 22:29:15 -0000
@@ -84,6 +84,14 @@
    */
   String default_awt_peer_toolkit = "@default_toolkit@";
 
+ /**
+   * This flag is used by the Preference API to define the implementation
+   * to use
+   * Actually, the value of DEFAULT_PREFS_PEER is substituted according to
+   * the "--enable-default-preferences-peer" argument of configure.
+   */
+  String DEFAULT_PREFS_PEER = "@DEFAULT_PREFS_PEER@";
+
   /**
    * Whether to automatically run the init* methods in java.lang.System
    * (the default) at class initialization time or whether to have the VM
Index: java/util/prefs/Preferences.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/prefs/Preferences.java,v
retrieving revision 1.14
diff -u -r1.14 Preferences.java
--- java/util/prefs/Preferences.java	1 Mar 2006 17:10:18 -0000	1.14
+++ java/util/prefs/Preferences.java	1 Jul 2006 22:29:22 -0000
@@ -37,6 +37,7 @@
 
 package java.util.prefs;
 
+import gnu.classpath.Configuration;
 import gnu.java.util.prefs.NodeReader;
 
 import java.io.IOException;
@@ -178,6 +179,9 @@
             sm.checkPermission(prefsPermission);
         }
 
+        System.setProperty("java.util.prefs.PreferencesFactory",
+                           Configuration.DEFAULT_PREFS_PEER);
+                
         // Get the factory
         if (factory == null) {
             // Caller might not have enough permissions

Attachment: signature.asc
Description: Questa รจ una parte del messaggio firmata digitalmente

Reply via email to