mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-15 20:12:04 +01:00
Add AndroidDebugger as possible debugger
Create AbstractXMPPConnection.DEBUGGERS with possible debugger classes.
This commit is contained in:
parent
f67d655fe7
commit
12b9e9d507
1 changed files with 36 additions and 19 deletions
|
@ -53,6 +53,15 @@ import org.jivesoftware.smack.packet.Session;
|
|||
public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||
private static final Logger LOGGER = Logger.getLogger(AbstractXMPPConnection.class.getName());
|
||||
|
||||
/**
|
||||
* Possible default debugger implementations. The order of enumeration is the one in which we try
|
||||
* to instantiate these.
|
||||
*/
|
||||
private static final String[] DEBUGGERS = new String[] {
|
||||
"org.jivesoftware.smackx.debugger.EnhancedDebugger",
|
||||
"org.jivesoftware.smackx.debugger.android.AndroidDebugger",
|
||||
"org.jivesoftware.smack.debugger.LiteDebugger" };
|
||||
|
||||
/**
|
||||
* Counter to uniquely identify connections that are created.
|
||||
*/
|
||||
|
@ -794,31 +803,39 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
}
|
||||
if (debuggerClass == null) {
|
||||
for (String debugger : DEBUGGERS) {
|
||||
try {
|
||||
debuggerClass =
|
||||
Class.forName("org.jivesoftware.smackx.debugger.EnhancedDebugger");
|
||||
debuggerClass = Class.forName(debugger);
|
||||
}
|
||||
catch (ClassNotFoundException cnfe) {
|
||||
LOGGER.fine("Did not find debugger class '" + debugger + "'");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
try {
|
||||
debuggerClass =
|
||||
Class.forName("org.jivesoftware.smack.debugger.LiteDebugger");
|
||||
}
|
||||
catch (Exception ex2) {
|
||||
LOGGER.warning("Unabled to instantiate either Smack debugger class");
|
||||
}
|
||||
if (debuggerClass != null) {
|
||||
// We found a debugger, let's use it
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Create a new debugger instance. If an exception occurs then disable the debugging
|
||||
}
|
||||
if (debuggerClass != null) {
|
||||
// Create a new debugger instance. If an exception occurs then disable the
|
||||
// debugging
|
||||
// option
|
||||
try {
|
||||
Constructor<?> constructor = debuggerClass
|
||||
.getConstructor(XMPPConnection.class, Writer.class, Reader.class);
|
||||
Constructor<?> constructor = debuggerClass.getConstructor(
|
||||
XMPPConnection.class, Writer.class, Reader.class);
|
||||
debugger = (SmackDebugger) constructor.newInstance(this, writer, reader);
|
||||
reader = debugger.getReader();
|
||||
writer = debugger.getWriter();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalArgumentException("Can't initialize the configured debugger!", e);
|
||||
throw new IllegalArgumentException(
|
||||
"Can't initialize the configured debugger!", e);
|
||||
}
|
||||
} else {
|
||||
LOGGER.severe("Debugging enabled but could not find debugger class");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue