Class BufferedProxySelector
- java.lang.Object
-
- java.net.ProxySelector
-
- com.github.markusbernhardt.proxy.selector.misc.BufferedProxySelector
-
public class BufferedProxySelector extends java.net.ProxySelectorImplements a cache that can be used to warp it around an existing ProxySelector. You can specify a maximum cache size and a "time to live" for positive resolves.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classBufferedProxySelector.CacheEntrystatic classBufferedProxySelector.CacheScopeDefine the available scopes of the cache key generation
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentHashMap<java.lang.String,BufferedProxySelector.CacheEntry>cacheprivate BufferedProxySelector.CacheScopecacheScopeprivate java.net.ProxySelectordelegateprivate intmaxSizeprivate longttl
-
Constructor Summary
Constructors Constructor Description BufferedProxySelector(int maxSize, long ttl, java.net.ProxySelector delegate, BufferedProxySelector.CacheScope cacheScope)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)connectFailedprivate voidpurgeCache()Purge cache to get some free space for a new entry.java.util.List<java.net.Proxy>select(java.net.URI uri)selectjava.lang.StringtoString()
-
-
-
Field Detail
-
delegate
private java.net.ProxySelector delegate
-
cache
private java.util.concurrent.ConcurrentHashMap<java.lang.String,BufferedProxySelector.CacheEntry> cache
-
maxSize
private int maxSize
-
ttl
private long ttl
-
cacheScope
private BufferedProxySelector.CacheScope cacheScope
-
-
Constructor Detail
-
BufferedProxySelector
public BufferedProxySelector(int maxSize, long ttl, java.net.ProxySelector delegate, BufferedProxySelector.CacheScope cacheScope)Constructor- Parameters:
maxSize- the max size for the cache.ttl- the "time to live" for cache entries as amount in milliseconds.delegate- the delegate to use.cacheScope- the desired cache scope.
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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)
-
purgeCache
private void purgeCache()
Purge cache to get some free space for a new entry.
-
-