org.apache.http.conn
Class RouteTracker

java.lang.Object
  extended by org.apache.http.conn.RouteTracker
All Implemented Interfaces:
java.lang.Cloneable

public final class RouteTracker
extends java.lang.Object
implements java.lang.Cloneable

Helps tracking the steps in establishing a route.

Since:
4.0
Version:
$Revision: 555215 $
Author:
Roland Weber

Constructor Summary
RouteTracker(org.apache.http.HttpHost target, java.net.InetAddress local)
          Creates a new route tracker.
RouteTracker(HttpRoute route)
          Creates a new tracker for the given route.
 
Method Summary
 java.lang.Object clone()
           
 void connectProxy(org.apache.http.HttpHost proxy, boolean secure)
          Tracks connecting to the first proxy.
 void connectTarget(boolean secure)
          Tracks connecting to the target.
 boolean equals(java.lang.Object o)
          Compares this tracked route to another.
 int getHopCount()
          Obtains the number of tracked hops.
 org.apache.http.HttpHost getHopTarget(int hop)
          Obtains the target of a hop in this route.
 java.net.InetAddress getLocalAddress()
          Obtains the local address to connect from.
 org.apache.http.HttpHost getProxyHost()
          Obtains the first proxy host.
 org.apache.http.HttpHost getTargetHost()
          Obtains the target host.
 int hashCode()
          Generates a hash code for this tracked route.
 boolean isConnected()
          Checks whether this route is connected to it's first hop.
 boolean isLayered()
          Checks whether this route includes a layered protocol.
 boolean isSecure()
          Checks whether this route is secure.
 boolean isTunnelled()
          Checks whether this route is tunnelled through a proxy.
 void layerProtocol(boolean secure)
          Tracks layering a protocol.
 HostConfiguration toHostConfig()
          Deprecated. use toRoute instead. Kept temporarily until HttpRoute takes over from HostConfiguration.
 HttpRoute toRoute()
          Obtains the tracked route.
 java.lang.String toString()
          Obtains a description of the tracked route.
 void tunnelProxy(org.apache.http.HttpHost proxy, boolean secure)
          Tracks tunnelling to a proxy in a proxy chain.
 void tunnelTarget(boolean secure)
          Tracks tunnelling to the target.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RouteTracker

public RouteTracker(org.apache.http.HttpHost target,
                    java.net.InetAddress local)
Creates a new route tracker. The target and origin need to be specified at creation time.

Parameters:
target - the host to which to route
local - the local address to route from, or null for the default

RouteTracker

public RouteTracker(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 - the route to track
Method Detail

connectTarget

public final void connectTarget(boolean secure)
Tracks connecting to the target.

Parameters:
secure - true if the route is secure, false otherwise

connectProxy

public final void connectProxy(org.apache.http.HttpHost proxy,
                               boolean secure)
Tracks connecting to the first proxy.

Parameters:
proxy - the proxy connected to
secure - true if the route is secure, false otherwise

tunnelTarget

public final void tunnelTarget(boolean secure)
Tracks tunnelling to the target.

Parameters:
secure - true if the route is secure, false otherwise

tunnelProxy

public final void tunnelProxy(org.apache.http.HttpHost proxy,
                              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 - the proxy tunnelled to
secure - true if the route is secure, false otherwise

layerProtocol

public final void layerProtocol(boolean secure)
Tracks layering a protocol.

Parameters:
secure - true if the route is secure, false otherwise

getTargetHost

public final org.apache.http.HttpHost getTargetHost()
Obtains the target host.

Returns:
the target host

getLocalAddress

public final java.net.InetAddress getLocalAddress()
Obtains the local address to connect from.

Returns:
the local address, or null

getHopCount

public final int getHopCount()
Obtains the number of tracked hops. An unconnected route has no hops. Connecting directly to the target adds one hop. Connecting to a proxy adds two hops, one for the proxy and one for the target. Tunnelling to a proxy in a proxy chain adds one hop.

Returns:
the number of hops in the tracked route

getHopTarget

public final org.apache.http.HttpHost getHopTarget(int hop)
Obtains the target of a hop in this route.

Parameters:
hop - index of the hop for which to get the target, 0 for first
Returns:
the target of the given hop
Throws:
java.lang.IllegalArgumentException - if the argument is negative or not less than getHopCount()

getProxyHost

public final org.apache.http.HttpHost getProxyHost()
Obtains the first proxy host.

Returns:
the first proxy host, or null if not tracked

isConnected

public final boolean isConnected()
Checks whether this route is connected to it's first hop.

Returns:
true if connected, false otherwise

isTunnelled

public final boolean isTunnelled()
Checks whether this route is tunnelled through a proxy.

Returns:
true if tunnelled, false otherwise

isLayered

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

Returns:
true if layered, false otherwise

isSecure

public final boolean isSecure()
Checks whether this route is secure.

Returns:
true if secure, false otherwise

toRoute

public final 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:
the tracked route, or null if nothing has been tracked so far

toHostConfig

public final HostConfiguration toHostConfig()
Deprecated. use toRoute instead. Kept temporarily until HttpRoute takes over from HostConfiguration.

Obtains the tracked route.
Note: Currently, HostConfiguration is used to represent the route. It does not cover all tracked attributes. In particular, it can not represent intermediate steps in establishing a route.

Returns:
a representation of the route tracked so far

equals

public final boolean equals(java.lang.Object o)
Compares this tracked route to another.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare with
Returns:
true if the argument is the same tracked route, false

hashCode

public final int 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.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code

toString

public final java.lang.String toString()
Obtains a description of the tracked route.

Overrides:
toString in class java.lang.Object
Returns:
a human-readable representation of the tracked route

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.