Class ProtocolDispatchSelector
- java.lang.Object
-
- java.net.ProxySelector
-
- com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector
-
public class ProtocolDispatchSelector extends ProxySelector
This is a facade for a list of ProxySelecor objects. You can register different ProxySelectors per Protocol.- Author:
- Markus Bernhardt, Copyright 2016, Bernd Rosstauscher, Copyright 2009
-
-
Constructor Summary
Constructors Constructor Description ProtocolDispatchSelector()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnectFailed(URI uri, SocketAddress sa, IOException ioe)connectFailedProxySelectorgetSelector(String protocol)Gets the selector installed for the given protocol.ProxySelectorremoveSelector(String protocol)Removes the selector installed for the given protocol.List<Proxy>select(URI uri)selectvoidsetFallbackSelector(ProxySelector selector)Sets the fallback selector that is always called when no matching protocol selector was found..voidsetSelector(String protocol, ProxySelector selector)Sets a selector responsible for the given protocol.intsize()Gets the size of the selector map.StringtoString()-
Methods inherited from class java.net.ProxySelector
getDefault, of, setDefault
-
-
-
-
Method Detail
-
setSelector
public void setSelector(String protocol, ProxySelector selector)
Sets a selector responsible for the given protocol.- Parameters:
protocol- the name of the protocol.selector- the selector to use.
-
removeSelector
public ProxySelector removeSelector(String protocol)
Removes the selector installed for the given protocol.- Parameters:
protocol- the protocol name.- Returns:
- the old selector that is removed.
-
getSelector
public ProxySelector getSelector(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(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(URI uri, SocketAddress sa, IOException ioe)
connectFailed- Specified by:
connectFailedin classProxySelector- See Also:
ProxySelector.connectFailed(java.net.URI, java.net.SocketAddress, java.io.IOException)
-
select
public List<Proxy> select(URI uri)
select- Specified by:
selectin classProxySelector- 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.
-
-