Package org.jivesoftware.smack
Class SmackConfiguration
- java.lang.Object
-
- org.jivesoftware.smack.SmackConfiguration
-
public final class SmackConfiguration extends Object
Represents the configuration of Smack. The configuration is used for:- Initializing classes by loading them at start-up.
- Getting the current Smack version.
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SmackConfiguration.UnknownIqRequestReplyMode
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEBUG
Value that indicates whether debugging is enabled.static URL
SMACK_URL
static String
SMACK_URL_STRING
static boolean
TRUELY_ASYNC_SENDS
If enabled, causesAbstractXMPPConnection
to create a thread for every asynchronous send operation.
-
Constructor Summary
Constructors Constructor Description SmackConfiguration()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addAllKnownModulesTo(ModularXmppClientToServerConnectionConfiguration.Builder builder)
static void
addCompressionHandler(XMPPInputOutputStream xmppInputOutputStream)
static void
addDisabledSmackClass(Class<?> clz)
Convenience method foraddDisabledSmackClass(String)
.static void
addDisabledSmackClass(String className)
Add a class to the disabled smack classes.static void
addDisabledSmackClasses(String... classNames)
Add the given class names to the list of disabled Smack classes.static boolean
addModule(Class<? extends ModularXmppClientToServerConnectionModuleDescriptor> moduleDescriptor)
static void
addSaslMech(String mech)
Add a SASL mechanism to the list to be used.static void
addSaslMechs(Collection<String> mechs)
Add a Collection of SASL mechanisms to the list to be used.static List<XMPPInputOutputStream>
getCompressionHandlers()
Get compression handlers.static int
getDefaultConcurrencyLevelLimit()
static ParsingExceptionCallback
getDefaultParsingExceptionCallback()
Returns the default parsing exception callback.static int
getDefaultReplyTimeout()
Returns the number of milliseconds to wait for a response from the server.static SmackDebuggerFactory
getDefaultSmackDebuggerFactory()
static List<String>
getSaslMechs()
Returns the list of SASL mechanisms to be used.static int
getStanzaCollectorSize()
Gets the default max size of a stanza collector before it will delete the older packets.static SmackConfiguration.UnknownIqRequestReplyMode
getUnknownIqRequestReplyMode()
static String
getVersion()
Deprecated.useSmack.getVersion()
instead.static boolean
isDisabledSmackClass(String className)
static boolean
isSmackInitialized()
Check if Smack was successfully initialized.static void
removeSaslMech(String mech)
Remove a SASL mechanism from the list to be used.static void
removeSaslMechs(Collection<String> mechs)
Remove a Collection of SASL mechanisms to the list to be used.static void
setDefaultHostnameVerifier(HostnameVerifier verifier)
Set the default HostnameVerifier that will be used by XMPP connections to verify the hostname of a TLS certificate.static void
setDefaultParsingExceptionCallback(ParsingExceptionCallback callback)
Set the default parsing exception callback for all newly created connections.static void
setDefaultReplyTimeout(int timeout)
Sets the number of milliseconds to wait for a response from the server.static void
setDefaultSmackDebuggerFactory(SmackDebuggerFactory debuggerFactory)
static void
setStanzaCollectorSize(int collectorSize)
Sets the default max size of a stanza collector before it will delete the older packets.static void
setUnknownIqRequestReplyMode(SmackConfiguration.UnknownIqRequestReplyMode unknownIqRequestReplyMode)
-
-
-
Field Detail
-
SMACK_URL_STRING
public static final String SMACK_URL_STRING
- See Also:
- Constant Field Values
-
DEBUG
public static boolean DEBUG
Value that indicates whether debugging is enabled. When enabled, a debug window will appear for each new connection that will contain the following information:- Client Traffic -- raw XML traffic generated by Smack and sent to the server.
- Server Traffic -- raw XML traffic sent by the server to the client.
- Interpreted Packets -- shows XML packets from the server as parsed by Smack.
smack.debugEnabled
to true. The system property can be set on the command line such as "java SomeApp -Dsmack.debugEnabled=true".
-
TRUELY_ASYNC_SENDS
public static boolean TRUELY_ASYNC_SENDS
If enabled, causesAbstractXMPPConnection
to create a thread for every asynchronous send operation. This is meant to work-around a shortcoming of Smack 4.4, where certain send operations are not asynchronous even if they should be. This is an expert setting, do not toggle if you do not understand the consequences or have been told to do so. Note that it is expected that this will not be needed in future Smack versions.- Since:
- 4.4.6
-
-
Constructor Detail
-
SmackConfiguration
public SmackConfiguration()
-
-
Method Detail
-
getVersion
@Deprecated public static String getVersion()
Deprecated.useSmack.getVersion()
instead.Returns the Smack version information, eg "1.3.0".- Returns:
- the Smack version information.
-
getDefaultReplyTimeout
public static int getDefaultReplyTimeout()
Returns the number of milliseconds to wait for a response from the server. The default value is 5000 ms.- Returns:
- the milliseconds to wait for a response from the server
-
setDefaultReplyTimeout
public static void setDefaultReplyTimeout(int timeout)
Sets the number of milliseconds to wait for a response from the server.- Parameters:
timeout
- the milliseconds to wait for a response from the server
-
setDefaultSmackDebuggerFactory
public static void setDefaultSmackDebuggerFactory(SmackDebuggerFactory debuggerFactory)
-
getDefaultSmackDebuggerFactory
public static SmackDebuggerFactory getDefaultSmackDebuggerFactory()
-
getStanzaCollectorSize
public static int getStanzaCollectorSize()
Gets the default max size of a stanza collector before it will delete the older packets.- Returns:
- The number of packets to queue before deleting older packets.
-
setStanzaCollectorSize
public static void setStanzaCollectorSize(int collectorSize)
Sets the default max size of a stanza collector before it will delete the older packets.- Parameters:
collectorSize
- the number of packets to queue before deleting older packets.
-
addSaslMech
public static void addSaslMech(String mech)
Add a SASL mechanism to the list to be used.- Parameters:
mech
- the SASL mechanism to be added
-
addSaslMechs
public static void addSaslMechs(Collection<String> mechs)
Add a Collection of SASL mechanisms to the list to be used.- Parameters:
mechs
- the Collection of SASL mechanisms to be added
-
removeSaslMech
public static void removeSaslMech(String mech)
Remove a SASL mechanism from the list to be used.- Parameters:
mech
- the SASL mechanism to be removed
-
removeSaslMechs
public static void removeSaslMechs(Collection<String> mechs)
Remove a Collection of SASL mechanisms to the list to be used.- Parameters:
mechs
- the Collection of SASL mechanisms to be removed
-
getSaslMechs
public static List<String> getSaslMechs()
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.- Returns:
- the list of SASL mechanisms to be used.
-
setDefaultParsingExceptionCallback
public static void setDefaultParsingExceptionCallback(ParsingExceptionCallback callback)
Set the default parsing exception callback for all newly created connections.- Parameters:
callback
- TODO javadoc me please- See Also:
ParsingExceptionCallback
-
getDefaultParsingExceptionCallback
public static ParsingExceptionCallback getDefaultParsingExceptionCallback()
Returns the default parsing exception callback.- Returns:
- the default parsing exception callback
- See Also:
ParsingExceptionCallback
-
addCompressionHandler
public static void addCompressionHandler(XMPPInputOutputStream xmppInputOutputStream)
-
getCompressionHandlers
public static List<XMPPInputOutputStream> getCompressionHandlers()
Get compression handlers.- Returns:
- a list of compression handlers.
-
setDefaultHostnameVerifier
public static void setDefaultHostnameVerifier(HostnameVerifier verifier)
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 HostnameVerifier in their ConnectionConfiguration withConnectionConfiguration.Builder.setHostnameVerifier(HostnameVerifier)
.- Parameters:
verifier
- HostnameVerifier
-
addDisabledSmackClass
public static void addDisabledSmackClass(Class<?> clz)
Convenience method foraddDisabledSmackClass(String)
.- Parameters:
clz
- the Smack class to disable
-
addDisabledSmackClass
public static void addDisabledSmackClass(String className)
Add a class to the disabled smack classes.className
can also be a package name, in this case, the entire package is disabled (but can be manually enabled).- Parameters:
className
- TODO javadoc me please
-
addDisabledSmackClasses
public static void addDisabledSmackClasses(String... classNames)
Add the given class names to the list of disabled Smack classes.- Parameters:
classNames
- the Smack classes to disable.- See Also:
addDisabledSmackClass(String)
-
isDisabledSmackClass
public static boolean isDisabledSmackClass(String className)
-
isSmackInitialized
public static boolean isSmackInitialized()
Check if Smack was successfully initialized.- Returns:
- true if smack was initialized, false otherwise
-
getUnknownIqRequestReplyMode
public static SmackConfiguration.UnknownIqRequestReplyMode getUnknownIqRequestReplyMode()
-
setUnknownIqRequestReplyMode
public static void setUnknownIqRequestReplyMode(SmackConfiguration.UnknownIqRequestReplyMode unknownIqRequestReplyMode)
-
getDefaultConcurrencyLevelLimit
public static int getDefaultConcurrencyLevelLimit()
-
addModule
public static boolean addModule(Class<? extends ModularXmppClientToServerConnectionModuleDescriptor> moduleDescriptor)
-
addAllKnownModulesTo
public static void addAllKnownModulesTo(ModularXmppClientToServerConnectionConfiguration.Builder builder)
-
-