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.*; *
+ * 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;