Class 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  
    • 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)
      connectFailed
      java.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)
      select
      void 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()  
      • Methods inherited from class java.net.ProxySelector

        getDefault, of, setDefault
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • selectors

        private java.util.Map<java.lang.String,​java.net.ProxySelector> selectors
      • fallbackSelector

        private java.net.ProxySelector fallbackSelector
    • Constructor Detail

      • ProtocolDispatchSelector

        public ProtocolDispatchSelector()
        Constructor
    • 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 class java.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 class java.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 class java.lang.Object