Class ProtocolDispatchSelector
- java.lang.Object
-
- java.net.ProxySelector
-
- com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector
-
public class ProtocolDispatchSelector extends java.net.ProxySelector
This 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.ProxySelector
fallbackSelector
private 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 void
connectFailed(java.net.URI uri, java.net.SocketAddress sa, java.io.IOException ioe)
connectFailedjava.net.ProxySelector
getSelector(java.lang.String protocol)
Gets the selector installed for the given protocol.java.net.ProxySelector
removeSelector(java.lang.String protocol)
Removes the selector installed for the given protocol.java.util.List<java.net.Proxy>
select(java.net.URI uri)
selectvoid
setFallbackSelector(java.net.ProxySelector selector)
Sets the fallback selector that is always called when no matching protocol selector was found..void
setSelector(java.lang.String protocol, java.net.ProxySelector selector)
Sets a selector responsible for the given protocol.int
size()
Gets the size of the selector map.java.lang.String
toString()
-
-
-
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:
connectFailed
in 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:
select
in 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:
toString
in classjava.lang.Object
-
-