1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-21 19:42:05 +01:00

Rename ConnectionConfigurationBuilder to Builder

This commit is contained in:
Florian Schmaus 2014-12-17 17:01:53 +01:00
parent 31c53f094c
commit a87227c531
8 changed files with 38 additions and 41 deletions

View file

@ -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<BOSHConfigurationBuilder, BOSHConfiguration> {
public static class Builder extends ConnectionConfiguration.Builder<Builder, BOSHConfiguration> {
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;
}
}

View file

@ -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.

View file

@ -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 <B> the builder type parameter.
* @param <C> the resulting connection configuration type parameter.
*/
public static abstract class ConnectionConfigurationBuilder<B extends ConnectionConfigurationBuilder<B, C>, C extends ConnectionConfiguration> {
public static abstract class Builder<B extends Builder<B, C>, 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() {
}
/**

View file

@ -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;

View file

@ -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 extends ConnectionConfigurationBuilder<B,?>> B setTLSOnly(B builder) {
public static <B extends ConnectionConfiguration.Builder<B,?>> 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 extends ConnectionConfigurationBuilder<B,?>> B setSSLv3AndTLSOnly(B builder) {
public static <B extends ConnectionConfiguration.Builder<B,?>> 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 extends ConnectionConfigurationBuilder<B,?>> B acceptAllCertificates(B builder) throws NoSuchAlgorithmException, KeyManagementException {
public static <B extends ConnectionConfiguration.Builder<B,?>> B acceptAllCertificates(B builder) throws NoSuchAlgorithmException, KeyManagementException {
SSLContext context = SSLContext.getInstance(TLS);
context.init(null, new TrustManager[] { new AcceptAllTrustManager() }, new SecureRandom());
builder.setCustomSSLContext(context);

View file

@ -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<TopLevelStreamElement> queue = new LinkedBlockingQueue<TopLevelStreamElement>();
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<DummyConnectionConfigurationBuilder, DummyConnectionConfiguration> {
ConnectionConfiguration.Builder<Builder, DummyConnectionConfiguration> {
private DummyConnectionConfigurationBuilder() {
private Builder() {
}
@Override
@ -253,7 +252,7 @@ public class DummyConnection extends AbstractXMPPConnection {
}
@Override
protected DummyConnectionConfigurationBuilder getThis() {
protected Builder getThis() {
return this;
}
}

View file

@ -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();

View file

@ -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<XMPPTCPConnectionConfigurationBuilder, XMPPTCPConnectionConfiguration> {
public static class Builder extends ConnectionConfiguration.Builder<Builder, XMPPTCPConnectionConfiguration> {
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;
}