From a87227c531c4919107ae3d4a0d4e4875d43158de Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 17 Dec 2014 17:01:53 +0100 Subject: [PATCH] Rename ConnectionConfigurationBuilder to Builder --- .../smack/bosh/BOSHConfiguration.java | 18 +++++++++--------- .../smack/AbstractXMPPConnection.java | 7 +++---- .../smack/ConnectionConfiguration.java | 8 ++++---- .../jivesoftware/smack/SmackConfiguration.java | 3 +-- .../org/jivesoftware/smack/util/TLSUtils.java | 8 ++++---- .../jivesoftware/smack/DummyConnection.java | 17 ++++++++--------- .../smack/RosterVersioningTest.java | 4 ++-- .../tcp/XMPPTCPConnectionConfiguration.java | 14 +++++++------- 8 files changed, 38 insertions(+), 41 deletions(-) diff --git a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java index a586eaca2..32a5e13a4 100644 --- a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java +++ b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java @@ -35,7 +35,7 @@ public class BOSHConfiguration extends ConnectionConfiguration { private final boolean https; private final String file; - private BOSHConfiguration(BOSHConfigurationBuilder builder) { + private BOSHConfiguration(Builder builder) { super(builder); https = builder.https; if (builder.file.charAt(0) != '/') { @@ -69,27 +69,27 @@ public class BOSHConfiguration extends ConnectionConfiguration { return new URI((https ? "https://" : "http://") + this.host + ":" + this.port + file); } - public static BOSHConfigurationBuilder builder() { - return new BOSHConfigurationBuilder(); + public static Builder builder() { + return new Builder(); } - public static class BOSHConfigurationBuilder extends ConnectionConfigurationBuilder { + public static class Builder extends ConnectionConfiguration.Builder { private boolean https; private String file; - private BOSHConfigurationBuilder() { + private Builder() { } - public BOSHConfigurationBuilder setUseHttps(boolean useHttps) { + public Builder setUseHttps(boolean useHttps) { https = useHttps; return this; } - public BOSHConfigurationBuilder useHttps() { + public Builder useHttps() { return setUseHttps(true); } - public BOSHConfigurationBuilder setFile(String file) { + public Builder setFile(String file) { this.file = file; return this; } @@ -100,7 +100,7 @@ public class BOSHConfiguration extends ConnectionConfiguration { } @Override - protected BOSHConfigurationBuilder getThis() { + protected Builder getThis() { return this; } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 843f811b7..6b30bfa15 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -40,7 +40,6 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; import java.util.logging.Logger; -import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder; import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode; import org.jivesoftware.smack.SmackException.AlreadyConnectedException; import org.jivesoftware.smack.SmackException.AlreadyLoggedInException; @@ -348,12 +347,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * Before logging in (i.e. authenticate) to the server the connection must be connected. * * It is possible to log in without sending an initial available presence by using - * {@link ConnectionConfigurationBuilder#setSendPresence(boolean)}. If this connection is + * {@link ConnectionConfiguration.Builder#setSendPresence(boolean)}. If this connection is * not interested in loading its roster upon login then use - * {@link ConnectionConfigurationBuilder#setRosterLoadedAtLogin(boolean)}. + * {@link ConnectionConfiguration.Builder#setRosterLoadedAtLogin(boolean)}. * Finally, if you want to not pass a password and instead use a more advanced mechanism * while using SASL then you may be interested in using - * {@link ConnectionConfigurationBuilder#setCallbackHandler(javax.security.auth.callback.CallbackHandler)}. + * {@link ConnectionConfiguration.Builder#setCallbackHandler(javax.security.auth.callback.CallbackHandler)}. * For more advanced login settings see {@link ConnectionConfiguration}. * * @throws XMPPException if an error occurs on the XMPP protocol level. diff --git a/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java b/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java index 039f6fcb7..4745f2751 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java @@ -93,7 +93,7 @@ public abstract class ConnectionConfiguration { // Holds the proxy information (such as proxyhost, proxyport, username, password etc) protected final ProxyInfo proxy; - protected ConnectionConfiguration(ConnectionConfigurationBuilder builder) { + protected ConnectionConfiguration(Builder builder) { if (builder.username != null) { // Do partial version of nameprep on the username. username = builder.username.toLowerCase(Locale.US).trim(); @@ -196,7 +196,7 @@ public abstract class ConnectionConfiguration { } /** - * Gets the custom SSLContext previously set with {@link ConnectionConfigurationBuilder#setCustomSSLContext(SSLContext)} for + * Gets the custom SSLContext previously set with {@link ConnectionConfiguration.Builder#setCustomSSLContext(SSLContext)} for * SSL sockets. This is null by default. * * @return the custom SSLContext or null. @@ -390,7 +390,7 @@ public abstract class ConnectionConfiguration { * @param the builder type parameter. * @param the resulting connection configuration type parameter. */ - public static abstract class ConnectionConfigurationBuilder, C extends ConnectionConfiguration> { + public static abstract class Builder, C extends ConnectionConfiguration> { private SecurityMode securityMode = SecurityMode.enabled; private String keystorePath = System.getProperty("javax.net.ssl.keyStore"); private String keystoreType = "jks"; @@ -415,7 +415,7 @@ public abstract class ConnectionConfiguration { private String host; private int port = 5222; - protected ConnectionConfigurationBuilder() { + protected Builder() { } /** 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 7cfb2e963..aacf7ac6d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java @@ -28,7 +28,6 @@ import java.util.Set; import javax.net.ssl.HostnameVerifier; -import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder; import org.jivesoftware.smack.compression.XMPPInputOutputStream; import org.jivesoftware.smack.debugger.ReflectionDebuggerFactory; import org.jivesoftware.smack.debugger.SmackDebugger; @@ -268,7 +267,7 @@ public final class SmackConfiguration { * Set the default HostnameVerifier that will be used by XMPP connections to verify the hostname * of a TLS certificate. XMPP connections are able to overwrite this settings by supplying a * HostnameVerifier in their ConnecitonConfiguration with - * {@link ConnectionConfigurationBuilder#setHostnameVerifier(HostnameVerifier)}. + * {@link ConnectionConfiguration.Builder#setHostnameVerifier(HostnameVerifier)}. */ public static void setDefaultHostnameVerifier(HostnameVerifier verifier) { defaultHostnameVerififer = verifier; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/TLSUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/TLSUtils.java index 1250a122a..e85de4973 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/TLSUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/TLSUtils.java @@ -30,7 +30,7 @@ import javax.net.ssl.SSLSocket; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; -import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder; +import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.SmackException.SecurityNotPossibleException; @@ -55,7 +55,7 @@ public class TLSUtils { * * @param builder the configuration builder to apply this setting to */ - public static > B setTLSOnly(B builder) { + public static > B setTLSOnly(B builder) { builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1 }); return builder; } @@ -72,7 +72,7 @@ public class TLSUtils { * * @param builder the configuration builder to apply this setting to */ - public static > B setSSLv3AndTLSOnly(B builder) { + public static > B setSSLv3AndTLSOnly(B builder) { builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1, PROTO_SSL3 }); return builder; } @@ -88,7 +88,7 @@ public class TLSUtils { * @throws NoSuchAlgorithmException * @throws KeyManagementException */ - public static > B acceptAllCertificates(B builder) throws NoSuchAlgorithmException, KeyManagementException { + public static > B acceptAllCertificates(B builder) throws NoSuchAlgorithmException, KeyManagementException { SSLContext context = SSLContext.getInstance(TLS); context.init(null, new TrustManager[] { new AcceptAllTrustManager() }, new SecureRandom()); builder.setCustomSSLContext(context); diff --git a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java index 030f09944..2a5235d71 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java @@ -23,7 +23,6 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; -import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder; import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.PlainStreamElement; import org.jivesoftware.smack.packet.TopLevelStreamElement; @@ -54,7 +53,7 @@ public class DummyConnection extends AbstractXMPPConnection { private final BlockingQueue queue = new LinkedBlockingQueue(); - public static ConnectionConfigurationBuilder getDummyConfigurationBuilder() { + public static ConnectionConfiguration.Builder getDummyConfigurationBuilder() { return DummyConnectionConfiguration.builder().setServiceName("example.org").setUsernameAndPassword("dummy", "dummypass"); } @@ -232,19 +231,19 @@ public class DummyConnection extends AbstractXMPPConnection { } public static class DummyConnectionConfiguration extends ConnectionConfiguration { - protected DummyConnectionConfiguration(DummyConnectionConfigurationBuilder builder) { + protected DummyConnectionConfiguration(Builder builder) { super(builder); } - public static DummyConnectionConfigurationBuilder builder() { - return new DummyConnectionConfigurationBuilder(); + public static Builder builder() { + return new Builder(); } - public static class DummyConnectionConfigurationBuilder + public static class Builder extends - ConnectionConfigurationBuilder { + ConnectionConfiguration.Builder { - private DummyConnectionConfigurationBuilder() { + private Builder() { } @Override @@ -253,7 +252,7 @@ public class DummyConnection extends AbstractXMPPConnection { } @Override - protected DummyConnectionConfigurationBuilder getThis() { + protected Builder getThis() { return this; } } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/RosterVersioningTest.java b/smack-core/src/test/java/org/jivesoftware/smack/RosterVersioningTest.java index 68b70822a..dd9e9dae2 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/RosterVersioningTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/RosterVersioningTest.java @@ -26,7 +26,7 @@ import java.io.IOException; import java.util.Collection; import java.util.HashSet; -import org.jivesoftware.smack.ConnectionConfiguration.ConnectionConfigurationBuilder; +import org.jivesoftware.smack.ConnectionConfiguration.Builder; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ.Type; import org.jivesoftware.smack.packet.Packet; @@ -65,7 +65,7 @@ public class RosterVersioningTest { DirectoryRosterStore store = DirectoryRosterStore.init(tmpFolder.newFolder("store")); populateStore(store); - ConnectionConfigurationBuilder builder = DummyConnection.getDummyConfigurationBuilder(); + Builder builder = DummyConnection.getDummyConfigurationBuilder(); builder.setRosterStore(store); connection = new DummyConnection(builder.build()); connection.connect(); diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnectionConfiguration.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnectionConfiguration.java index 27701dbe6..57a46d9ef 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnectionConfiguration.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnectionConfiguration.java @@ -22,7 +22,7 @@ public class XMPPTCPConnectionConfiguration extends ConnectionConfiguration { private final boolean compressionEnabled; - private XMPPTCPConnectionConfiguration(XMPPTCPConnectionConfigurationBuilder builder) { + private XMPPTCPConnectionConfiguration(Builder builder) { super(builder); compressionEnabled = builder.compressionEnabled; } @@ -40,14 +40,14 @@ public class XMPPTCPConnectionConfiguration extends ConnectionConfiguration { return compressionEnabled; } - public static XMPPTCPConnectionConfigurationBuilder builder() { - return new XMPPTCPConnectionConfigurationBuilder(); + public static Builder builder() { + return new Builder(); } - public static class XMPPTCPConnectionConfigurationBuilder extends ConnectionConfigurationBuilder { + public static class Builder extends ConnectionConfiguration.Builder { private boolean compressionEnabled = false; - private XMPPTCPConnectionConfigurationBuilder() { + private Builder() { } /** @@ -58,13 +58,13 @@ public class XMPPTCPConnectionConfiguration extends ConnectionConfiguration { * * @param compressionEnabled if the connection is going to use stream compression. */ - public XMPPTCPConnectionConfigurationBuilder setCompressionEnabled(boolean compressionEnabled) { + public Builder setCompressionEnabled(boolean compressionEnabled) { this.compressionEnabled = compressionEnabled; return this; } @Override - protected XMPPTCPConnectionConfigurationBuilder getThis() { + protected Builder getThis() { return this; }