Class ProtocolDispatchSelector
- java.lang.Object
-
- java.net.ProxySelector
-
- com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector
-
public class ProtocolDispatchSelector extends java.net.ProxySelectorThis is a facade for a list of ProxySelecor objects. You can register different ProxySelectors per Protocol.
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.ProxySelectorfallbackSelectorprivate java.util.Map<java.lang.String,java.net.ProxySelector>selectors
-
Constructor Summary
Constructors Constructor Description ProtocolDispatchSelector()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnectFailed(java.net.URI uri, java.net.SocketAddress sa, java.io.IOException ioe)connectFailedjava.net.ProxySelectorgetSelector(java.lang.String protocol)Gets the selector installed for the given protocol.java.net.ProxySelectorremoveSelector(java.lang.String protocol)Removes the selector installed for the given protocol.java.util.List<java.net.Proxy>select(java.net.URI uri)selectvoidsetFallbackSelector(java.net.ProxySelector selector)Sets the fallback selector that is always called when no matching protocol selector was found..voidsetSelector(java.lang.String protocol, java.net.ProxySelector selector)Sets a selector responsible for the given protocol.intsize()Gets the size of the selector map.java.lang.StringtoString()
-
-
-
Method Detail
-
setSelector
public void setSelector(java.lang.String protocol, java.net.ProxySelector selector)Sets a selector responsible for the given protocol.- Parameters:
protocol- the name of the protocol.selector- the selector to use.
-
removeSelector
public java.net.ProxySelector removeSelector(java.lang.String protocol)
Removes the selector installed for the given protocol.- Parameters:
protocol- the protocol name.- Returns:
- the old selector that is removed.
-
getSelector
public java.net.ProxySelector getSelector(java.lang.String protocol)
Gets the selector installed for the given protocol.- Parameters:
protocol- the protocol name.- Returns:
- the selector for that protocol, null if none is currently set.
-
setFallbackSelector
public void setFallbackSelector(java.net.ProxySelector selector)
Sets the fallback selector that is always called when no matching protocol selector was found..- Parameters:
selector- the selector to use.
-
connectFailed
public void connectFailed(java.net.URI uri, java.net.SocketAddress sa, java.io.IOException ioe)connectFailed- Specified by:
connectFailedin classjava.net.ProxySelector- See Also:
ProxySelector.connectFailed(java.net.URI, java.net.SocketAddress, java.io.IOException)
-
select
public java.util.List<java.net.Proxy> select(java.net.URI uri)
select- Specified by:
selectin classjava.net.ProxySelector- See Also:
ProxySelector.select(java.net.URI)
-
size
public int size()
Gets the size of the selector map.- Returns:
- the size of the selector map.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-