Top Description Fields Constructors Methods
org.apache.hc.client5.http

public final Class RouteTracker

extends Object
implements RouteInfo, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, org.apache.hc.client5.http.RouteInfo
Imports
java.net.InetAddress, java.util.Objects, org.apache.hc.core5.http.HttpHost, org.apache.hc.core5.util.Args, .Asserts, .LangUtils

Helps tracking the steps in establishing a route.
Since
4.0

Field Summary

Modifier and TypeField and Description
private boolean
connected

Whether the first hop of the route is established.

private RouteInfo.LayerType
layered

Whether the route is layered over a tunnel.

private final InetAddress
localAddress

The local address to connect from.

private HttpHost[]
proxyChain

The proxy chain, if any.

private boolean
secure

Whether the route is secure.

private final HttpHost
targetHost

The target host to connect to.

private RouteInfo.TunnelType
tunnelled

Whether the the route is tunnelled end-to-end through proxies.

Constructor Summary

AccessConstructor and Description
public
RouteTracker(final HttpHost
the host to which to route
target
,
final InetAddress
the local address to route from, or null for the default
local
)

Creates a new route tracker.

public
RouteTracker(final HttpRoute
the route to track
route
)

Creates a new tracker for the given route.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public void
connectProxy(final HttpHost
the proxy connected to
proxy
,
final boolean
true if the route is secure, false otherwise
secure
)

Tracks connecting to the first proxy.

public void
connectTarget(final boolean
true if the route is secure, false otherwise
secure
)

Tracks connecting to the target.

public boolean

Returns:

true if the argument is the same tracked route, false
equals
(final Object
the object to compare with
o
)

Overrides java.lang.Object.equals.

Compares this tracked route to another.
public int
getHopCount()

Implements org.apache.hc.client5.http.RouteInfo.getHopCount.

Obtains the number of hops in this route.
public HttpHost
getHopTarget(final int
index of the hop for which to get the target, 0 for first
hop
)

Implements org.apache.hc.client5.http.RouteInfo.getHopTarget.

Obtains the target of a hop in this route.
public RouteInfo.LayerType
getLayerType()

Implements org.apache.hc.client5.http.RouteInfo.getLayerType.

Obtains the layering type of this route.
public InetAddress
getLocalAddress()

Implements org.apache.hc.client5.http.RouteInfo.getLocalAddress.

Obtains the local address to connect from.
public HttpHost
getProxyHost()

Implements org.apache.hc.client5.http.RouteInfo.getProxyHost.

Obtains the first proxy host.
public HttpHost
public RouteInfo.TunnelType
getTunnelType()

Implements org.apache.hc.client5.http.RouteInfo.getTunnelType.

Obtains the tunnel type of this route.
public int

Returns:

the hash code
hashCode
()

Overrides java.lang.Object.hashCode.

Generates a hash code for this tracked route.
public boolean
public boolean
isLayered()

Implements org.apache.hc.client5.http.RouteInfo.isLayered.

Checks whether this route includes a layered protocol.
public boolean
isSecure()

Implements org.apache.hc.client5.http.RouteInfo.isSecure.

Checks whether this route is secure.
public boolean
isTunnelled()

Implements org.apache.hc.client5.http.RouteInfo.isTunnelled.

Checks whether this route is tunnelled through a proxy.
public void
layerProtocol(final boolean
true if the route is secure, false otherwise
secure
)

Tracks layering a protocol.

public void
public HttpRoute

Returns:

the tracked route, or null if nothing has been tracked so far
toRoute
()

Obtains the tracked route.

public String

Returns:

a human-readable representation of the tracked route
toString
()

Overrides java.lang.Object.toString.

Obtains a description of the tracked route.
public void
tunnelProxy(final HttpHost
the proxy tunnelled to
proxy
,
final boolean
true if the route is secure, false otherwise
secure
)

Tracks tunnelling to a proxy in a proxy chain.

public void
tunnelTarget(final boolean
true if the route is secure, false otherwise
secure
)

Tracks tunnelling to the target.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

connectedback to summary
private boolean connected

Whether the first hop of the route is established.

layeredback to summary
private RouteInfo.LayerType layered

Whether the route is layered over a tunnel.

localAddressback to summary
private final InetAddress localAddress

The local address to connect from. null indicates that the default should be used.

proxyChainback to summary
private HttpHost[] proxyChain

The proxy chain, if any.

secureback to summary
private boolean secure

Whether the route is secure.

targetHostback to summary
private final HttpHost targetHost

The target host to connect to.

tunnelledback to summary
private RouteInfo.TunnelType tunnelled

Whether the the route is tunnelled end-to-end through proxies.

Constructor Detail

RouteTrackerback to summary
public RouteTracker(final HttpHost target, final InetAddress local)

Creates a new route tracker. The target and origin need to be specified at creation time.

Parameters
target:HttpHost

the host to which to route

local:InetAddress

the local address to route from, or null for the default

RouteTrackerback to summary
public RouteTracker(final HttpRoute route)

Creates a new tracker for the given route. Only target and origin are taken from the route, everything else remains to be tracked.

Parameters
route:HttpRoute

the route to track

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
connectProxyback to summary
public void connectProxy(final HttpHost proxy, final boolean secure)

Tracks connecting to the first proxy.

Parameters
proxy:HttpHost

the proxy connected to

secure:boolean

true if the route is secure, false otherwise

connectTargetback to summary
public void connectTarget(final boolean secure)

Tracks connecting to the target.

Parameters
secure:boolean

true if the route is secure, false otherwise

equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

Compares this tracked route to another.

Parameters
o:Object

the object to compare with

Returns:boolean

true if the argument is the same tracked route, false

Annotations
@Override
getHopCountback to summary
public int getHopCount()

Implements org.apache.hc.client5.http.RouteInfo.getHopCount.

Doc from org.apache.hc.client5.http.RouteInfo.getHopCount.

Obtains the number of hops in this route. A direct route has one hop. A route through a proxy has two hops. A route through a chain of n proxies has n+1 hops.

Returns:int

the number of hops in this route

Annotations
@Override
getHopTargetback to summary
public HttpHost getHopTarget(final int hop)

Implements org.apache.hc.client5.http.RouteInfo.getHopTarget.

Doc from org.apache.hc.client5.http.RouteInfo.getHopTarget.

Obtains the target of a hop in this route. The target of the last hop is the target host, the target of previous hops is the respective proxy in the chain. For a route through exactly one proxy, target of hop 0 is the proxy and target of hop 1 is the target host.

Parameters
hop:int

index of the hop for which to get the target, 0 for first

Returns:HttpHost

the target of the given hop

Annotations
@Override
getLayerTypeback to summary
public RouteInfo.LayerType getLayerType()

Implements org.apache.hc.client5.http.RouteInfo.getLayerType.

Doc from org.apache.hc.client5.http.RouteInfo.getLayerType.

Obtains the layering type of this route. In the presence of proxies, only layering over an end-to-end tunnel is considered.

Returns:RouteInfo.LayerType

the layering type

Annotations
@Override
getLocalAddressback to summary
public InetAddress getLocalAddress()

Implements org.apache.hc.client5.http.RouteInfo.getLocalAddress.

Doc from org.apache.hc.client5.http.RouteInfo.getLocalAddress.

Obtains the local address to connect from.

Returns:InetAddress

the local address, or null

Annotations
@Override
getProxyHostback to summary
public HttpHost getProxyHost()

Implements org.apache.hc.client5.http.RouteInfo.getProxyHost.

Doc from org.apache.hc.client5.http.RouteInfo.getProxyHost.

Obtains the first proxy host.

Returns:HttpHost

the first proxy in the proxy chain, or null if this route is direct

Annotations
@Override
getTargetHostback to summary
public HttpHost getTargetHost()

Implements org.apache.hc.client5.http.RouteInfo.getTargetHost.

Doc from org.apache.hc.client5.http.RouteInfo.getTargetHost.

Obtains the target host.

Returns:HttpHost

the target host

Annotations
@Override
getTunnelTypeback to summary
public RouteInfo.TunnelType getTunnelType()

Implements org.apache.hc.client5.http.RouteInfo.getTunnelType.

Doc from org.apache.hc.client5.http.RouteInfo.getTunnelType.

Obtains the tunnel type of this route. If there is a proxy chain, only end-to-end tunnels are considered.

Returns:RouteInfo.TunnelType

the tunnelling type

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Generates a hash code for this tracked route. Route trackers are modifiable and should therefore not be used as lookup keys. Use toRoute to obtain an unmodifiable representation of the tracked route.

Returns:int

the hash code

Annotations
@Override
isConnectedback to summary
public boolean isConnected()
isLayeredback to summary
public boolean isLayered()

Implements org.apache.hc.client5.http.RouteInfo.isLayered.

Doc from org.apache.hc.client5.http.RouteInfo.isLayered.

Checks whether this route includes a layered protocol. In the presence of proxies, only layering over an end-to-end tunnel is considered.

Returns:boolean

true if layered, false otherwise

Annotations
@Override
isSecureback to summary
public boolean isSecure()

Implements org.apache.hc.client5.http.RouteInfo.isSecure.

Doc from org.apache.hc.client5.http.RouteInfo.isSecure.

Checks whether this route is secure.

Returns:boolean

true if secure, false otherwise

Annotations
@Override
isTunnelledback to summary
public boolean isTunnelled()

Implements org.apache.hc.client5.http.RouteInfo.isTunnelled.

Doc from org.apache.hc.client5.http.RouteInfo.isTunnelled.

Checks whether this route is tunnelled through a proxy. If there is a proxy chain, only end-to-end tunnels are considered.

Returns:boolean

true if tunnelled end-to-end through at least one proxy, false otherwise

Annotations
@Override
layerProtocolback to summary
public void layerProtocol(final boolean secure)

Tracks layering a protocol.

Parameters
secure:boolean

true if the route is secure, false otherwise

resetback to summary
public void reset()
Since
4.2
toRouteback to summary
public HttpRoute toRoute()

Obtains the tracked route. If a route has been tracked, it is connected. If not connected, nothing has been tracked so far.

Returns:HttpRoute

the tracked route, or null if nothing has been tracked so far

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Obtains a description of the tracked route.

Returns:String

a human-readable representation of the tracked route

Annotations
@Override
tunnelProxyback to summary
public void tunnelProxy(final HttpHost proxy, final boolean secure)

Tracks tunnelling to a proxy in a proxy chain. This will extend the tracked proxy chain, but it does not mark the route as tunnelled. Only end-to-end tunnels are considered there.

Parameters
proxy:HttpHost

the proxy tunnelled to

secure:boolean

true if the route is secure, false otherwise

tunnelTargetback to summary
public void tunnelTarget(final boolean secure)

Tracks tunnelling to the target.

Parameters
secure:boolean

true if the route is secure, false otherwise