From a958b245e6c0dbf467006bfbd78511cdd8cb5e0e Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Sun, 18 Apr 2004 18:11:26 +0000 Subject: [PATCH] Fixed logic bug where setting values via the API in SmackConfiguration could be overridden by the config file. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2297 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jivesoftware/smack/SmackConfiguration.java | 16 ++++++++++------ .../org/jivesoftware/smack/XMPPConnection.java | 5 +++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/source/org/jivesoftware/smack/SmackConfiguration.java b/source/org/jivesoftware/smack/SmackConfiguration.java index a262342a9..3a1b09ec4 100644 --- a/source/org/jivesoftware/smack/SmackConfiguration.java +++ b/source/org/jivesoftware/smack/SmackConfiguration.java @@ -63,7 +63,13 @@ import org.xmlpull.v1.*; * + * + * Configuration settings are stored in META-INF/smack-config.xml (typically inside the + * smack.jar file). * * @author Gaston Dombiak */ @@ -78,14 +84,13 @@ public final class SmackConfiguration { } /** - * Loads the configuration from the smack.configuration file.

+ * Loads the configuration from the smack-config.xml file.

* * So far this means that: * 1) a set of classes will be loaded in order to execute their static init block * 2) retrieve and set the current Smack release - * */ - static void init() { + static { try { // Get an array of class loaders to try loading the providers files from. ClassLoader[] classLoaders = getClassLoaders(); @@ -98,8 +103,7 @@ public final class SmackConfiguration { systemStream = url.openStream(); XmlPullParserFactory factory = XmlPullParserFactory.newInstance( - "org.xmlpull.mxp1.MXParserFactory", - null); + "org.xmlpull.mxp1.MXParserFactory", null); factory.setNamespaceAware(true); XmlPullParser parser = factory.newPullParser(); parser.setInput(systemStream, "UTF-8"); @@ -198,7 +202,7 @@ public final class SmackConfiguration { Class.forName(className); } catch (ClassNotFoundException cnfe) { - System.err.println("Error! a startup class specified in smack-config.xml could " + + System.err.println("Error! A startup class specified in smack-config.xml could " + "not be loaded: " + className); } } diff --git a/source/org/jivesoftware/smack/XMPPConnection.java b/source/org/jivesoftware/smack/XMPPConnection.java index 8539dda13..f58b10a47 100644 --- a/source/org/jivesoftware/smack/XMPPConnection.java +++ b/source/org/jivesoftware/smack/XMPPConnection.java @@ -94,6 +94,7 @@ public class XMPPConnection { public static boolean DEBUG_ENABLED = false; private static List connectionEstablishedListeners = new ArrayList(); + static { // Use try block since we may not have permission to get a system // property (for example, when an applet). @@ -102,8 +103,8 @@ public class XMPPConnection { } catch (Exception e) { } - // Initialize Smack with the parameterized configuration - SmackConfiguration.init(); + // Ensure the SmackConfiguration class is loaded by calling a method in it. + SmackConfiguration.getVersion(); } private SmackDebugger debugger = null;