hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rola...@apache.org
Subject svn commit: r620254 - in /httpcomponents/httpclient/trunk: ./ module-client/src/main/java/org/apache/http/conn/routing/ module-client/src/test/java/org/apache/http/conn/routing/
Date Sun, 10 Feb 2008 10:18:50 GMT
Author: rolandw
Date: Sun Feb 10 02:18:48 2008
New Revision: 620254

URL: http://svn.apache.org/viewvc?rev=620254&view=rev
Log:
HTTPCLIENT-742: common interface for HttpRoute and RouteTracker

Added:
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java
  (with props)
Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteTracker.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java
    httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=620254&r1=620253&r2=620254&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Sun Feb 10 02:18:48 2008
@@ -1,6 +1,9 @@
 Changes since 4.0 Alpha 2
 -------------------
 
+* [HTTPCLIENT-742] common interface for HttpRoute and RouteTracker
+  Contributed by Roland Weber <rolandw at apache.org>
+
 * [HTTPCLIENT-741] Fixed concurrency issues in AbstractClientConnAdapter.
   Contributed by Oleg Kalnichevski <olegk at apache.org>
 

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java?rev=620254&r1=620253&r2=620254&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java
Sun Feb 10 02:18:48 2008
@@ -48,33 +48,7 @@
  *
  * @since 4.0
  */
-public final class HttpRoute implements Cloneable {
-
-    /**
-     * The tunnelling type of a route.
-     * Plain routes are established by connecting to the target or
-     * the first proxy.
-     * Tunnelled routes are established by connecting to the first proxy
-     * and tunnelling through all proxies to the target.
-     * Routes without a proxy cannot be tunnelled.
-     */
-    public enum TunnelType { PLAIN, TUNNELLED };
-
-    /**
-     * The layering type of a route.
-     * Plain routes are established by connecting or tunnelling.
-     * Layered routes are established by layering a protocol such as TLS/SSL
-     * over an existing connection.
-     * Protocols can only be layered over a tunnel to the target, or
-     * or over a direct connection without proxies.
-     * <br/>
-     * Layering a protocol
-     * over a direct connection makes little sense, since the connection
-     * could be established with the new protocol in the first place.
-     * But we don't want to exclude that use case.
-     */
-    public enum LayerType  { PLAIN, LAYERED };
-
+public final class HttpRoute implements RouteInfo, Cloneable {
 
     /** The target host to connect to. */
     private final HttpHost targetHost;
@@ -279,55 +253,26 @@
     }
 
 
-    /**
-     * Obtains the target host.
-     * 
-     * @return the target host
-     */
+
+    // non-JavaDoc, see interface RouteInfo
     public final HttpHost getTargetHost() {
         return this.targetHost;
     }
 
 
-    /**
-     * Obtains the local address to connect from.
-     * 
-     * @return  the local address,
-     *          or <code>null</code>
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final InetAddress getLocalAddress() {
         return this.localAddress;
     }
 
 
-    /**
-     * 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 <i>n</i> proxies has <i>n+1</i>
hops.
-     *
-     * @return  the number of hops in this route
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final int getHopCount() {
         return (proxyChain == null) ? 1 : (proxyChain.length+1);
     }
 
 
-    /**
-     * Obtains the target of a hop in this route.
-     * The target of the last hop is the {@link #getTargetHost 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.
-     *
-     * @param hop       index of the hop for which to get the target,
-     *                  0 for first
-     *
-     * @return  the target of the given hop
-     *
-     * @throws IllegalArgumentException
-     *  if the argument is negative or not less than
-     *  {@link #getHopCount getHopCount()}
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final HttpHost getHopTarget(int hop) {
         if (hop < 0)
             throw new IllegalArgumentException
@@ -348,72 +293,37 @@
     }
 
 
-    /**
-     * Obtains the first proxy host.
-     * 
-     * @return the first proxy in the proxy chain, or
-     *         <code>null</code> if this route is direct
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final HttpHost getProxyHost() {
         return (this.proxyChain == null) ? null : this.proxyChain[0];
     }
 
 
-    /**
-     * Obtains the tunnel type of this route.
-     * If there is a proxy chain, only end-to-end tunnels are considered.
-     *
-     * @return  the tunnelling type
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final TunnelType getTunnelType() {
         return this.tunnelled;
     }
 
 
-    /**
-     * Checks whether this route is tunnelled through a proxy.
-     * If there is a proxy chain, only end-to-end tunnels are considered.
-     *
-     * @return  <code>true</code> if tunnelled end-to-end through at least
-     *          one proxy,
-     *          <code>false</code> otherwise
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final boolean isTunnelled() {
         return (this.tunnelled == TunnelType.TUNNELLED);
     }
 
 
-    /**
-     * Obtains the layering type of this route.
-     * In the presence of proxies, only layering over an end-to-end tunnel
-     * is considered.
-     *
-     * @return  the layering type
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final LayerType getLayerType() {
         return this.layered;
     }
 
 
-    /**
-     * Checks whether this route includes a layered protocol.
-     * In the presence of proxies, only layering over an end-to-end tunnel
-     * is considered.
-     *
-     * @return  <code>true</code> if layered,
-     *          <code>false</code> otherwise
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final boolean isLayered() {
         return (this.layered == LayerType.LAYERED);
     }
 
 
-    /**
-     * Checks whether this route is secure.
-     *
-     * @return  <code>true</code> if secure,
-     *          <code>false</code> otherwise
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final boolean isSecure() {
         return this.secure;
     }

Added: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java?rev=620254&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java
(added)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java
Sun Feb 10 02:18:48 2008
@@ -0,0 +1,194 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.conn.routing;
+
+import java.net.InetAddress;
+
+import org.apache.http.HttpHost;
+
+
+/**
+ * Read-only interface for route information.
+ * 
+ * @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
+ *
+ *
+ * <!-- empty lines to avoid svn diff problems -->
+ * @version $Revision$
+ *
+ * @since 4.0
+ */
+public interface RouteInfo {
+
+    /**
+     * The tunnelling type of a route.
+     * Plain routes are established by connecting to the target or
+     * the first proxy.
+     * Tunnelled routes are established by connecting to the first proxy
+     * and tunnelling through all proxies to the target.
+     * Routes without a proxy cannot be tunnelled.
+     */
+    public enum TunnelType { PLAIN, TUNNELLED };
+
+    /**
+     * The layering type of a route.
+     * Plain routes are established by connecting or tunnelling.
+     * Layered routes are established by layering a protocol such as TLS/SSL
+     * over an existing connection.
+     * Protocols can only be layered over a tunnel to the target, or
+     * or over a direct connection without proxies.
+     * <br/>
+     * Layering a protocol
+     * over a direct connection makes little sense, since the connection
+     * could be established with the new protocol in the first place.
+     * But we don't want to exclude that use case.
+     */
+    public enum LayerType  { PLAIN, LAYERED };
+
+
+
+    /**
+     * Obtains the target host.
+     * 
+     * @return the target host
+     */
+    HttpHost getTargetHost()
+        ;
+
+
+    /**
+     * Obtains the local address to connect from.
+     * 
+     * @return  the local address,
+     *          or <code>null</code>
+     */
+    InetAddress getLocalAddress()
+        ;
+
+
+    /**
+     * 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 <i>n</i> proxies has <i>n+1</i>
hops.
+     *
+     * @return  the number of hops in this route
+     */
+    int getHopCount()
+        ;
+
+
+    /**
+     * Obtains the target of a hop in this route.
+     * The target of the last hop is the {@link #getTargetHost 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.
+     *
+     * @param hop       index of the hop for which to get the target,
+     *                  0 for first
+     *
+     * @return  the target of the given hop
+     *
+     * @throws IllegalArgumentException
+     *  if the argument is negative or not less than
+     *  {@link #getHopCount getHopCount()}
+     */
+    HttpHost getHopTarget(int hop)
+        ;
+
+
+    /**
+     * Obtains the first proxy host.
+     * 
+     * @return the first proxy in the proxy chain, or
+     *         <code>null</code> if this route is direct
+     */
+    HttpHost getProxyHost()
+        ;
+
+
+    /**
+     * Obtains the tunnel type of this route.
+     * If there is a proxy chain, only end-to-end tunnels are considered.
+     *
+     * @return  the tunnelling type
+     */
+    TunnelType getTunnelType()
+        ;
+
+
+    /**
+     * Checks whether this route is tunnelled through a proxy.
+     * If there is a proxy chain, only end-to-end tunnels are considered.
+     *
+     * @return  <code>true</code> if tunnelled end-to-end through at least
+     *          one proxy,
+     *          <code>false</code> otherwise
+     */
+    boolean isTunnelled()
+        ;
+
+
+    /**
+     * Obtains the layering type of this route.
+     * In the presence of proxies, only layering over an end-to-end tunnel
+     * is considered.
+     *
+     * @return  the layering type
+     */
+    LayerType getLayerType()
+        ;
+
+
+    /**
+     * Checks whether this route includes a layered protocol.
+     * In the presence of proxies, only layering over an end-to-end tunnel
+     * is considered.
+     *
+     * @return  <code>true</code> if layered,
+     *          <code>false</code> otherwise
+     */
+    boolean isLayered()
+        ;
+
+
+    /**
+     * Checks whether this route is secure.
+     *
+     * @return  <code>true</code> if secure,
+     *          <code>false</code> otherwise
+     */
+    boolean isSecure()
+        ;
+
+
+} // interface RouteInfo

Propchange: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteTracker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteTracker.java?rev=620254&r1=620253&r2=620254&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteTracker.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteTracker.java
Sun Feb 10 02:18:48 2008
@@ -34,8 +34,6 @@
 import java.net.InetAddress;
 
 import org.apache.http.HttpHost;
-import org.apache.http.conn.routing.HttpRoute.TunnelType;
-import org.apache.http.conn.routing.HttpRoute.LayerType;
 
 
 /**
@@ -49,7 +47,7 @@
  *
  * @since 4.0
  */
-public final class RouteTracker implements Cloneable {
+public final class RouteTracker implements RouteInfo, Cloneable {
 
     /** The target host to connect to. */
     private final HttpHost targetHost;
@@ -212,37 +210,20 @@
     }
 
 
-    /**
-     * Obtains the target host.
-     * 
-     * @return the target host
-     */
+
+    // non-JavaDoc, see interface RouteInfo
     public final HttpHost getTargetHost() {
         return this.targetHost;
     }
 
 
-    /**
-     * Obtains the local address to connect from.
-     * 
-     * @return  the local address,
-     *          or <code>null</code>
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final InetAddress getLocalAddress() {
         return this.localAddress;
     }
 
 
-    /**
-     * 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.
-     *
-     * @return  the number of hops in the tracked route
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final int getHopCount() {
         int hops = 0;
         if (this.connected) {
@@ -255,18 +236,7 @@
     }
 
 
-    /**
-     * Obtains the target of a hop in this route.
-     *
-     * @param hop       index of the hop for which to get the target,
-     *                  0 for first
-     *
-     * @return  the target of the given hop
-     *
-     * @throws IllegalArgumentException
-     *  if the argument is negative or not less than
-     *  {@link #getHopCount getHopCount()}
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final HttpHost getHopTarget(int hop) {
         if (hop < 0)
             throw new IllegalArgumentException
@@ -288,82 +258,43 @@
     }
 
 
-    /**
-     * Obtains the first proxy host.
-     * 
-     * @return the first proxy host, or <code>null</code> if not tracked
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final HttpHost getProxyHost() {
         return (this.proxyChain == null) ? null : this.proxyChain[0];
     }
 
 
-    /**
-     * Checks whether this route is connected to it's first hop.
-     *
-     * @return  <code>true</code> if connected,
-     *          <code>false</code> otherwise
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final boolean isConnected() {
         return this.connected;
     }
 
 
-    /**
-     * Obtains the tunnel type of this route.
-     * If there is a proxy chain, only end-to-end tunnels are considered.
-     *
-     * @return  the tunnelling type
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final TunnelType getTunnelType() {
         return this.tunnelled;
     }
 
 
-    /**
-     * Checks whether this route is tunnelled through a proxy.
-     * If there is a proxy chain, only end-to-end tunnels are considered.
-     *
-     * @return  <code>true</code> if tunnelled end-to-end through at least
-     *          one proxy,
-     *          <code>false</code> otherwise
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final boolean isTunnelled() {
         return (this.tunnelled == TunnelType.TUNNELLED);
     }
 
 
-    /**
-     * Obtains the layering type of this route.
-     * In the presence of proxies, only layering over an end-to-end tunnel
-     * is considered.
-     *
-     * @return  the layering type
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final LayerType getLayerType() {
         return this.layered;
     }
 
 
-    /**
-     * Checks whether this route includes a layered protocol.
-     * In the presence of proxies, only layering over an end-to-end tunnel
-     * is considered.
-     *
-     * @return  <code>true</code> if layered,
-     *          <code>false</code> otherwise
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final boolean isLayered() {
         return (this.layered == LayerType.LAYERED);
     }
 
 
-    /**
-     * Checks whether this route is secure.
-     *
-     * @return  <code>true</code> if secure,
-     *          <code>false</code> otherwise
-     */
+    // non-JavaDoc, see interface RouteInfo
     public final boolean isSecure() {
         return this.secure;
     }

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java?rev=620254&r1=620253&r2=620254&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java
Sun Feb 10 02:18:48 2008
@@ -41,8 +41,8 @@
 import junit.framework.TestSuite;
 
 import org.apache.http.HttpHost;
-import org.apache.http.conn.routing.HttpRoute.TunnelType;
-import org.apache.http.conn.routing.HttpRoute.LayerType;
+import org.apache.http.conn.routing.RouteInfo.TunnelType;
+import org.apache.http.conn.routing.RouteInfo.LayerType;
 
 
 /**

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java?rev=620254&r1=620253&r2=620254&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java
Sun Feb 10 02:18:48 2008
@@ -38,8 +38,8 @@
 import junit.framework.TestSuite;
 
 import org.apache.http.HttpHost;
-import org.apache.http.conn.routing.HttpRoute.TunnelType;
-import org.apache.http.conn.routing.HttpRoute.LayerType;
+import org.apache.http.conn.routing.RouteInfo.TunnelType;
+import org.apache.http.conn.routing.RouteInfo.LayerType;
 
 
 /**

Modified: httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java?rev=620254&r1=620253&r2=620254&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java
Sun Feb 10 02:18:48 2008
@@ -40,8 +40,8 @@
 import junit.framework.TestSuite;
 
 import org.apache.http.HttpHost;
-import org.apache.http.conn.routing.HttpRoute.TunnelType;
-import org.apache.http.conn.routing.HttpRoute.LayerType;
+import org.apache.http.conn.routing.RouteInfo.TunnelType;
+import org.apache.http.conn.routing.RouteInfo.LayerType;
 
 
 /**



Mime
View raw message