mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +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 {
|
public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
private static final Logger LOGGER = Logger.getLogger(AbstractXMPPConnection.class.getName());
|
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.
|
* Counter to uniquely identify connections that are created.
|
||||||
*/
|
*/
|
||||||
|
@ -794,31 +803,39 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debuggerClass == null) {
|
if (debuggerClass == null) {
|
||||||
|
for (String debugger : DEBUGGERS) {
|
||||||
try {
|
try {
|
||||||
debuggerClass =
|
debuggerClass = Class.forName(debugger);
|
||||||
Class.forName("org.jivesoftware.smackx.debugger.EnhancedDebugger");
|
}
|
||||||
|
catch (ClassNotFoundException cnfe) {
|
||||||
|
LOGGER.fine("Did not find debugger class '" + debugger + "'");
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
try {
|
|
||||||
debuggerClass =
|
|
||||||
Class.forName("org.jivesoftware.smack.debugger.LiteDebugger");
|
|
||||||
}
|
|
||||||
catch (Exception ex2) {
|
|
||||||
LOGGER.warning("Unabled to instantiate either Smack debugger class");
|
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
|
// option
|
||||||
try {
|
try {
|
||||||
Constructor<?> constructor = debuggerClass
|
Constructor<?> constructor = debuggerClass.getConstructor(
|
||||||
.getConstructor(XMPPConnection.class, Writer.class, Reader.class);
|
XMPPConnection.class, Writer.class, Reader.class);
|
||||||
debugger = (SmackDebugger) constructor.newInstance(this, writer, reader);
|
debugger = (SmackDebugger) constructor.newInstance(this, writer, reader);
|
||||||
reader = debugger.getReader();
|
reader = debugger.getReader();
|
||||||
writer = debugger.getWriter();
|
writer = debugger.getWriter();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
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 {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue