I'm committing these changes to the GConf preference backed, as discussed in my previous mail.
Thanks, Mario 2007-11-23 Mario Torre <[EMAIL PROTECTED]> * gnu/java/util/prefs/EventDispatcher.java: class removed. * gnu/classpath/toolkit/DefaultDaemonThreadFactory.java: new file. * java/util/prefs/AbstractPreferences.java: (fire(PreferenceChangeEvent)): Use DefaultDaemonThreadFactory and Executors.newSingleThreadExecutor instead of EventDispatcher. Import statement refactored accordingly. Also refactored to use 1.5 enhanced for loop and generics. (fire(NodeChangeEvent, boolean)): likewise. * gnu/java/util/prefs/GConfBasedPreferences.java (childSpi): removed startWatchingNode call. * gnu/java/util/prefs/gconf/GConfNativePeer.java: (GConfNativePeer): removed use of semaphore. (gconf_all_nodes): method name shortened, renamed from gconf_client_all_nodes (removed client_ from method signature) and declared synchronized. (gconf_suggest_sync): likewise. (gconf_get_string): likewise. (gconf_unescape_key): likewise. (gconf_set_string): likewise. (gconf_escape_key): likewise. (gconf_all_keys): likewise. (gconf_dir_exists): likewise. (getKeys): refactored to use new native method name. (getKey): likewise. (setString): likewise. (getChildrenNodes): likewise. (unset): likewise. (suggestSync): likewise. (finalize): likewise. (nodeExist): likewise. (gconf_client_add_dir): removed, not needed anymore. (gconf_client_remove_dir): likewise. (startWatchingNode): likewise. (stopWatchingNode): likewise. * native/jni/conf-peer/GConfNativePeer.c: All native methods renamed to match changes in GConfNativePeer.java Now use GConfEngine instead of GConfClient. Removed gdk_thread_enter/leave locking from all methods. (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir): removed. (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists): likewise. * include/gnu_java_util_prefs_gconf_GConfNativePeer.h: regenerated. -- Lima Software - http://www.limasoftware.net/ GNU Classpath Developer - http://www.classpath.org/ Fedora Ambassador - http://fedoraproject.org/wiki/MarioTorre Jabber: [EMAIL PROTECTED] pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF Please, support open standards: http://opendocumentfellowship.org/petition/ http://www.nosoftwarepatents.com/
### Eclipse Workspace Patch 1.0 #P classpath Index: gnu/java/util/prefs/gconf/GConfNativePeer.java =================================================================== RCS file: /sources/classpath/classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java,v retrieving revision 1.4 diff -u -r1.4 GConfNativePeer.java --- gnu/java/util/prefs/gconf/GConfNativePeer.java 18 Dec 2006 16:47:10 -0000 1.4 +++ gnu/java/util/prefs/gconf/GConfNativePeer.java 21 Nov 2007 00:49:09 -0000 @@ -49,19 +49,11 @@ public final class GConfNativePeer { /** - * Object to achieve locks for methods that need to be synchronized. - */ - private static final Object[] semaphore = new Object[0]; - - /** * Creates a new instance of GConfNativePeer */ public GConfNativePeer() { - synchronized (semaphore) - { - init_class(); - } + init_class(); } /** @@ -72,31 +64,7 @@ */ public boolean nodeExist(String node) { - return gconf_client_dir_exists(node); - } - - /** - * Add the node <code>node</code> to the list of nodes the GConf will watch. - * An event is raised everytime this node is changed. You can add a node - * multiple times. - * - * @param node the node to track. - */ - public void startWatchingNode(String node) - { - gconf_client_add_dir(node); - } - - /** - * Remove the node <code>node</code> to the list of nodes the GConf is - * watching. Note that if a node has been added multiple times, you must - * remove it the same number of times before the remove takes effect. - * - * @param node the node you don't want to track anymore. - */ - public void stopWatchingNode(String node) - { - gconf_client_remove_dir(node); + return gconf_dir_exists(node); } /** @@ -111,7 +79,7 @@ */ public boolean setString(String key, String value) { - return gconf_client_set_string(key, value); + return gconf_set_string(key, value); } /** @@ -124,7 +92,7 @@ */ public boolean unset(String key) { - return gconf_client_unset(key); + return gconf_unset(key); } /** @@ -135,7 +103,7 @@ */ public String getKey(String key) { - return gconf_client_get_string(key); + return gconf_get_string(key); } /** @@ -149,7 +117,7 @@ */ public List<String> getKeys(String node) throws BackingStoreException { - return gconf_client_all_keys(node); + return gconf_all_keys(node); } /** @@ -161,7 +129,7 @@ */ public List<String> getChildrenNodes(String node) throws BackingStoreException { - return gconf_client_all_nodes(node); + return gconf_all_nodes(node); } /** @@ -185,17 +153,14 @@ */ public void suggestSync() throws BackingStoreException { - gconf_client_suggest_sync(); + gconf_suggest_sync(); } protected void finalize() throws Throwable { try { - synchronized (semaphore) - { - finalize_class(); - } + finalize_class(); } finally { @@ -215,18 +180,18 @@ * Initialize the GConf native peer and enable the object cache. * It is meant to be used by the static initializer. */ - native static final private void init_id_cache(); + native synchronized static final private void init_id_cache(); /** * Initialize the GConf native peer. This is meant to be used by the * class constructor. */ - native static final private void init_class(); + native synchronized static final private void init_class(); /** * Class finalizer. */ - native static final private void finalize_class(); + native synchronized static final private void finalize_class(); /** * Queries the GConf database to see if the given node exists, returning @@ -235,23 +200,8 @@ * @param node the node to query for existence. * @return true if the node exist, false otherwise. */ - native static final protected boolean gconf_client_dir_exists(String node); - - /** - * Adds the given node to the list of nodes that GConf watches for - * changes. - * - * @param node the node to watch for changes. - */ - native static final protected void gconf_client_add_dir(String node); - - /** - * Removes the given node from the list of nodes that GConf watches for - * changes. - * - * @param node the node to remove from from the list of watched nodes. - */ - native static final protected void gconf_client_remove_dir(String node); + native synchronized + static final protected boolean gconf_dir_exists(String node); /** * Sets the given key/value pair into the GConf database. @@ -261,8 +211,8 @@ * @param value the value to associate to the given key. * @return true if the change has effect, false otherwise. */ - native static final protected boolean gconf_client_set_string(String key, - String value); + native synchronized + static final protected boolean gconf_set_string(String key, String value); /** * Returns the key associated to the given key. Null is returned if the @@ -271,7 +221,8 @@ * @param key the key to return the value of. * @return The value associated to the given key, or null. */ - native static final protected String gconf_client_get_string(String key); + native synchronized + static final protected String gconf_get_string(String key); /** * Usets the given key, removing the key from the database. @@ -279,13 +230,13 @@ * @param key the key to remove. * @return true if the operation success, false otherwise. */ - native static final protected boolean gconf_client_unset(String key); + native synchronized static final protected boolean gconf_unset(String key); /** * Suggest to the GConf native peer a sync with the database. * */ - native static final protected void gconf_client_suggest_sync() + native synchronized static final protected void gconf_suggest_sync() throws BackingStoreException; /** @@ -295,7 +246,7 @@ * @return A list of nodes under the given source node. */ native - static final protected List<String> gconf_client_all_nodes(String node) + static synchronized final protected List<String> gconf_all_nodes(String node) throws BackingStoreException; /** @@ -304,8 +255,8 @@ * @param node the source node. * @return A list of all keys stored in the given node. */ - native - static final protected List<String> gconf_client_all_keys(String node) + native synchronized + static final protected List<String> gconf_all_keys(String node) throws BackingStoreException; /** @@ -314,7 +265,7 @@ * @param plain the String to escape. * @return An escaped String for use with GConf. */ - native + native synchronized static final protected String gconf_escape_key(String plain); /** @@ -324,7 +275,7 @@ * @param escaped key as returned by gconf_escape_key * @return An unescaped key. */ - native + native synchronized static final protected String gconf_unescape_key(String escaped); static Index: include/gnu_java_util_prefs_gconf_GConfNativePeer.h =================================================================== RCS file: /sources/classpath/classpath/include/gnu_java_util_prefs_gconf_GConfNativePeer.h,v retrieving revision 1.2 diff -u -r1.2 gnu_java_util_prefs_gconf_GConfNativePeer.h --- include/gnu_java_util_prefs_gconf_GConfNativePeer.h 27 Sep 2006 18:36:09 -0000 1.2 +++ include/gnu_java_util_prefs_gconf_GConfNativePeer.h 21 Nov 2007 00:49:09 -0000 @@ -1,10 +1,10 @@ /* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> + #ifndef __gnu_java_util_prefs_gconf_GConfNativePeer__ #define __gnu_java_util_prefs_gconf_GConfNativePeer__ -#include <jni.h> - #ifdef __cplusplus extern "C" { @@ -13,15 +13,13 @@ JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache (JNIEnv *env, jclass); JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class (JNIEnv *env, jclass); JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class (JNIEnv *env, jclass); -JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists (JNIEnv *env, jclass, jstring); -JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir (JNIEnv *env, jclass, jstring); -JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir (JNIEnv *env, jclass, jstring); -JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string (JNIEnv *env, jclass, jstring, jstring); -JNIEXPORT jstring JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string (JNIEnv *env, jclass, jstring); -JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset (JNIEnv *env, jclass, jstring); -JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1suggest_1sync (JNIEnv *env, jclass); -JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1nodes (JNIEnv *env, jclass, jstring); -JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1keys (JNIEnv *env, jclass, jstring); +JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1dir_1exists (JNIEnv *env, jclass, jstring); +JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1set_1string (JNIEnv *env, jclass, jstring, jstring); +JNIEXPORT jstring JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1get_1string (JNIEnv *env, jclass, jstring); +JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unset (JNIEnv *env, jclass, jstring); +JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1suggest_1sync (JNIEnv *env, jclass); +JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1nodes (JNIEnv *env, jclass, jstring); +JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1keys (JNIEnv *env, jclass, jstring); JNIEXPORT jstring JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1escape_1key (JNIEnv *env, jclass, jstring); JNIEXPORT jstring JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unescape_1key (JNIEnv *env, jclass, jstring); Index: gnu/java/util/prefs/EventDispatcher.java =================================================================== RCS file: gnu/java/util/prefs/EventDispatcher.java diff -N gnu/java/util/prefs/EventDispatcher.java --- gnu/java/util/prefs/EventDispatcher.java 18 Dec 2006 16:47:09 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,113 +0,0 @@ -/* EventDispatcher.java -- Dispatch events for prefs - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.java.util.prefs; - -import java.util.ArrayList; - -/** - * This is a helper class used for dispatching events for - * the prefs package. - */ -public class EventDispatcher extends Thread -{ - // This is a singleton class. We dispatch all events via a - // new Thread which is created on demand. - private static final Thread dispatchThread = new EventDispatcher(); - - // This is a queue of events to dispatch. This thread waits on - // the queue and when notified will remove events until the queue - // is empty. - private static final ArrayList<Runnable> queue = new ArrayList<Runnable>(); - - // FIXME: this thread probably ought to go in some classpath-internal - // ThreadGroup. But we don't have that yet. - private EventDispatcher() - { - setDaemon(true); - start(); - } - - public void run() - { - while (true) - { - Runnable r; - synchronized (queue) - { - while (queue.size() == 0) - { - try - { - queue.wait(); - } - catch (InterruptedException _) - { - // Ignore. - } - } - r = queue.remove(0); - } - // Invoke outside the synchronization, so that - // we aren't blocking other threads from posting events. - try - { - r.run(); - } - catch (Throwable _) - { - // Ignore. - } - } - } - - /** - * Add a new runnable to the event dispatch queue. The - * runnable will be invoked in the event dispatch queue - * without any locks held. - * @param runner the Runnable to dispatch - */ - public static void dispatch(Runnable runner) - { - synchronized (queue) - { - queue.add(runner); - queue.notify(); - } - } -} Index: gnu/java/util/prefs/GConfBasedPreferences.java =================================================================== RCS file: /sources/classpath/classpath/gnu/java/util/prefs/GConfBasedPreferences.java,v retrieving revision 1.4 diff -u -r1.4 GConfBasedPreferences.java --- gnu/java/util/prefs/GConfBasedPreferences.java 18 Dec 2006 16:47:10 -0000 1.4 +++ gnu/java/util/prefs/GConfBasedPreferences.java 21 Nov 2007 00:49:08 -0000 @@ -166,10 +166,6 @@ GConfBasedPreferences preferenceNode = new GConfBasedPreferences(this, name, this.isUser); - // register the node for to GConf so that it can listen - // events outside the scope of the application - backend.startWatchingNode(this.node); - return preferenceNode; } Index: java/util/prefs/AbstractPreferences.java =================================================================== RCS file: /sources/classpath/classpath/java/util/prefs/AbstractPreferences.java,v retrieving revision 1.15 diff -u -r1.15 AbstractPreferences.java --- java/util/prefs/AbstractPreferences.java 18 Dec 2006 16:47:10 -0000 1.15 +++ java/util/prefs/AbstractPreferences.java 21 Nov 2007 00:49:11 -0000 @@ -38,7 +38,7 @@ package java.util.prefs; -import gnu.java.util.prefs.EventDispatcher; +import gnu.classpath.toolkit.DefaultDaemonThreadFactory; import gnu.java.util.prefs.NodeWriter; import java.io.ByteArrayOutputStream; @@ -49,6 +49,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.TreeSet; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; /** * Partial implementation of a Preference node. @@ -1236,17 +1238,18 @@ */ private void fire(final PreferenceChangeEvent event) { - Iterator it = preferenceListeners.iterator(); - while (it.hasNext()) + for (final PreferenceChangeListener listener : preferenceListeners) { - final PreferenceChangeListener l = (PreferenceChangeListener) it.next(); - EventDispatcher.dispatch(new Runnable() - { - public void run() - { - l.preferenceChange(event); - } - }); + Runnable dispatcher = new Runnable() { + public void run() + { + listener.preferenceChange(event); + } + }; + + Executor executor = + Executors.newSingleThreadExecutor(new DefaultDaemonThreadFactory()); + executor.execute(dispatcher); } } @@ -1258,20 +1261,21 @@ */ private void fire(final NodeChangeEvent event, final boolean added) { - Iterator it = nodeListeners.iterator(); - while (it.hasNext()) + for (final NodeChangeListener listener : nodeListeners) { - final NodeChangeListener l = (NodeChangeListener) it.next(); - EventDispatcher.dispatch(new Runnable() - { - public void run() - { - if (added) - l.childAdded(event); - else - l.childRemoved(event); - } - }); + Runnable dispatcher = new Runnable() { + public void run() + { + if (added) + listener.childAdded(event); + else + listener.childRemoved(event); + } + }; + + Executor executor = + Executors.newSingleThreadExecutor(new DefaultDaemonThreadFactory()); + executor.execute(dispatcher); } } Index: native/jni/gconf-peer/GConfNativePeer.c =================================================================== RCS file: /sources/classpath/classpath/native/jni/gconf-peer/GConfNativePeer.c,v retrieving revision 1.9 diff -u -r1.9 GConfNativePeer.c --- native/jni/gconf-peer/GConfNativePeer.c 27 Sep 2006 18:36:09 -0000 1.9 +++ native/jni/gconf-peer/GConfNativePeer.c 21 Nov 2007 00:49:11 -0000 @@ -55,8 +55,8 @@ /** Reference count */ static int reference_count = 0; -/** GConfClient backend */ -static GConfClient *client = NULL; +/** GConfEngine backend */ +static GConfEngine *engine = NULL; /** java.util.ArrayList class */ static jclass jlist_class = NULL; @@ -70,12 +70,10 @@ /* ***** PRIVATE FUNCTIONS DELCARATION ***** */ /** - * Gets the reference of the default GConfClient and initialize the - * the type system. + * Gets the reference of the default GConfEngine.. * The client reference should be released with g_object_unref after use. - * This functions must be called with gdk lock held. */ -static void init_gconf_client (void); +static void init_gconf (void); /** * Throws a new runtime exception after a failure, with the given message. @@ -133,16 +131,14 @@ { reference_count++; - gdk_threads_enter (); - init_gconf_client (); - gdk_threads_leave (); + init_gconf (); - /* if client is null, there is probably an out of memory */ - if (client == NULL) + /* if engine is null, there is probably an out of memory */ + if (engine == NULL) { /* release the string and throw a runtime exception */ throw_exception (env, - "Unable to initialize GConfClient in native code\n"); + "Unable to initialize GConfEngine in native code\n"); return; } @@ -157,11 +153,11 @@ /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_client_all_keys + * Method: gconf_all_keys * Signature: (Ljava/lang/String;)Ljava/util/List; */ JNIEXPORT jobject JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1keys +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1keys (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) { /* TODO: check all the calls to gdk_threads_enter/leave */ @@ -183,9 +179,7 @@ return NULL; } - gdk_threads_enter (); - entries = gconf_client_all_entries (client, dir, &err); - gdk_threads_leave (); + entries = gconf_engine_all_entries (engine, dir, &err); if (err != NULL) { throw_exception_by_name (env, "java/util/prefs/BackingStoreException", @@ -235,11 +229,11 @@ /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_client_all_nodes + * Method: gconf_all_nodes * Signature: (Ljava/lang/String;)Ljava/util/List; */ JNIEXPORT jobject JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1nodes +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1all_1nodes (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) { const char *dir = NULL; @@ -259,9 +253,7 @@ return NULL; } - gdk_threads_enter (); - entries = gconf_client_all_dirs (client, dir, &err); - gdk_threads_leave (); + entries = gconf_engine_all_dirs (engine, dir, &err); if (err != NULL) { throw_exception_by_name (env, "java/util/prefs/BackingStoreException", @@ -311,18 +303,16 @@ /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_client_suggest_sync + * Method: gconf_suggest_sync * Signature: ()V */ JNIEXPORT void JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1suggest_1sync +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1suggest_1sync (JNIEnv *env, jclass clazz __attribute__ ((unused))) { GError *err = NULL; - gdk_threads_enter (); - gconf_client_suggest_sync (client, &err); - gdk_threads_leave (); + gconf_engine_suggest_sync (engine, &err); if (err != NULL) { throw_exception_by_name (env, "java/util/prefs/BackingStoreException", @@ -334,11 +324,11 @@ /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_client_unset + * Method: gconf_unset * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unset (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key) { const char *_key = NULL; @@ -351,9 +341,7 @@ return JNI_FALSE; } - gdk_threads_enter (); - result = gconf_client_unset (client, _key, &err); - gdk_threads_leave (); + result = gconf_engine_unset (engine, _key, &err); if (err != NULL) { result = JNI_FALSE; @@ -368,11 +356,11 @@ /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_client_get_string + * Method: gconf_get_string * Signature: (Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1get_1string (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key) { const char *_key = NULL; @@ -386,9 +374,7 @@ return NULL; } - gdk_threads_enter (); - _value = gconf_client_get_string (client, _key, &err); - gdk_threads_leave (); + _value = gconf_engine_get_string (engine, _key, &err); JCL_free_cstring (env, key, _key); if (err != NULL) { @@ -407,17 +393,19 @@ result = (*env)->NewStringUTF (env, _value); g_free ((gpointer) _value); } - + + gconf_engine_suggest_sync (engine, NULL); + return result; } /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_client_set_string + * Method: gconf_set_string * Signature: (Ljava/lang/String;Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1set_1string (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring key, jstring value) { @@ -435,9 +423,7 @@ return JNI_FALSE; } - gdk_threads_enter (); - result = gconf_client_set_string (client, _key, _value, &err); - gdk_threads_leave (); + result = gconf_engine_set_string (engine, _key, _value, &err); if (err != NULL) { g_error_free (err); @@ -453,56 +439,11 @@ /* * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_client_remove_dir - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1remove_1dir - (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) -{ - const char *dir = NULL; - - dir = JCL_jstring_to_cstring (env, node); - if (dir == NULL) - return; - - gdk_threads_enter (); - gconf_client_remove_dir (client, dir, NULL); - gdk_threads_leave (); - - JCL_free_cstring (env, node, dir); -} - -/* - * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_client_add_dir - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1add_1dir - (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) -{ - const char *dir = NULL; - - dir = JCL_jstring_to_cstring (env, node); - if (dir == NULL) - return; - - /* ignore errors */ - gdk_threads_enter (); - gconf_client_add_dir (client, dir, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gdk_threads_leave (); - - JCL_free_cstring (env, node, dir); -} - -/* - * Class: gnu_java_util_prefs_gconf_GConfNativePeer - * Method: gconf_client_dir_exists + * Method: gconf_dir_exists * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists +Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1dir_1exists (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node) { const char *dir = NULL; @@ -514,9 +455,7 @@ return value; /* on error return false */ - gdk_threads_enter (); - value = gconf_client_dir_exists (client, dir, &err); - gdk_threads_leave (); + value = gconf_engine_dir_exists (engine, dir, &err); if (err != NULL) value = JNI_FALSE; @@ -537,10 +476,8 @@ if (reference_count == 0) { /* last reference, free all resources and return */ - gdk_threads_enter (); - g_object_unref (G_OBJECT (client)); - gdk_threads_leave (); - + g_object_unref (G_OBJECT (engine)); + (*env)->DeleteGlobalRef (env, jlist_class); jlist_class = NULL; @@ -572,9 +509,7 @@ return NULL; } - gdk_threads_enter (); escaped = gconf_escape_key (_plain, strlen (_plain)); - gdk_threads_leave (); JCL_free_cstring (env, plain, _plain); /* check for NULL, if so prevent string creation */ @@ -606,9 +541,7 @@ return NULL; } - gdk_threads_enter (); plain = gconf_unescape_key (_escaped, strlen (_escaped)); - gdk_threads_leave (); JCL_free_cstring (env, escaped, _escaped); /* check for NULL, if so prevent string creation */ @@ -636,10 +569,9 @@ JCL_ThrowException (env, name, msg); } -static void init_gconf_client (void) +static void init_gconf (void) { - g_type_init (); - client = gconf_client_get_default (); + engine = gconf_engine_get_default (); } static gboolean set_jlist_class (JNIEnv *env) Index: gnu/classpath/toolkit/DefaultDaemonThreadFactory.java =================================================================== RCS file: gnu/classpath/toolkit/DefaultDaemonThreadFactory.java diff -N gnu/classpath/toolkit/DefaultDaemonThreadFactory.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/classpath/toolkit/DefaultDaemonThreadFactory.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,59 @@ +/* DefaultDaemonThreadFactory.java -- Factory for Deamon Threads. + + Copyright (C) 2007 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.toolkit; + +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory;; + +/** + * Create a new thread using all the default settings as returned by + * <code>Executors.defaultThreadFactory()</code> plus calling + * <code>thread.setDaemon(true)</code> on the newly created thread. + * + * @author Mario Torre <[EMAIL PROTECTED]> + */ +public class DefaultDaemonThreadFactory implements ThreadFactory +{ + public Thread newThread(Runnable r) + { + Thread thread = Executors.defaultThreadFactory().newThread(r); + thread.setDaemon(true); + return thread; + } +}