2003-12-19 19:17:36 +01:00
|
|
|
/**
|
2004-11-03 00:53:30 +01:00
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2004-11-03 00:53:30 +01:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2004-11-03 00:53:30 +01:00
|
|
|
* 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;
|
|
|
|
|
2019-07-04 15:51:28 +02:00
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
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;
|
2014-02-23 17:48:07 +01:00
|
|
|
import java.util.HashSet;
|
2013-01-04 12:43:35 +01:00
|
|
|
import java.util.List;
|
2014-02-23 17:48:07 +01:00
|
|
|
import java.util.Set;
|
2013-01-04 12:43:35 +01:00
|
|
|
|
2014-07-21 18:42:44 +02:00
|
|
|
import javax.net.ssl.HostnameVerifier;
|
|
|
|
|
2014-03-10 10:20:52 +01:00
|
|
|
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
|
2014-08-18 09:59:28 +02:00
|
|
|
import org.jivesoftware.smack.debugger.ReflectionDebuggerFactory;
|
|
|
|
import org.jivesoftware.smack.debugger.SmackDebuggerFactory;
|
2019-05-06 22:06:13 +02:00
|
|
|
import org.jivesoftware.smack.parsing.ExceptionThrowingCallback;
|
2018-08-02 09:37:26 +02:00
|
|
|
import org.jivesoftware.smack.parsing.ExceptionThrowingCallbackWithHint;
|
2014-01-16 06:14:39 +01:00
|
|
|
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
|
2017-05-03 13:18:15 +02:00
|
|
|
import org.jivesoftware.smack.util.Objects;
|
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
|
|
|
*
|
2014-07-05 12:04:40 +02:00
|
|
|
* Configuration settings are stored in org.jivesoftware.smack/smack-config.xml.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-12-19 19:17:36 +01:00
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
|
|
|
public final class SmackConfiguration {
|
2014-02-23 17:48:07 +01:00
|
|
|
|
2019-07-04 15:51:28 +02:00
|
|
|
public static final String SMACK_URL_STRING = "https://igniterealtime.org/projects/smack";
|
|
|
|
|
|
|
|
public static final URL SMACK_URL;
|
|
|
|
|
|
|
|
static {
|
|
|
|
try {
|
|
|
|
SMACK_URL = new URL(SMACK_URL_STRING);
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
throw new IllegalStateException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-18 15:05:19 +01:00
|
|
|
private static int defaultPacketReplyTimeout = 5000;
|
2014-02-23 17:48:07 +01:00
|
|
|
private static int packetCollectorSize = 5000;
|
|
|
|
|
2017-12-13 23:10:11 +01:00
|
|
|
private static List<String> defaultMechs = new ArrayList<>();
|
2003-12-19 19:17:36 +01:00
|
|
|
|
2017-12-13 23:10:11 +01:00
|
|
|
static Set<String> disabledSmackClasses = new HashSet<>();
|
2014-09-05 12:17:50 +02:00
|
|
|
|
2018-03-29 12:35:11 +02:00
|
|
|
static final List<XMPPInputOutputStream> compressionHandlers = new ArrayList<>(2);
|
2010-08-15 13:57:11 +02:00
|
|
|
|
2014-09-05 12:17:50 +02:00
|
|
|
static boolean smackInitialized = false;
|
2014-03-10 10:20:52 +01:00
|
|
|
|
|
|
|
/**
|
2014-04-03 13:06:43 +02:00
|
|
|
* Value that indicates whether debugging is enabled. When enabled, a debug
|
2017-12-13 23:10:11 +01:00
|
|
|
* window will appear for each new connection that will contain the following
|
2014-04-03 13:06:43 +02:00
|
|
|
* information:<ul>
|
|
|
|
* <li> Client Traffic -- raw XML traffic generated by Smack and sent to the server.
|
|
|
|
* <li> Server Traffic -- raw XML traffic sent by the server to the client.
|
|
|
|
* <li> Interpreted Packets -- shows XML packets from the server as parsed by Smack.
|
|
|
|
* </ul>
|
|
|
|
* Debugging can be enabled by setting this field to true, or by setting the Java system
|
2019-07-19 18:10:36 +02:00
|
|
|
* property <code>smack.debugEnabled</code> to true. The system property can be set on the
|
2014-04-03 13:06:43 +02:00
|
|
|
* command line such as "java SomeApp -Dsmack.debugEnabled=true".
|
|
|
|
*/
|
2015-01-18 21:33:03 +01:00
|
|
|
public static boolean DEBUG = false;
|
2014-04-03 13:06:43 +02:00
|
|
|
|
2017-07-28 11:59:11 +02:00
|
|
|
private static SmackDebuggerFactory DEFAULT_DEBUGGER_FACTORY = ReflectionDebuggerFactory.INSTANCE;
|
|
|
|
|
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.
|
|
|
|
*/
|
2018-08-02 09:37:26 +02:00
|
|
|
private static ParsingExceptionCallback defaultCallback = new ExceptionThrowingCallbackWithHint();
|
2013-06-22 19:01:40 +02:00
|
|
|
|
2014-07-21 18:42:44 +02:00
|
|
|
private static HostnameVerifier defaultHostnameVerififer;
|
|
|
|
|
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".
|
2018-05-09 23:06:12 +02: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() {
|
2014-09-05 12:17:50 +02:00
|
|
|
return SmackInitialization.SMACK_VERSION;
|
2003-12-19 19:17:36 +01:00
|
|
|
}
|
|
|
|
|
2017-01-12 20:57:19 +01:00
|
|
|
/**
|
|
|
|
* Returns the number of milliseconds to wait for a response from
|
|
|
|
* the server. The default value is 5000 ms.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2017-01-12 20:57:19 +01:00
|
|
|
* @return the milliseconds to wait for a response from the server
|
|
|
|
*/
|
|
|
|
public static int getDefaultReplyTimeout() {
|
2004-09-24 04:12:47 +02:00
|
|
|
// The timeout value must be greater than 0 otherwise we will answer the default value
|
2014-02-18 15:05:19 +01:00
|
|
|
if (defaultPacketReplyTimeout <= 0) {
|
|
|
|
defaultPacketReplyTimeout = 5000;
|
2004-09-24 04:12:47 +02:00
|
|
|
}
|
2014-02-18 15:05:19 +01:00
|
|
|
return defaultPacketReplyTimeout;
|
2004-01-02 00:19:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the number of milliseconds to wait for a response from
|
|
|
|
* the server.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2004-01-02 00:19:37 +01:00
|
|
|
* @param timeout the milliseconds to wait for a response from the server
|
|
|
|
*/
|
2017-01-12 20:57:19 +01:00
|
|
|
public static void setDefaultReplyTimeout(int timeout) {
|
2004-09-24 04:12:47 +02:00
|
|
|
if (timeout <= 0) {
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
}
|
2014-02-18 15:05:19 +01:00
|
|
|
defaultPacketReplyTimeout = timeout;
|
2004-01-02 00:19:37 +01:00
|
|
|
}
|
|
|
|
|
2017-07-28 11:59:11 +02:00
|
|
|
public static void setDefaultSmackDebuggerFactory(SmackDebuggerFactory debuggerFactory) {
|
|
|
|
DEFAULT_DEBUGGER_FACTORY = Objects.requireNonNull(debuggerFactory, "Debugger factory must not be null");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SmackDebuggerFactory getDefaultSmackDebuggerFactory() {
|
|
|
|
return DEFAULT_DEBUGGER_FACTORY;
|
|
|
|
}
|
|
|
|
|
2011-06-18 20:18:03 +02:00
|
|
|
/**
|
2018-05-09 23:06:12 +02:00
|
|
|
* Gets the default max size of a stanza collector before it will delete
|
2011-06-18 20:18:03 +02:00
|
|
|
* the older packets.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2011-06-18 20:18:03 +02:00
|
|
|
* @return The number of packets to queue before deleting older packets.
|
|
|
|
*/
|
2017-01-03 11:12:34 +01:00
|
|
|
public static int getStanzaCollectorSize() {
|
2014-02-23 17:48:07 +01:00
|
|
|
return packetCollectorSize;
|
2011-06-18 20:18:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-09 23:06:12 +02:00
|
|
|
* Sets the default max size of a stanza collector before it will delete
|
2011-06-18 20:18:03 +02:00
|
|
|
* the older packets.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-03-10 18:31:45 +01:00
|
|
|
* @param collectorSize the number of packets to queue before deleting older packets.
|
2011-06-18 20:18:03 +02:00
|
|
|
*/
|
2017-01-03 11:12:34 +01:00
|
|
|
public static void setStanzaCollectorSize(int collectorSize) {
|
2014-02-23 17:48:07 +01:00
|
|
|
packetCollectorSize = collectorSize;
|
2011-06-18 20:18:03 +02:00
|
|
|
}
|
2015-03-17 11:33:02 +01:00
|
|
|
|
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) {
|
2017-05-23 16:45:04 +02:00
|
|
|
if (!defaultMechs.contains(mech)) {
|
2007-11-14 17:27:47 +01:00
|
|
|
defaultMechs.add(mech);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-14 21:47:53 +02:00
|
|
|
/**
|
2007-11-14 17:27:47 +01:00
|
|
|
* 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) {
|
2017-05-23 16:45:04 +02:00
|
|
|
for (String mech : mechs) {
|
2007-11-14 17:27:47 +01:00
|
|
|
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
|
|
|
defaultMechs.remove(mech);
|
2007-11-14 17:27:47 +01:00
|
|
|
}
|
|
|
|
|
2017-08-14 21:47:53 +02:00
|
|
|
/**
|
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
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-22 19:01:40 +02:00
|
|
|
/**
|
2015-03-29 12:15:32 +02:00
|
|
|
* Set the default parsing exception callback for all newly created connections.
|
2013-06-22 19:01:40 +02:00
|
|
|
*
|
2019-08-30 12:08:30 +02:00
|
|
|
* @param callback TODO javadoc me please
|
2013-06-22 19:01:40 +02:00
|
|
|
* @see ParsingExceptionCallback
|
|
|
|
*/
|
|
|
|
public static void setDefaultParsingExceptionCallback(ParsingExceptionCallback callback) {
|
|
|
|
defaultCallback = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-03-29 12:15:32 +02:00
|
|
|
* Returns the default parsing exception callback.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2013-06-22 19:01:40 +02:00
|
|
|
* @return the default parsing exception callback
|
|
|
|
* @see ParsingExceptionCallback
|
|
|
|
*/
|
|
|
|
public static ParsingExceptionCallback getDefaultParsingExceptionCallback() {
|
|
|
|
return defaultCallback;
|
|
|
|
}
|
|
|
|
|
2014-03-10 10:20:52 +01:00
|
|
|
public static void addCompressionHandler(XMPPInputOutputStream xmppInputOutputStream) {
|
|
|
|
compressionHandlers.add(xmppInputOutputStream);
|
|
|
|
}
|
|
|
|
|
2017-12-19 15:06:40 +01:00
|
|
|
/**
|
|
|
|
* Get compression handlers.
|
|
|
|
*
|
2019-08-30 12:08:30 +02:00
|
|
|
* @return a list of compression handlers.
|
2017-12-19 15:06:40 +01:00
|
|
|
* @deprecated use {@link #getCompressionHandlers()} instead.
|
|
|
|
*/
|
|
|
|
@Deprecated
|
2019-08-30 12:08:30 +02:00
|
|
|
// TODO: Remove in Smack 4.4.
|
2017-12-19 15:06:40 +01:00
|
|
|
public static List<XMPPInputOutputStream> getCompresionHandlers() {
|
|
|
|
return getCompressionHandlers();
|
|
|
|
}
|
|
|
|
|
2019-08-30 12:08:30 +02:00
|
|
|
/**
|
|
|
|
* Get compression handlers.
|
|
|
|
*
|
|
|
|
* @return a list of compression handlers.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
public static List<XMPPInputOutputStream> getCompressionHandlers() {
|
|
|
|
List<XMPPInputOutputStream> res = new ArrayList<>(compressionHandlers.size());
|
2014-03-10 10:20:52 +01:00
|
|
|
for (XMPPInputOutputStream ios : compressionHandlers) {
|
|
|
|
if (ios.isSupported()) {
|
|
|
|
res.add(ios);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-07-21 18:42:44 +02:00
|
|
|
/**
|
|
|
|
* Set the default HostnameVerifier that will be used by XMPP connections to verify the hostname
|
|
|
|
* of a TLS certificate. XMPP connections are able to overwrite this settings by supplying a
|
2017-12-13 23:10:11 +01:00
|
|
|
* HostnameVerifier in their ConnectionConfiguration with
|
2014-12-17 17:01:53 +01:00
|
|
|
* {@link ConnectionConfiguration.Builder#setHostnameVerifier(HostnameVerifier)}.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @param verifier HostnameVerifier
|
2014-07-21 18:42:44 +02:00
|
|
|
*/
|
|
|
|
public static void setDefaultHostnameVerifier(HostnameVerifier verifier) {
|
|
|
|
defaultHostnameVerififer = verifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-09-05 12:17:50 +02:00
|
|
|
* Convenience method for {@link #addDisabledSmackClass(String)}.
|
2014-07-21 18:42:44 +02:00
|
|
|
*
|
2014-09-05 12:17:50 +02:00
|
|
|
* @param clz the Smack class to disable
|
2014-07-21 18:42:44 +02:00
|
|
|
*/
|
2014-09-05 12:17:50 +02:00
|
|
|
public static void addDisabledSmackClass(Class<?> clz) {
|
|
|
|
addDisabledSmackClass(clz.getName());
|
2014-07-21 18:42:44 +02:00
|
|
|
}
|
|
|
|
|
2014-09-05 12:17:50 +02:00
|
|
|
/**
|
2014-09-25 09:42:55 +02:00
|
|
|
* Add a class to the disabled smack classes.
|
|
|
|
* <p>
|
|
|
|
* {@code className} can also be a package name, in this case, the entire
|
|
|
|
* package is disabled (but can be manually enabled).
|
|
|
|
* </p>
|
2014-09-05 12:17:50 +02:00
|
|
|
*
|
2019-08-30 12:08:30 +02:00
|
|
|
* @param className TODO javadoc me please
|
2014-09-05 12:17:50 +02:00
|
|
|
*/
|
|
|
|
public static void addDisabledSmackClass(String className) {
|
|
|
|
disabledSmackClasses.add(className);
|
2014-05-15 15:04:46 +02:00
|
|
|
}
|
|
|
|
|
2017-01-02 16:29:29 +01:00
|
|
|
/**
|
|
|
|
* Add the given class names to the list of disabled Smack classes.
|
|
|
|
*
|
|
|
|
* @param classNames the Smack classes to disable.
|
|
|
|
* @see #addDisabledSmackClass(String)
|
|
|
|
*/
|
|
|
|
public static void addDisabledSmackClasses(String... classNames) {
|
|
|
|
for (String className : classNames) {
|
|
|
|
addDisabledSmackClass(className);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-21 18:21:54 +01:00
|
|
|
public static boolean isDisabledSmackClass(String className) {
|
|
|
|
for (String disabledClassOrPackage : disabledSmackClasses) {
|
|
|
|
if (disabledClassOrPackage.equals(className)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
int lastDotIndex = disabledClassOrPackage.lastIndexOf('.');
|
|
|
|
// Security check to avoid NPEs if someone entered 'foo.bar.'
|
|
|
|
if (disabledClassOrPackage.length() > lastDotIndex
|
|
|
|
// disabledClassOrPackage is not an Class
|
|
|
|
&& !Character.isUpperCase(disabledClassOrPackage.charAt(lastDotIndex + 1))
|
|
|
|
// classToLoad startsWith the package disabledClassOrPackage disables
|
|
|
|
&& className.startsWith(disabledClassOrPackage)) {
|
|
|
|
// Skip the class because the whole package was disabled
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-05 12:17:50 +02:00
|
|
|
/**
|
|
|
|
* Check if Smack was successfully initialized.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-09-05 12:17:50 +02:00
|
|
|
* @return true if smack was initialized, false otherwise
|
|
|
|
*/
|
|
|
|
public static boolean isSmackInitialized() {
|
|
|
|
return smackInitialized;
|
2014-02-23 17:48:07 +01:00
|
|
|
}
|
|
|
|
|
2014-09-05 12:17:50 +02:00
|
|
|
/**
|
|
|
|
* Get the default HostnameVerifier
|
|
|
|
*
|
|
|
|
* @return the default HostnameVerifier or <code>null</code> if none was set
|
|
|
|
*/
|
|
|
|
static HostnameVerifier getDefaultHostnameVerifier() {
|
|
|
|
return defaultHostnameVerififer;
|
2014-02-15 13:01:57 +01:00
|
|
|
}
|
|
|
|
|
2017-08-06 14:25:57 +02:00
|
|
|
public enum UnknownIqRequestReplyMode {
|
2017-05-03 13:18:15 +02:00
|
|
|
doNotReply,
|
|
|
|
replyFeatureNotImplemented,
|
|
|
|
replyServiceUnavailable,
|
|
|
|
}
|
|
|
|
|
2017-08-16 14:31:46 +02:00
|
|
|
private static UnknownIqRequestReplyMode unknownIqRequestReplyMode = UnknownIqRequestReplyMode.replyFeatureNotImplemented;
|
2017-05-03 13:18:15 +02:00
|
|
|
|
|
|
|
public static UnknownIqRequestReplyMode getUnknownIqRequestReplyMode() {
|
|
|
|
return unknownIqRequestReplyMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setUnknownIqRequestReplyMode(UnknownIqRequestReplyMode unknownIqRequestReplyMode) {
|
|
|
|
SmackConfiguration.unknownIqRequestReplyMode = Objects.requireNonNull(unknownIqRequestReplyMode, "Must set mode");
|
|
|
|
}
|
2019-04-10 12:18:06 +02:00
|
|
|
|
|
|
|
private static final int defaultConcurrencyLevelLimit;
|
|
|
|
|
|
|
|
static {
|
|
|
|
int availableProcessors = Runtime.getRuntime().availableProcessors();
|
|
|
|
if (availableProcessors < 8) {
|
|
|
|
defaultConcurrencyLevelLimit = 8;
|
|
|
|
} else {
|
|
|
|
defaultConcurrencyLevelLimit = (int) (availableProcessors * 1.1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getDefaultConcurrencyLevelLimit() {
|
|
|
|
return defaultConcurrencyLevelLimit;
|
|
|
|
}
|
2019-05-06 22:06:13 +02:00
|
|
|
|
2003-12-19 19:17:36 +01:00
|
|
|
}
|