2003-12-19 19:17:36 +01:00
|
|
|
/**
|
2004-11-03 00:53:30 +01:00
|
|
|
* $RCSfile$
|
|
|
|
* $Revision$
|
|
|
|
* $Date$
|
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2004-11-03 00:53:30 +01:00
|
|
|
*
|
|
|
|
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2003-12-19 19:17:36 +01:00
|
|
|
|
|
|
|
package org.jivesoftware.smack;
|
|
|
|
|
2014-01-16 06:14:39 +01:00
|
|
|
import java.io.IOException;
|
2006-03-09 03:34:27 +01:00
|
|
|
import java.io.InputStream;
|
2013-01-04 12:43:35 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
2014-01-16 06:14:39 +01:00
|
|
|
import java.util.Collections;
|
2013-01-04 12:43:35 +01:00
|
|
|
import java.util.List;
|
2014-01-16 06:14:39 +01:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2013-01-04 12:43:35 +01:00
|
|
|
|
2013-10-06 01:14:24 +02:00
|
|
|
import org.jivesoftware.smack.parsing.ExceptionThrowingCallback;
|
2014-01-16 06:14:39 +01:00
|
|
|
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
|
|
|
|
import org.jivesoftware.smack.util.FileUtils;
|
2013-01-04 12:43:35 +01:00
|
|
|
import org.xmlpull.mxp1.MXParser;
|
|
|
|
import org.xmlpull.v1.XmlPullParser;
|
2003-12-19 19:17:36 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents the configuration of Smack. The configuration is used for:
|
|
|
|
* <ul>
|
|
|
|
* <li> Initializing classes by loading them at start-up.
|
|
|
|
* <li> Getting the current Smack version.
|
2004-04-18 20:11:26 +02:00
|
|
|
* <li> Getting and setting global library behavior, such as the period of time
|
|
|
|
* to wait for replies to packets from the server. Note: setting these values
|
|
|
|
* via the API will override settings in the configuration file.
|
2003-12-19 19:17:36 +01:00
|
|
|
* </ul>
|
2004-04-18 20:11:26 +02:00
|
|
|
*
|
|
|
|
* Configuration settings are stored in META-INF/smack-config.xml (typically inside the
|
|
|
|
* smack.jar file).
|
2003-12-19 19:17:36 +01:00
|
|
|
*
|
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
|
|
|
public final class SmackConfiguration {
|
2013-10-07 04:42:12 +02:00
|
|
|
private static final String SMACK_VERSION = "3.3.1";
|
2014-01-16 06:14:39 +01:00
|
|
|
private static final String DEFAULT_CONFIG_FILE = "classpath:META-INF/smack-config.xml";
|
|
|
|
|
|
|
|
private static final Logger log = Logger.getLogger(SmackConfiguration.class.getName());
|
|
|
|
|
|
|
|
private static InputStream configFileStream;
|
|
|
|
|
2004-03-15 19:59:41 +01:00
|
|
|
private static int packetReplyTimeout = 5000;
|
|
|
|
private static int keepAliveInterval = 30000;
|
2014-01-16 06:14:39 +01:00
|
|
|
private static List<String> defaultMechs = new ArrayList<String>();
|
2003-12-19 19:17:36 +01:00
|
|
|
|
2010-08-15 13:57:11 +02:00
|
|
|
private static boolean localSocks5ProxyEnabled = true;
|
2012-01-27 22:30:09 +01:00
|
|
|
private static int localSocks5ProxyPort = 7777;
|
2011-06-18 20:18:03 +02:00
|
|
|
private static int packetCollectorSize = 5000;
|
2014-01-16 06:14:39 +01:00
|
|
|
|
|
|
|
private static boolean initialized = false;
|
2010-08-15 13:57:11 +02:00
|
|
|
|
2013-06-22 19:01:40 +02:00
|
|
|
/**
|
2013-10-06 01:14:24 +02:00
|
|
|
* The default parsing exception callback is {@link ExceptionThrowingCallback} which will
|
2013-06-22 19:01:40 +02:00
|
|
|
* throw an exception and therefore disconnect the active connection.
|
|
|
|
*/
|
2013-10-06 01:14:24 +02:00
|
|
|
private static ParsingExceptionCallback defaultCallback = new ExceptionThrowingCallback();
|
2013-06-22 19:01:40 +02:00
|
|
|
|
2013-03-18 09:50:48 +01:00
|
|
|
/**
|
|
|
|
* This automatically enables EntityCaps for new connections if it is set to true
|
|
|
|
*/
|
2013-06-22 19:01:58 +02:00
|
|
|
private static boolean autoEnableEntityCaps = true;
|
2013-03-18 09:50:48 +01:00
|
|
|
|
2003-12-19 19:17:36 +01:00
|
|
|
private SmackConfiguration() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-04-18 20:11:26 +02:00
|
|
|
* Loads the configuration from the smack-config.xml file.<p>
|
2003-12-19 19:17:36 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2014-01-16 06:14:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the location of the config file on the classpath. Only required if changing from the default location of <i>classpath:META-INF/smack-config.xml</i>.
|
|
|
|
*
|
|
|
|
* <p>
|
|
|
|
* This method must be called before accessing any other class in Smack.
|
|
|
|
*
|
|
|
|
* @param configFileUrl The location of the config file.
|
|
|
|
* @param loader The classloader to use if the URL has a protocol of <b>classpath</> and the file is not located on the default classpath.
|
|
|
|
* This can be set to null to use defaults and is ignored for all other protocols.
|
|
|
|
* @throws IllegalArgumentException If the config URL is invalid in that it cannot open an {@link InputStream}
|
|
|
|
*/
|
|
|
|
public static void setConfigFileUrl(String configFileUrl, ClassLoader loader) {
|
2003-12-19 19:17:36 +01:00
|
|
|
try {
|
2014-01-16 06:14:39 +01:00
|
|
|
configFileStream = FileUtils.getStreamForUrl(configFileUrl, loader);
|
|
|
|
}
|
2003-12-19 19:17:36 +01:00
|
|
|
catch (Exception e) {
|
2014-01-16 06:14:39 +01:00
|
|
|
throw new IllegalArgumentException("Failed to create input stream from specified file URL ["+ configFileUrl + "]", e);
|
|
|
|
}
|
|
|
|
initialize();
|
2003-12-19 19:17:36 +01:00
|
|
|
}
|
2014-01-16 06:14:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the {@link InputStream} representing the smack configuration file. This can be used to override the default with something that is not on the classpath.
|
|
|
|
* <p>
|
|
|
|
* This method must be called before accessing any other class in Smack.
|
|
|
|
* @param configFile
|
|
|
|
*/
|
|
|
|
public static void setConfigFileStream(InputStream configFile) {
|
|
|
|
configFileStream = configFile;
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
2003-12-19 19:17:36 +01:00
|
|
|
/**
|
2004-08-09 23:13:36 +02:00
|
|
|
* Returns the Smack version information, eg "1.3.0".
|
2003-12-19 19:17:36 +01:00
|
|
|
*
|
2004-03-15 19:59:41 +01:00
|
|
|
* @return the Smack version information.
|
2003-12-19 19:17:36 +01:00
|
|
|
*/
|
2004-03-15 19:59:41 +01:00
|
|
|
public static String getVersion() {
|
|
|
|
return SMACK_VERSION;
|
2003-12-19 19:17:36 +01:00
|
|
|
}
|
|
|
|
|
2004-01-02 00:19:37 +01:00
|
|
|
/**
|
|
|
|
* Returns the number of milliseconds to wait for a response from
|
2004-03-15 19:59:41 +01:00
|
|
|
* the server. The default value is 5000 ms.
|
2004-01-02 00:19:37 +01:00
|
|
|
*
|
|
|
|
* @return the milliseconds to wait for a response from the server
|
|
|
|
*/
|
|
|
|
public static int getPacketReplyTimeout() {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
|
|
|
|
2004-09-24 04:12:47 +02:00
|
|
|
// The timeout value must be greater than 0 otherwise we will answer the default value
|
|
|
|
if (packetReplyTimeout <= 0) {
|
2006-08-03 00:31:23 +02:00
|
|
|
packetReplyTimeout = 5000;
|
2004-09-24 04:12:47 +02:00
|
|
|
}
|
2004-01-02 00:19:37 +01:00
|
|
|
return packetReplyTimeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the number of milliseconds to wait for a response from
|
|
|
|
* the server.
|
|
|
|
*
|
|
|
|
* @param timeout the milliseconds to wait for a response from the server
|
|
|
|
*/
|
|
|
|
public static void setPacketReplyTimeout(int timeout) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
|
|
|
|
2004-09-24 04:12:47 +02:00
|
|
|
if (timeout <= 0) {
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
}
|
2004-01-02 00:19:37 +01:00
|
|
|
packetReplyTimeout = timeout;
|
|
|
|
}
|
|
|
|
|
2004-03-15 19:59:41 +01:00
|
|
|
/**
|
|
|
|
* Returns the number of milleseconds delay between sending keep-alive
|
|
|
|
* requests to the server. The default value is 30000 ms. A value of -1
|
|
|
|
* mean no keep-alive requests will be sent to the server.
|
|
|
|
*
|
|
|
|
* @return the milliseconds to wait between keep-alive requests, or -1 if
|
|
|
|
* no keep-alive should be sent.
|
|
|
|
*/
|
|
|
|
public static int getKeepAliveInterval() {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2004-03-15 19:59:41 +01:00
|
|
|
return keepAliveInterval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the number of milleseconds delay between sending keep-alive
|
|
|
|
* requests to the server. The default value is 30000 ms. A value of -1
|
|
|
|
* mean no keep-alive requests will be sent to the server.
|
|
|
|
*
|
|
|
|
* @param interval the milliseconds to wait between keep-alive requests,
|
|
|
|
* or -1 if no keep-alive should be sent.
|
|
|
|
*/
|
|
|
|
public static void setKeepAliveInterval(int interval) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2004-03-15 19:59:41 +01:00
|
|
|
keepAliveInterval = interval;
|
|
|
|
}
|
|
|
|
|
2011-06-18 20:18:03 +02:00
|
|
|
/**
|
|
|
|
* Gets the default max size of a packet collector before it will delete
|
|
|
|
* the older packets.
|
|
|
|
*
|
|
|
|
* @return The number of packets to queue before deleting older packets.
|
|
|
|
*/
|
|
|
|
public static int getPacketCollectorSize() {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2011-06-18 20:18:03 +02:00
|
|
|
return packetCollectorSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the default max size of a packet collector before it will delete
|
|
|
|
* the older packets.
|
|
|
|
*
|
|
|
|
* @param The number of packets to queue before deleting older packets.
|
|
|
|
*/
|
|
|
|
public static void setPacketCollectorSize(int collectorSize) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2011-06-18 20:18:03 +02:00
|
|
|
packetCollectorSize = collectorSize;
|
|
|
|
}
|
|
|
|
|
2007-11-14 17:27:47 +01:00
|
|
|
/**
|
|
|
|
* Add a SASL mechanism to the list to be used.
|
|
|
|
*
|
|
|
|
* @param mech the SASL mechanism to be added
|
|
|
|
*/
|
|
|
|
public static void addSaslMech(String mech) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
|
|
|
|
2007-11-14 17:27:47 +01:00
|
|
|
if(! defaultMechs.contains(mech) ) {
|
|
|
|
defaultMechs.add(mech);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a Collection of SASL mechanisms to the list to be used.
|
|
|
|
*
|
|
|
|
* @param mechs the Collection of SASL mechanisms to be added
|
|
|
|
*/
|
|
|
|
public static void addSaslMechs(Collection<String> mechs) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
|
|
|
|
2007-11-14 17:27:47 +01:00
|
|
|
for(String mech : mechs) {
|
|
|
|
addSaslMech(mech);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a SASL mechanism from the list to be used.
|
|
|
|
*
|
|
|
|
* @param mech the SASL mechanism to be removed
|
|
|
|
*/
|
|
|
|
public static void removeSaslMech(String mech) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
|
|
|
defaultMechs.remove(mech);
|
2007-11-14 17:27:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a Collection of SASL mechanisms to the list to be used.
|
|
|
|
*
|
|
|
|
* @param mechs the Collection of SASL mechanisms to be removed
|
|
|
|
*/
|
|
|
|
public static void removeSaslMechs(Collection<String> mechs) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
|
|
|
defaultMechs.removeAll(mechs);
|
2007-11-14 17:27:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of SASL mechanisms to be used. If a SASL mechanism is
|
|
|
|
* listed here it does not guarantee it will be used. The server may not
|
|
|
|
* support it, or it may not be implemented.
|
|
|
|
*
|
|
|
|
* @return the list of SASL mechanisms to be used.
|
|
|
|
*/
|
|
|
|
public static List<String> getSaslMechs() {
|
2014-01-16 06:14:39 +01:00
|
|
|
return Collections.unmodifiableList(defaultMechs);
|
2007-11-14 17:27:47 +01:00
|
|
|
}
|
|
|
|
|
2010-08-15 13:57:11 +02:00
|
|
|
/**
|
|
|
|
* Returns true if the local Socks5 proxy should be started. Default is true.
|
|
|
|
*
|
|
|
|
* @return if the local Socks5 proxy should be started
|
|
|
|
*/
|
|
|
|
public static boolean isLocalSocks5ProxyEnabled() {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2010-08-15 13:57:11 +02:00
|
|
|
return localSocks5ProxyEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets if the local Socks5 proxy should be started. Default is true.
|
|
|
|
*
|
|
|
|
* @param localSocks5ProxyEnabled if the local Socks5 proxy should be started
|
|
|
|
*/
|
|
|
|
public static void setLocalSocks5ProxyEnabled(boolean localSocks5ProxyEnabled) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2010-08-15 13:57:11 +02:00
|
|
|
SmackConfiguration.localSocks5ProxyEnabled = localSocks5ProxyEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the port of the local Socks5 proxy. Default is 7777.
|
|
|
|
*
|
|
|
|
* @return the port of the local Socks5 proxy
|
|
|
|
*/
|
|
|
|
public static int getLocalSocks5ProxyPort() {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2010-08-15 13:57:11 +02:00
|
|
|
return localSocks5ProxyPort;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the port of the local Socks5 proxy. Default is 7777. If you set the port to a negative
|
|
|
|
* value Smack tries the absolute value and all following until it finds an open port.
|
|
|
|
*
|
|
|
|
* @param localSocks5ProxyPort the port of the local Socks5 proxy to set
|
|
|
|
*/
|
|
|
|
public static void setLocalSocks5ProxyPort(int localSocks5ProxyPort) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2010-08-15 13:57:11 +02:00
|
|
|
SmackConfiguration.localSocks5ProxyPort = localSocks5ProxyPort;
|
|
|
|
}
|
|
|
|
|
2013-02-27 23:49:04 +01:00
|
|
|
/**
|
2013-03-18 09:50:48 +01:00
|
|
|
* Check if Entity Caps are enabled as default for every new connection
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public static boolean autoEnableEntityCaps() {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2013-03-18 09:50:48 +01:00
|
|
|
return autoEnableEntityCaps;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set if Entity Caps are enabled or disabled for every new connection
|
|
|
|
*
|
|
|
|
* @param true if Entity Caps should be auto enabled, false if not
|
|
|
|
*/
|
|
|
|
public static void setAutoEnableEntityCaps(boolean b) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2013-03-18 09:50:48 +01:00
|
|
|
autoEnableEntityCaps = b;
|
|
|
|
}
|
|
|
|
|
2013-06-22 19:01:40 +02:00
|
|
|
/**
|
|
|
|
* Set the default parsing exception callback for all newly created connections
|
|
|
|
*
|
|
|
|
* @param callback
|
|
|
|
* @see ParsingExceptionCallback
|
|
|
|
*/
|
|
|
|
public static void setDefaultParsingExceptionCallback(ParsingExceptionCallback callback) {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2013-06-22 19:01:40 +02:00
|
|
|
defaultCallback = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the default parsing exception callback
|
|
|
|
*
|
|
|
|
* @return the default parsing exception callback
|
|
|
|
* @see ParsingExceptionCallback
|
|
|
|
*/
|
|
|
|
public static ParsingExceptionCallback getDefaultParsingExceptionCallback() {
|
2014-01-16 06:14:39 +01:00
|
|
|
initialize();
|
2013-06-22 19:01:40 +02:00
|
|
|
return defaultCallback;
|
|
|
|
}
|
|
|
|
|
2004-03-15 19:59:41 +01:00
|
|
|
private static void parseClassToLoad(XmlPullParser parser) throws Exception {
|
|
|
|
String className = parser.nextText();
|
|
|
|
// Attempt to load the class so that the class can get initialized
|
|
|
|
try {
|
2014-01-16 06:14:39 +01:00
|
|
|
Class<?> initClass = Class.forName(className);
|
|
|
|
|
|
|
|
if (SmackInitializer.class.isAssignableFrom(initClass)) {
|
|
|
|
SmackInitializer initializer = (SmackInitializer) initClass.newInstance();
|
|
|
|
initializer.initialize();
|
|
|
|
}
|
2004-03-15 19:59:41 +01:00
|
|
|
}
|
|
|
|
catch (ClassNotFoundException cnfe) {
|
2014-01-16 06:14:39 +01:00
|
|
|
log.log(Level.WARNING, "A startup class [" + className + "] specified in smack-config.xml could not be loaded: ");
|
2004-03-15 19:59:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int parseIntProperty(XmlPullParser parser, int defaultValue)
|
|
|
|
throws Exception
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
return Integer.parseInt(parser.nextText());
|
|
|
|
}
|
|
|
|
catch (NumberFormatException nfe) {
|
2014-01-16 06:14:39 +01:00
|
|
|
log.log(Level.SEVERE, "Could not parse integer", nfe);
|
2004-03-15 19:59:41 +01:00
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-16 06:14:39 +01:00
|
|
|
/*
|
|
|
|
* Order of precedence for config file is VM arg, setConfigXXX methods and embedded default file location.
|
2003-12-19 19:17:36 +01:00
|
|
|
*/
|
2014-01-16 06:14:39 +01:00
|
|
|
private static void initialize() {
|
|
|
|
if (initialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
initialized = true;
|
|
|
|
|
|
|
|
String configFileLocation = System.getProperty("smack.config.file");
|
|
|
|
|
|
|
|
if (configFileLocation != null) {
|
|
|
|
try {
|
|
|
|
configFileStream = FileUtils.getStreamForUrl(configFileLocation, null);
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
log.log(Level.SEVERE, "Error creating input stream for config file [" + configFileLocation + "] from VM argument", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (configFileStream == null) {
|
|
|
|
try {
|
|
|
|
configFileStream = FileUtils.getStreamForUrl(DEFAULT_CONFIG_FILE, null);
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
log.log(Level.INFO, "Could not create input stream for default config file [" + DEFAULT_CONFIG_FILE + "]", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (configFileStream != null) {
|
|
|
|
readFile(configFileStream);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
log.log(Level.INFO, "No configuration file found");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void readFile(InputStream cfgFileStream) {
|
|
|
|
XmlPullParser parser = new MXParser();
|
|
|
|
try {
|
|
|
|
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
|
|
|
parser.setInput(cfgFileStream, "UTF-8");
|
|
|
|
int eventType = parser.getEventType();
|
|
|
|
do {
|
|
|
|
if (eventType == XmlPullParser.START_TAG) {
|
|
|
|
if (parser.getName().equals("className")) {
|
|
|
|
// Attempt to load the class so that the class can get initialized
|
|
|
|
parseClassToLoad(parser);
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("packetReplyTimeout")) {
|
|
|
|
packetReplyTimeout = parseIntProperty(parser, packetReplyTimeout);
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("keepAliveInterval")) {
|
|
|
|
keepAliveInterval = parseIntProperty(parser, keepAliveInterval);
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("mechName")) {
|
|
|
|
defaultMechs.add(parser.nextText());
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("localSocks5ProxyEnabled")) {
|
|
|
|
localSocks5ProxyEnabled = Boolean.parseBoolean(parser.nextText());
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("localSocks5ProxyPort")) {
|
|
|
|
localSocks5ProxyPort = parseIntProperty(parser, localSocks5ProxyPort);
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("packetCollectorSize")) {
|
|
|
|
packetCollectorSize = parseIntProperty(parser, packetCollectorSize);
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("autoEnableEntityCaps")) {
|
|
|
|
autoEnableEntityCaps = Boolean.parseBoolean(parser.nextText());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eventType = parser.next();
|
|
|
|
} while (eventType != XmlPullParser.END_DOCUMENT);
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.log(Level.SEVERE, "Error occurred while reading config file", e);
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
try {
|
|
|
|
cfgFileStream.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.log(Level.INFO, "Error while closing config file input stream", e);
|
2006-08-03 00:31:23 +02:00
|
|
|
}
|
|
|
|
}
|
2003-12-19 19:17:36 +01:00
|
|
|
}
|
|
|
|
}
|