public class Protocol
extends java.lang.Object
One use case for modifying the default set of protocols would be to set a custom SSL socket factory. This would look something like the following:
Protocol myHTTPS = new Protocol( "https", new MySSLSocketFactory(), 443 ); Protocol.registerProtocol( "https", myHTTPS );
Constructor and Description |
---|
Protocol(java.lang.String scheme,
ProtocolSocketFactory factory,
int defaultPort)
Constructs a new Protocol.
|
Protocol(java.lang.String scheme,
SecureProtocolSocketFactory factory,
int defaultPort)
Deprecated.
Use the constructor that uses ProtocolSocketFactory, this version of
the constructor is only kept for backwards API compatibility.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Return true if the specified object equals this object.
|
int |
getDefaultPort()
Returns the defaultPort.
|
static Protocol |
getProtocol(java.lang.String id)
Gets the protocol with the given ID.
|
java.lang.String |
getScheme()
Returns the scheme.
|
ProtocolSocketFactory |
getSocketFactory()
Returns the socketFactory.
|
int |
hashCode()
Return a hash code for this object
|
boolean |
isSecure()
Returns true if this protocol is secure
|
static void |
registerProtocol(java.lang.String id,
Protocol protocol)
Registers a new protocol with the given identifier.
|
int |
resolvePort(int port)
Resolves the correct port for this protocol.
|
java.lang.String |
toString()
Return a string representation of this object.
|
static void |
unregisterProtocol(java.lang.String id)
Unregisters the protocol with the given ID.
|
public Protocol(java.lang.String scheme, ProtocolSocketFactory factory, int defaultPort)
factory
.scheme
- the scheme (e.g. http, https)factory
- the factory for creating sockets for communication using
this protocoldefaultPort
- the port this protocol defaults topublic Protocol(java.lang.String scheme, SecureProtocolSocketFactory factory, int defaultPort)
factory
.scheme
- the scheme (e.g. http, https)factory
- the factory for creating sockets for communication using
this protocoldefaultPort
- the port this protocol defaults topublic static void registerProtocol(java.lang.String id, Protocol protocol)
id
- the identifier for this protocolprotocol
- the protocol to registergetProtocol(String)
public static void unregisterProtocol(java.lang.String id)
id
- the ID of the protocol to removepublic static Protocol getProtocol(java.lang.String id) throws java.lang.IllegalStateException
id
- the protocol IDjava.lang.IllegalStateException
- if a protocol with the ID cannot be foundpublic int getDefaultPort()
public ProtocolSocketFactory getSocketFactory()
public java.lang.String getScheme()
public boolean isSecure()
public int resolvePort(int port)
port
- the port to be resolvedpublic java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- The object to compare against.public int hashCode()
hashCode
in class java.lang.Object
Copyright © 2001-2012 Apache Software Foundation. All Rights Reserved.