mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Move DEBUG_ENABLED from XMPPConnection to SmackConfiguration
This commit is contained in:
parent
3c2f794522
commit
4a60a68802
5 changed files with 36 additions and 34 deletions
|
@ -62,7 +62,7 @@ public class ConnectionConfiguration implements Cloneable {
|
|||
*/
|
||||
private CallbackHandler callbackHandler;
|
||||
|
||||
private boolean debuggerEnabled = XMPPConnection.DEBUG_ENABLED;
|
||||
private boolean debuggerEnabled = SmackConfiguration.DEBUG_ENABLED;
|
||||
|
||||
// Flag that indicates if a reconnection should be attempted when abruptly disconnected
|
||||
private boolean reconnectionAllowed = true;
|
||||
|
@ -332,7 +332,7 @@ public class ConnectionConfiguration implements Cloneable {
|
|||
|
||||
/**
|
||||
* Returns true if the new connection about to be establish is going to be debugged. By
|
||||
* default the value of {@link XMPPConnection#DEBUG_ENABLED} is used.
|
||||
* default the value of {@link SmackConfiguration#DEBUG_ENABLED} is used.
|
||||
*
|
||||
* @return true if the new connection about to be establish is going to be debugged.
|
||||
*/
|
||||
|
@ -342,7 +342,7 @@ public class ConnectionConfiguration implements Cloneable {
|
|||
|
||||
/**
|
||||
* Sets if the new connection about to be establish is going to be debugged. By
|
||||
* default the value of {@link XMPPConnection#DEBUG_ENABLED} is used.
|
||||
* default the value of {@link SmackConfiguration#DEBUG_ENABLED} is used.
|
||||
*
|
||||
* @param debuggerEnabled if the new connection about to be establish is going to be debugged.
|
||||
*/
|
||||
|
|
|
@ -70,11 +70,27 @@ public final class SmackConfiguration {
|
|||
private final static List<XMPPInputOutputStream> compressionHandlers = new ArrayList<XMPPInputOutputStream>(2);
|
||||
|
||||
/**
|
||||
* Loads the configuration from the smack-config.xml file.<p>
|
||||
*
|
||||
* Value that indicates whether debugging is enabled. When enabled, a debug
|
||||
* window will apear for each new connection that will contain the following
|
||||
* 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>
|
||||
* <p/>
|
||||
* Debugging can be enabled by setting this field to true, or by setting the Java system
|
||||
* property <tt>smack.debugEnabled</tt> to true. The system property can be set on the
|
||||
* command line such as "java SomeApp -Dsmack.debugEnabled=true".
|
||||
*/
|
||||
public static boolean DEBUG_ENABLED = false;
|
||||
|
||||
/**
|
||||
* Loads the configuration from the smack-config.xml and system properties file.
|
||||
* <p>
|
||||
* So far this means that:
|
||||
* 1) a set of classes will be loaded in order to execute their static init block
|
||||
* 2) retrieve and set the current Smack release
|
||||
* 3) set DEBUG_ENABLED
|
||||
*/
|
||||
static {
|
||||
String smackVersion;
|
||||
|
@ -137,6 +153,15 @@ public final class SmackConfiguration {
|
|||
|
||||
// Add the Java7 compression handler first, since it's preferred
|
||||
compressionHandlers.add(new Java7ZlibInputOutputStream());
|
||||
|
||||
// Use try block since we may not have permission to get a system
|
||||
// property (for example, when an applet).
|
||||
try {
|
||||
DEBUG_ENABLED = Boolean.getBoolean("smack.debugEnabled");
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -104,30 +104,7 @@ public abstract class XMPPConnection {
|
|||
private final static Set<ConnectionCreationListener> connectionEstablishedListeners =
|
||||
new CopyOnWriteArraySet<ConnectionCreationListener>();
|
||||
|
||||
/**
|
||||
* Value that indicates whether debugging is enabled. When enabled, a debug
|
||||
* window will apear for each new connection that will contain the following
|
||||
* 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>
|
||||
* <p/>
|
||||
* Debugging can be enabled by setting this field to true, or by setting the Java system
|
||||
* property <tt>smack.debugEnabled</tt> to true. The system property can be set on the
|
||||
* command line such as "java SomeApp -Dsmack.debugEnabled=true".
|
||||
*/
|
||||
public static boolean DEBUG_ENABLED = false;
|
||||
|
||||
static {
|
||||
// Use try block since we may not have permission to get a system
|
||||
// property (for example, when an applet).
|
||||
try {
|
||||
DEBUG_ENABLED = Boolean.getBoolean("smack.debugEnabled");
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Ignore.
|
||||
}
|
||||
// Ensure the SmackConfiguration class is loaded by calling a method in it.
|
||||
SmackConfiguration.getVersion();
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ public class DummyConnection extends XMPPConnection {
|
|||
|
||||
@Override
|
||||
void sendPacketInternal(Packet packet) {
|
||||
if (DEBUG_ENABLED) {
|
||||
if (SmackConfiguration.DEBUG_ENABLED) {
|
||||
System.out.println("[SEND]: " + packet.toXML());
|
||||
}
|
||||
queue.add(packet);
|
||||
|
@ -244,7 +244,7 @@ public class DummyConnection extends XMPPConnection {
|
|||
collector.processPacket(packet);
|
||||
}
|
||||
|
||||
if (DEBUG_ENABLED) {
|
||||
if (SmackConfiguration.DEBUG_ENABLED) {
|
||||
System.out.println("[RECV]: " + packet.toXML());
|
||||
}
|
||||
|
||||
|
|
|
@ -703,7 +703,7 @@ public class RosterTest {
|
|||
|
||||
public synchronized void entriesAdded(Collection<String> addresses) {
|
||||
addressesAdded.addAll(addresses);
|
||||
if (XMPPConnection.DEBUG_ENABLED) {
|
||||
if (SmackConfiguration.DEBUG_ENABLED) {
|
||||
for (String address : addresses) {
|
||||
System.out.println("Roster entry for " + address + " added.");
|
||||
}
|
||||
|
@ -712,7 +712,7 @@ public class RosterTest {
|
|||
|
||||
public synchronized void entriesDeleted(Collection<String> addresses) {
|
||||
addressesDeleted.addAll(addresses);
|
||||
if (XMPPConnection.DEBUG_ENABLED) {
|
||||
if (SmackConfiguration.DEBUG_ENABLED) {
|
||||
for (String address : addresses) {
|
||||
System.out.println("Roster entry for " + address + " deleted.");
|
||||
}
|
||||
|
@ -721,7 +721,7 @@ public class RosterTest {
|
|||
|
||||
public synchronized void entriesUpdated(Collection<String> addresses) {
|
||||
addressesUpdated.addAll(addresses);
|
||||
if (XMPPConnection.DEBUG_ENABLED) {
|
||||
if (SmackConfiguration.DEBUG_ENABLED) {
|
||||
for (String address : addresses) {
|
||||
System.out.println("Roster entry for " + address + " updated.");
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ public class RosterTest {
|
|||
}
|
||||
|
||||
public void presenceChanged(Presence presence) {
|
||||
if (XMPPConnection.DEBUG_ENABLED) {
|
||||
if (SmackConfiguration.DEBUG_ENABLED) {
|
||||
System.out.println("Roster presence changed: " + presence.toXML());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue