mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 02:39:42 +02:00
SMACK-425 Introduced smack.parsing.ParsingExceptionCallback, a callback invoked when a exception is thrown while parsing a stanza. Smack is now able to either rethrow the exception ulitmatly causing a disconnect *or* log/ignore the exception and resume parsing after the faulty stanza.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_1@13688 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
18a603d932
commit
30bc5afa2b
12 changed files with 524 additions and 8 deletions
|
@ -28,6 +28,8 @@ import java.util.Enumeration;
|
|||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
|
||||
import org.jivesoftware.smack.parsing.ThrowException;
|
||||
import org.xmlpull.mxp1.MXParser;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
|
@ -58,6 +60,12 @@ public final class SmackConfiguration {
|
|||
private static int localSocks5ProxyPort = 7777;
|
||||
private static int packetCollectorSize = 5000;
|
||||
|
||||
/**
|
||||
* The default parsing exception callback is {@link ThrowException} which will
|
||||
* throw an exception and therefore disconnect the active connection.
|
||||
*/
|
||||
private static ParsingExceptionCallback defaultCallback = new ThrowException();
|
||||
|
||||
/**
|
||||
* This automatically enables EntityCaps for new connections if it is set to true
|
||||
*/
|
||||
|
@ -328,6 +336,26 @@ public final class SmackConfiguration {
|
|||
autoEnableEntityCaps = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default parsing exception callback for all newly created connections
|
||||
*
|
||||
* @param callback
|
||||
* @see ParsingExceptionCallback
|
||||
*/
|
||||
public static void setDefaultParsingExceptionCallback(ParsingExceptionCallback callback) {
|
||||
defaultCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default parsing exception callback
|
||||
*
|
||||
* @return the default parsing exception callback
|
||||
* @see ParsingExceptionCallback
|
||||
*/
|
||||
public static ParsingExceptionCallback getDefaultParsingExceptionCallback() {
|
||||
return defaultCallback;
|
||||
}
|
||||
|
||||
private static void parseClassToLoad(XmlPullParser parser) throws Exception {
|
||||
String className = parser.nextText();
|
||||
// Attempt to load the class so that the class can get initialized
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue