Package net.webpdf.wsclient.session.soap
Class ClientProxySelector
- java.lang.Object
-
- java.net.ProxySelector
-
- net.webpdf.wsclient.session.soap.ClientProxySelector
-
- All Implemented Interfaces:
AutoCloseable
public class ClientProxySelector extends ProxySelector implements AutoCloseable
An instance ofClientProxySelectorinitializes a custom proxy selector, that prepares proxy settings for webPDF calls. It shall fall back to the default proxy selector, when a processedURIis not pointing to a webPDF endpoint. It will restore the previously set proxy selector, when closed. The default proxy selector shall also be used as a fallback, when a resource path shall be routed, that is not based on one of the given routedResources.
-
-
Constructor Summary
Constructors Constructor Description ClientProxySelector(@NotNull URI[] routedResources, @NotNull org.apache.hc.core5.http.HttpHost... proxies)Initializes a custom proxy selector, that prepares proxy settings for webPDF calls.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProxy(@NotNull org.apache.hc.core5.http.HttpHost proxy)Adds the given proxy to the list of usable proxy servers.voidaddRoutedResource(URI routedResource)voidclose()Restores the previously found proxy selector as the VM's default.voidconnectFailed(@Nullable URI uri, @Nullable SocketAddress socketAddress, @Nullable IOException exception)Called to indicate that a connection could not be established to a proxy/socks server.@NotNull List<Proxy>select(@Nullable URI uri)Selects all the applicable proxies based on the protocol to access the resource with and a destination address to access the resource at.-
Methods inherited from class java.net.ProxySelector
getDefault, of, setDefault
-
-
-
-
Constructor Detail
-
ClientProxySelector
public ClientProxySelector(@NotNull @NotNull URI[] routedResources, @NotNull @NotNull org.apache.hc.core5.http.HttpHost... proxies)Initializes a custom proxy selector, that prepares proxy settings for webPDF calls. It shall fall back to the default proxy selector, when a processedURIis not pointing to a webPDF endpoint. It will restore the previously set proxy selector, when closed. The default proxy selector shall also be used as a fallback, when a resource path shall be routed, that is not based on one of the given routedResources.
-
-
Method Detail
-
addProxy
public void addProxy(@NotNull @NotNull org.apache.hc.core5.http.HttpHost proxy)Adds the given proxy to the list of usable proxy servers.- Parameters:
proxy- A proxy server, that shall be used.
-
addRoutedResource
public void addRoutedResource(URI routedResource)
Adds the givenURIto the list ofURIs, that must be resolved using a proxy route from this selector. AllURIs a proxy shall be requested for, will be routed, if they start with one of the hereby configuredURIs. (otherwise a default selector shall be used instead.)- Parameters:
routedResource- TheURI, that shall be routed via this selector.
-
select
@NotNull public @NotNull List<Proxy> select(@Nullable @Nullable URI uri)
Selects all the applicable proxies based on the protocol to access the resource with and a destination address to access the resource at. The format of theURIis defined as follows:- http
URIfor http connections - https
URIfor https connections socket://host:port
for tcp client sockets connections
If the
URIdoes not point to a routed resource, the previously known default proxy selector shall be used, to select the proxies.- Specified by:
selectin classProxySelector- Parameters:
uri- TheURIthat a connection is required to.- Returns:
- A List of Proxies. Each element in the List is of type
Proxy; when no proxy is available, the list will contain one element of typeProxythat represents a direct connection. - Throws:
IllegalArgumentException- if the argument isnull.
- http
-
connectFailed
public void connectFailed(@Nullable @Nullable URI uri, @Nullable @Nullable SocketAddress socketAddress, @Nullable @Nullable IOException exception)Called to indicate that a connection could not be established to a proxy/socks server. An implementation of this method can temporarily remove the proxies or reorder the sequence of proxies returned byselect(URI), using the address and theIOExceptioncaught when trying to connect.- Specified by:
connectFailedin classProxySelector- Parameters:
uri- TheURIthat a connection could not be established to.socketAddress- TheSocketAddressof the proxy/SOCKS serverexception- TheIOException, that shall be thrown when a connection attempt fails.- Throws:
IllegalArgumentException- Shall be thrown, when either argument isnull.
-
close
public void close()
Restores the previously found proxy selector as the VM's default.- Specified by:
closein interfaceAutoCloseable
-
-