Removed static socket factories; adjusted Scheme#hashCode and Scheme#equals

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1053589 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2010-12-29 09:54:02 +00:00
parent 18de7cda9c
commit eda06a75ee
4 changed files with 4 additions and 19 deletions

View File

@ -56,21 +56,15 @@ import org.apache.http.params.HttpParams;
@Immutable @Immutable
public class PlainSocketFactory implements SocketFactory, SchemeSocketFactory { public class PlainSocketFactory implements SocketFactory, SchemeSocketFactory {
/**
* The default factory.
*/
private static final PlainSocketFactory DEFAULT_FACTORY = new PlainSocketFactory();
private final HostNameResolver nameResolver; private final HostNameResolver nameResolver;
/** /**
* Gets the default factory. Usually there should be no reason for creating * Gets the default factory.
* multiple instances of this class.
* *
* @return the default factory * @return the default factory
*/ */
public static PlainSocketFactory getSocketFactory() { public static PlainSocketFactory getSocketFactory() {
return DEFAULT_FACTORY; return new PlainSocketFactory();
} }
@Deprecated @Deprecated

View File

@ -242,8 +242,7 @@ public final class Scheme {
Scheme that = (Scheme) obj; Scheme that = (Scheme) obj;
return this.name.equals(that.name) return this.name.equals(that.name)
&& this.defaultPort == that.defaultPort && this.defaultPort == that.defaultPort
&& this.layered == that.layered && this.layered == that.layered;
&& this.socketFactory.equals(that.socketFactory);
} else { } else {
return false; return false;
} }
@ -255,7 +254,6 @@ public final class Scheme {
hash = LangUtils.hashCode(hash, this.defaultPort); hash = LangUtils.hashCode(hash, this.defaultPort);
hash = LangUtils.hashCode(hash, this.name); hash = LangUtils.hashCode(hash, this.name);
hash = LangUtils.hashCode(hash, this.layered); hash = LangUtils.hashCode(hash, this.layered);
hash = LangUtils.hashCode(hash, this.socketFactory);
return hash; return hash;
} }

View File

@ -155,11 +155,6 @@ public class SSLSocketFactory implements LayeredSchemeSocketFactory, LayeredSock
public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER
= new StrictHostnameVerifier(); = new StrictHostnameVerifier();
/**
* The default factory using the default JVM settings for secure connections.
*/
private static final SSLSocketFactory DEFAULT_FACTORY = new SSLSocketFactory();
/** /**
* Gets the default factory, which uses the default JVM settings for secure * Gets the default factory, which uses the default JVM settings for secure
* connections. * connections.
@ -167,7 +162,7 @@ public class SSLSocketFactory implements LayeredSchemeSocketFactory, LayeredSock
* @return the default factory * @return the default factory
*/ */
public static SSLSocketFactory getSocketFactory() { public static SSLSocketFactory getSocketFactory() {
return DEFAULT_FACTORY; return new SSLSocketFactory();
} }
private final javax.net.ssl.SSLSocketFactory socketfactory; private final javax.net.ssl.SSLSocketFactory socketfactory;

View File

@ -47,12 +47,10 @@ public class TestScheme {
Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory()); Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
Assert.assertEquals("http", http.getName()); Assert.assertEquals("http", http.getName());
Assert.assertEquals(80, http.getDefaultPort()); Assert.assertEquals(80, http.getDefaultPort());
Assert.assertSame(PlainSocketFactory.getSocketFactory(), http.getSchemeSocketFactory());
Assert.assertFalse(http.isLayered()); Assert.assertFalse(http.isLayered());
Scheme https = new Scheme("https", 443, SecureSocketFactoryMockup.INSTANCE); Scheme https = new Scheme("https", 443, SecureSocketFactoryMockup.INSTANCE);
Assert.assertEquals("https", https.getName()); Assert.assertEquals("https", https.getName());
Assert.assertEquals(443, https.getDefaultPort()); Assert.assertEquals(443, https.getDefaultPort());
Assert.assertSame(SecureSocketFactoryMockup.INSTANCE, https.getSchemeSocketFactory());
Assert.assertTrue(https.isLayered()); Assert.assertTrue(https.isLayered());
Scheme hTtP = new Scheme("hTtP", 80, PlainSocketFactory.getSocketFactory()); Scheme hTtP = new Scheme("hTtP", 80, PlainSocketFactory.getSocketFactory());