From df5899e72bbbdc83513a4570cb0ff04763303938 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 4 Jul 2019 15:51:28 +0200 Subject: [PATCH] Introduce SmackConfiguration.SMACK_URL(_STRING) --- .../org/jivesoftware/smack/SmackConfiguration.java | 14 ++++++++++++++ .../java/org/jivesoftware/smack/packet/TestIQ.java | 4 +++- .../smackx/caps/EntityCapsManager.java | 3 ++- .../smackx/iqprivate/PrivateDataManager.java | 3 ++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java b/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java index 6f06e4d33..f7957cccb 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java @@ -17,6 +17,8 @@ package org.jivesoftware.smack; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -50,6 +52,18 @@ import org.jivesoftware.smack.util.Objects; */ public final class SmackConfiguration { + public static final String SMACK_URL_STRING = "https://igniterealtime.org/projects/smack"; + + public static final URL SMACK_URL; + + static { + try { + SMACK_URL = new URL(SMACK_URL_STRING); + } catch (MalformedURLException e) { + throw new IllegalStateException(e); + } + } + private static int defaultPacketReplyTimeout = 5000; private static int packetCollectorSize = 5000; diff --git a/smack-core/src/test/java/org/jivesoftware/smack/packet/TestIQ.java b/smack-core/src/test/java/org/jivesoftware/smack/packet/TestIQ.java index 84aed089d..c222035e1 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/packet/TestIQ.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/packet/TestIQ.java @@ -16,10 +16,12 @@ */ package org.jivesoftware.smack.packet; +import org.jivesoftware.smack.SmackConfiguration; + public class TestIQ extends SimpleIQ { public TestIQ() { - this("https://igniterealtime.org/projects/smack", "test-iq"); + this(SmackConfiguration.SMACK_URL_STRING, "test-iq"); } public TestIQ(String element, String namespace) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java index d75cb7036..5fe1e0260 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java @@ -36,6 +36,7 @@ import java.util.logging.Logger; import org.jivesoftware.smack.AbstractConnectionListener; import org.jivesoftware.smack.ConnectionCreationListener; import org.jivesoftware.smack.Manager; +import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.StanzaListener; @@ -92,7 +93,7 @@ public final class EntityCapsManager extends Manager { */ private static final String DEFAULT_HASH = StringUtils.SHA1; - private static String DEFAULT_ENTITY_NODE = "http://www.igniterealtime.org/projects/smack"; + private static String DEFAULT_ENTITY_NODE = SmackConfiguration.SMACK_URL_STRING; protected static EntityCapsPersistentCache persistentCache; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java index a4a758e93..7a1149ea6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java @@ -25,6 +25,7 @@ import java.util.WeakHashMap; import javax.xml.namespace.QName; import org.jivesoftware.smack.Manager; +import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; @@ -193,7 +194,7 @@ public final class PrivateDataManager extends Manager { @Override public String getNamespace() { - return "https://igniterealtime.org/projects/smack/"; + return SmackConfiguration.SMACK_URL_STRING; } @Override