hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r542224 - in /jakarta/httpcomponents/httpcore/trunk: contrib/src/main/java/org/apache/http/contrib/benchmark/ module-main/src/examples/org/apache/http/examples/ module-main/src/main/java/org/apache/http/params/ module-main/src/main/java/org...
Date Mon, 28 May 2007 13:34:05 GMT
Author: olegk
Date: Mon May 28 06:34:04 2007
New Revision: 542224

URL: http://svn.apache.org/viewvc?view=rev&rev=542224
Log:
params refactoring, step 6 - Moved param hierarchy building methods to an optional interface
extending HttpParams

Added:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpLinkedParams.java
      - copied, changed from r541969, jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParamsLinker.java
  (with props)
Modified:
    jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/mockup/TestHttpClient.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java

Modified: jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java
Mon May 28 06:34:04 2007
@@ -30,20 +30,38 @@
  */
 package org.apache.http.contrib.benchmark;
 
-import org.apache.http.*;
-import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.DefaultHttpClientConnection;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.*;
-import org.apache.http.util.EntityUtils;
-
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.SocketFactory;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.Socket;
 import java.util.Iterator;
 
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpClientConnection;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
+import org.apache.http.protocol.BasicHttpProcessor;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpExecutionContext;
+import org.apache.http.protocol.HttpRequestExecutor;
+import org.apache.http.protocol.RequestConnControl;
+import org.apache.http.protocol.RequestContent;
+import org.apache.http.protocol.RequestExpectContinue;
+import org.apache.http.protocol.RequestTargetHost;
+import org.apache.http.protocol.RequestUserAgent;
+import org.apache.http.util.EntityUtils;
+
 /**
  * Worker thread for the {@link HttpBenchmark HttpBenchmark}.
  *
@@ -86,7 +104,7 @@
         this.keepalive = keepalive;
 
         this.httpProcessor = new BasicHttpProcessor();
-        this.httpexecutor = new HttpRequestExecutor(params);
+        this.httpexecutor = new HttpRequestExecutor();
 
         // Required request interceptors
         this.httpProcessor.addInterceptor(new RequestContent());
@@ -117,8 +135,8 @@
         this.context.setAttribute(HttpExecutionContext.HTTP_REQUEST, this.request);
 
         stats.start();
-
-        for (int i=0; i < count; i++) {
+        HttpParamsLinker.link(this.request, this.params);
+        for (int i = 0; i < count; i++) {
 
             try {
                 resetHeader(request);

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
Mon May 28 06:34:04 2007
@@ -82,7 +82,7 @@
         httpproc.addInterceptor(new RequestUserAgent());
         httpproc.addInterceptor(new RequestExpectContinue());
 
-        HttpRequestExecutor httpexecutor = new HttpRequestExecutor(params);
+        HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
         
         HttpContext context = new HttpExecutionContext(null);
         HttpHost host = new HttpHost("localhost", 8080);
@@ -109,7 +109,7 @@
                 System.out.println(">> Request URI: " + request.getRequestLine().getUri());
                 
                 context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
-                request.setParams(httpexecutor.getParams());
+                request.setParams(params);
                 httpexecutor.preProcess(request, httpproc, context);
                 HttpResponse response = httpexecutor.execute(request, conn, context);
                 httpexecutor.postProcess(response, httpproc, context);

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
Mon May 28 06:34:04 2007
@@ -87,7 +87,7 @@
         httpproc.addInterceptor(new RequestUserAgent());
         httpproc.addInterceptor(new RequestExpectContinue());
         
-        HttpRequestExecutor httpexecutor = new HttpRequestExecutor(params);
+        HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
 
         HttpContext context = new HttpExecutionContext(null);
         
@@ -123,7 +123,7 @@
                 System.out.println(">> Request URI: " + request.getRequestLine().getUri());
 
                 context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
-                request.setParams(httpexecutor.getParams());
+                request.setParams(params);
                 httpexecutor.preProcess(request, httpproc, context);
                 HttpResponse response = httpexecutor.execute(request, conn, context);
                 httpexecutor.postProcess(response, httpproc, context);

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java
Mon May 28 06:34:04 2007
@@ -47,60 +47,11 @@
 public abstract class AbstractHttpParams implements HttpParams {
 
     /**
-     * The optional set of default values to defer to.
-     * <br/>
-     * <b>WARNING:</b> Handling of default parameters is currently
-     * subject to discussions, and may be changed signifcantly.
-     */
-    protected HttpParams defaults;
-
-    /**
      * Instantiates parameters.
      */
     protected AbstractHttpParams() {
         super();
     }
-
-
-
-    /**
-     * Obtains default parameters, if set.
-     * <br/>
-     * <b>WARNING:</b> Handling of default parameters is currently
-     * subject to discussions, and may be changed signifcantly.
-     *
-     * @return  the defaults, or <code>null</code>
-     */
-    public synchronized HttpParams getDefaults() {
-        return this.defaults;
-    }
-    
-    /**
-     * Provides default parameters.
-     * <br/>
-     * <b>WARNING:</b> Handling of default parameters is currently
-     * subject to discussions, and may be changed signifcantly.
-     *
-     * @param params    the new defaults, or <code>null</code> to unset
-     */
-    public synchronized void setDefaults(final HttpParams params) {
-
-        // check we're not becoming our own defaults, directly or indirectly
-        // that would trigger an endless loop when looking up an unknown param
-        HttpParams ancestor = params;
-        while (ancestor != null) {
-            // check for object identity, not .equals
-            if (ancestor == this) {
-                throw new IllegalArgumentException
-                    ("cyclic default params detected");
-            }
-            ancestor = ancestor.getDefaults();
-        }
-
-        this.defaults = params;
-    }
-
-
 
     public long getLongParameter(final String name, long defaultValue) { 
         Object param = getParameter(name);

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java
Mon May 28 06:34:04 2007
@@ -44,19 +44,21 @@
  * If a particular parameter value has not been explicitly defined
  * in the collection itself, its value will be drawn from the parent 
  * collection of parameters.
- * <br/>
- * <b>WARNING:</b> Handling of default parameters is currently
- * subject to discussions, and may be changed signifcantly.
  * 
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * 
  * @version $Revision$
  */
 public class BasicHttpParams extends AbstractHttpParams
-    implements HttpParams, Serializable {
+    implements HttpLinkedParams, Serializable {
 
     static final long serialVersionUID = 4571099216197814749L;
 
+    /**
+     * The optional set of default values to defer to.
+     */
+    protected HttpParams defaults;
+
     /** Map of HTTP parameters that this collection contains. */
     private HashMap parameters;
 
@@ -74,10 +76,29 @@
         setDefaults(defaults); // perform ancestor check
     }
 
+    
     public BasicHttpParams() {
         this(null);
     }
 
+    /**
+     * Obtains default parameters, if set.
+     *
+     * @return  the defaults, or <code>null</code>
+     */
+    public synchronized HttpParams getDefaults() {
+        return this.defaults;
+    }
+    
+    /**
+     * Provides default parameters.
+     *
+     * @param params    the new defaults, or <code>null</code> to unset
+     */
+    public synchronized void setDefaults(final HttpParams params) {
+        this.defaults = params;
+    }
+
     public synchronized Object getParameter(final String name) {
         // See if the parameter has been explicitly defined
         Object param = null;
@@ -176,4 +197,5 @@
                 target.setParameter((String)me.getKey(), me.getValue());
         }
     }
+    
 }

Copied: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpLinkedParams.java
(from r541969, jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpLinkedParams.java?view=diff&rev=542224&p1=jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java&r1=541969&p2=jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpLinkedParams.java&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpLinkedParams.java
Mon May 28 06:34:04 2007
@@ -32,13 +32,12 @@
 package org.apache.http.params;
 
 /**
- * Represents a collection of HTTP protocol and framework parameters.
+ * Represents a collection of HTTP protocol and framework parameters
+ * that can be linked with another one to form a parameter hierarchy. 
  * <br/>
  * <b>WARNING:</b> This interface includes methods for building hierarchies of
- * parameters. These methods are clearly marked as <i>not part of the API</i>.
- * The handling of default parameters is currently subject to discussions and
- * may be changed signifcantly, or removed. Do not try to evaluate, build or
- * modify parameter hierarchies in your application.
+ * parameters. These methods are intended for internal use by the the HTTP Components
+ * framework. Use with caution.
  *   
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * 
@@ -46,13 +45,12 @@
  *
  * @since 4.0
  */
-public interface HttpParams {
+public interface HttpLinkedParams extends HttpParams {
 
     /**
      * <b>WARNING:</b> This method is not part of the API. 
-     * It is exclusively for internal use by the HTTP Components framework.
-     * Do not call it in your application. Do not try to evaluate, build or
-     * modify parameter hierarchies in your application.
+     * It is intended for internal use by the HTTP Components framework.
+     * Use with caution.
      * <br/>
      *
      * Returns the parent collection that the collection may defer to
@@ -66,9 +64,8 @@
 
     /** 
      * <b>WARNING:</b> This method is not part of the API. 
-     * It is exclusively for internal use by the HTTP Components framework.
-     * Do not call it in your application. Do not try to evaluate, build or
-     * modify parameter hierarchies in your application.
+     * It is intended for internal use by the HTTP Components framework.
+     * Use with caution.
      * <br/>
      *
      * Provides the parent collection that this collection may defer to
@@ -80,147 +77,10 @@
      */
     void setDefaults(HttpParams params);
     
-    /** 
-     * Returns a parameter value with the given name. If the parameter is
-     * not explicitly defined in this collection, its value will be drawn 
-     * from a higer level collection at which this parameter is defined.
-     * If the parameter is not explicitly set anywhere up the hierarchy,
-     * <tt>null</tt> value is returned.  
-     * 
-     * @param name the parent name.
-     * 
-     * @return an object that represents the value of the parameter.
-     * 
-     * @see #setParameter(String, Object)
-     */
-    Object getParameter(String name);
-
-    /**
-     * Assigns the value to the parameter with the given name
-     * 
-     * @param name parameter name
-     * @param value parameter value
-     */ 
-    HttpParams setParameter(String name, Object value);
-
-    /**
-     * Creates a copy of these parameters.
-     *
-     * @return  a new set of parameters holding the same values as this one
-     */
-    HttpParams copy();
-
-    /** 
-     * Returns a {@link Long} parameter value with the given name. 
-     * If the parameter is not explicitly defined in this collection, its 
-     * value will be drawn from a higer level collection at which this parameter 
-     * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
-     * the default value is returned.  
-     * 
-     * @param name the parent name.
-     * @param defaultValue the default value.
-     * 
-     * @return a {@link Long} that represents the value of the parameter.
-     * 
-     * @see #setLongParameter(String, long)
-     */
-    long getLongParameter(String name, long defaultValue); 
-    
-    /**
-     * Assigns a {@link Long} to the parameter with the given name
-     * 
-     * @param name parameter name
-     * @param value parameter value
-     */ 
-    HttpParams setLongParameter(String name, long value);
-
-    /** 
-     * Returns an {@link Integer} parameter value with the given name. 
-     * If the parameter is not explicitly defined in this collection, its 
-     * value will be drawn from a higer level collection at which this parameter 
-     * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
-     * the default value is returned.  
-     * 
-     * @param name the parent name.
-     * @param defaultValue the default value.
-     * 
-     * @return a {@link Integer} that represents the value of the parameter.
-     * 
-     * @see #setIntParameter(String, int)
-     */
-    int getIntParameter(String name, int defaultValue); 
-    
-    /**
-     * Assigns an {@link Integer} to the parameter with the given name
-     * 
-     * @param name parameter name
-     * @param value parameter value
-     */ 
-    HttpParams setIntParameter(String name, int value);
-
-    /** 
-     * Returns a {@link Double} parameter value with the given name. 
-     * If the parameter is not explicitly defined in this collection, its 
-     * value will be drawn from a higer level collection at which this parameter 
-     * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
-     * the default value is returned.  
-     * 
-     * @param name the parent name.
-     * @param defaultValue the default value.
-     * 
-     * @return a {@link Double} that represents the value of the parameter.
-     * 
-     * @see #setDoubleParameter(String, double)
-     */
-    double getDoubleParameter(String name, double defaultValue); 
-    
-    /**
-     * Assigns a {@link Double} to the parameter with the given name
-     * 
-     * @param name parameter name
-     * @param value parameter value
-     */ 
-    HttpParams setDoubleParameter(String name, double value);
-
-    /** 
-     * Returns a {@link Boolean} parameter value with the given name. 
-     * If the parameter is not explicitly defined in this collection, its 
-     * value will be drawn from a higer level collection at which this parameter 
-     * is defined. If the parameter is not explicitly set anywhere up the hierarchy,
-     * the default value is returned.  
-     * 
-     * @param name the parent name.
-     * @param defaultValue the default value.
-     * 
-     * @return a {@link Boolean} that represents the value of the parameter.
-     * 
-     * @see #setBooleanParameter(String, boolean)
-     */
-    boolean getBooleanParameter(String name, boolean defaultValue); 
-    
-    /**
-     * Assigns a {@link Boolean} to the parameter with the given name
-     * 
-     * @param name parameter name
-     * @param value parameter value
-     */ 
-    HttpParams setBooleanParameter(String name, boolean value);
-
-    /**
-     * Returns <tt>true</tt> if the parameter is set at any level, <tt>false</tt>
otherwise.
-     * 
-     * @param name parameter name
-     * 
-     * @return <tt>true</tt> if the parameter is set at any level, <tt>false</tt>
-     * otherwise.
-     */
-    boolean isParameterSet(String name);
-        
     /**
      * <b>WARNING:</b> This method is not part of the API. 
-     * It is exclusively for internal use by the HTTP Components framework.
-     * Do not call it in your application. Do not try to evaluate, build or
-     * modify parameter hierarchies in your application.
+     * It is intended for internal use by the HTTP Components framework.
+     * Use with caution.
      * <br/>
      * 
      * @param name      the parameter name
@@ -232,28 +92,5 @@
      * @see #setDefaults(HttpParams)
      */
     boolean isParameterSetLocally(String name);
-
-        
-    /**
-     * Returns <tt>true</tt> if the parameter is set and is <tt>true</tt>,
<tt>false</tt>
-     * otherwise.
-     * 
-     * @param name parameter name
-     * 
-     * @return <tt>true</tt> if the parameter is set and is <tt>true</tt>,
<tt>false</tt>
-     * otherwise.
-     */
-    boolean isParameterTrue(String name);
-        
-    /**
-     * Returns <tt>true</tt> if the parameter is either not set or is <tt>false</tt>,

-     * <tt>false</tt> otherwise.
-     * 
-     * @param name parameter name
-     * 
-     * @return <tt>true</tt> if the parameter is either not set or is <tt>false</tt>,

-     * <tt>false</tt> otherwise.
-     */
-    boolean isParameterFalse(String name);
-
+    
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java
Mon May 28 06:34:04 2007
@@ -33,12 +33,6 @@
 
 /**
  * Represents a collection of HTTP protocol and framework parameters.
- * <br/>
- * <b>WARNING:</b> This interface includes methods for building hierarchies of
- * parameters. These methods are clearly marked as <i>not part of the API</i>.
- * The handling of default parameters is currently subject to discussions and
- * may be changed signifcantly, or removed. Do not try to evaluate, build or
- * modify parameter hierarchies in your application.
  *   
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * 
@@ -48,38 +42,6 @@
  */
 public interface HttpParams {
 
-    /**
-     * <b>WARNING:</b> This method is not part of the API. 
-     * It is exclusively for internal use by the HTTP Components framework.
-     * Do not call it in your application. Do not try to evaluate, build or
-     * modify parameter hierarchies in your application.
-     * <br/>
-     *
-     * Returns the parent collection that the collection may defer to
-     * for a default value if a particular parameter is not explicitly set.
-     * 
-     * @return the parent collection, or <code>null</code>
-     * 
-     * @see #setDefaults(HttpParams)
-     */
-    HttpParams getDefaults();
-
-    /** 
-     * <b>WARNING:</b> This method is not part of the API. 
-     * It is exclusively for internal use by the HTTP Components framework.
-     * Do not call it in your application. Do not try to evaluate, build or
-     * modify parameter hierarchies in your application.
-     * <br/>
-     *
-     * Provides the parent collection that this collection may defer to
-     * for a default value if a particular parameter is not explicitly set.
-     * 
-     * @param params the parent collection, or <code>null</code>
-     * 
-     * @see #getDefaults()
-     */
-    void setDefaults(HttpParams params);
-    
     /** 
      * Returns a parameter value with the given name. If the parameter is
      * not explicitly defined in this collection, its value will be drawn 
@@ -215,24 +177,6 @@
      * otherwise.
      */
     boolean isParameterSet(String name);
-        
-    /**
-     * <b>WARNING:</b> This method is not part of the API. 
-     * It is exclusively for internal use by the HTTP Components framework.
-     * Do not call it in your application. Do not try to evaluate, build or
-     * modify parameter hierarchies in your application.
-     * <br/>
-     * 
-     * @param name      the parameter name
-     * 
-     * @return  <tt>true</tt> if the parameter is set locally,
-     *          <tt>false</tt> otherwise
-     *
-     * @see #getDefaults()
-     * @see #setDefaults(HttpParams)
-     */
-    boolean isParameterSetLocally(String name);
-
         
     /**
      * Returns <tt>true</tt> if the parameter is set and is <tt>true</tt>,
<tt>false</tt>

Added: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParamsLinker.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParamsLinker.java?view=auto&rev=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParamsLinker.java
(added)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParamsLinker.java
Mon May 28 06:34:04 2007
@@ -0,0 +1,65 @@
+/*
+ * $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.params;
+
+import org.apache.http.HttpMessage;
+import org.apache.http.params.HttpParams;
+
+/**
+ * A utility class that can be used to build parameter hierarchies.
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ * 
+ * @version $Revision$
+ */
+public class HttpParamsLinker {
+
+    private HttpParamsLinker() {
+    }
+    
+    /**
+     * Builds parameter hierarchy by linking parameters associated with 
+     * the given HTTP message and the given defaults. 
+     * 
+     * @param message HTTP message
+     * @param defaults default HTTP parameters
+     */
+    public static void link(final HttpMessage message, final HttpParams defaults) {
+        if (message == null) {
+            throw new IllegalArgumentException("HTTP message may not be null");
+        }
+        if (message.getParams() instanceof HttpLinkedParams) {
+            ((HttpLinkedParams) message.getParams()).setDefaults(defaults);
+        }
+    }
+    
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParamsLinker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParamsLinker.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParamsLinker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpRequestExecutor.java
Mon May 28 06:34:04 2007
@@ -41,7 +41,6 @@
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
-import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
 
 /**
@@ -57,23 +56,11 @@
  */
 public class HttpRequestExecutor {
 
-    private final HttpParams params;
-
     /**
      * Create a new request executor.
      */
-    public HttpRequestExecutor(final HttpParams params) {
+    public HttpRequestExecutor() {
         super();
-        this.params = params;
-    }
-
-    /**
-     * Obtain the parameters for executing requests.
-     *
-     * @return  the currently installed parameters
-     */
-    public final HttpParams getParams() {
-        return this.params;
     }
 
     /**
@@ -223,7 +210,8 @@
                 conn.flush();
                 // As suggested by RFC 2616 section 8.2.3, we don't wait for a
                 // 100-continue response forever. On timeout, send the entity.
-                int tms = params.getIntParameter(HttpProtocolParams.WAIT_FOR_CONTINUE, 2000);
+                int tms = request.getParams().getIntParameter(
+                        HttpProtocolParams.WAIT_FOR_CONTINUE, 2000);
                 
                 if (conn.isResponseAvailable(tms)) {
                     response = conn.receiveResponseHeader();

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/protocol/HttpService.java
Mon May 28 06:34:04 2007
@@ -48,6 +48,7 @@
 import org.apache.http.UnsupportedHttpVersionException;
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
 import org.apache.http.util.EncodingUtils;
 
 /**
@@ -131,7 +132,8 @@
         try {
 
             HttpRequest request = conn.receiveRequestHeader();
-            request.getParams().setDefaults(this.params);
+            HttpParamsLinker.link(request, this.params);
+            
             HttpVersion ver = request.getRequestLine().getHttpVersion();
             if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
                 // Downgrade protocol version if greater than HTTP/1.1 
@@ -146,7 +148,7 @@
                 if (((HttpEntityEnclosingRequest) request).expectContinue()) {
                     response = this.responseFactory.newHttpResponse(ver, 
                             HttpStatus.SC_CONTINUE, context);
-                    response.getParams().setDefaults(this.params);
+                    HttpParamsLinker.link(request, this.params);
                     
                     if (this.expectationVerifier != null) {
                         try {
@@ -154,7 +156,7 @@
                         } catch (HttpException ex) {
                             response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0,

                                     HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
-                            response.getParams().setDefaults(this.params);
+                            HttpParamsLinker.link(request, this.params);
                             handleException(ex, response);
                         }
                     }
@@ -178,7 +180,7 @@
 
             if (response == null) {
                 response = this.responseFactory.newHttpResponse(ver, HttpStatus.SC_OK, context);
-                response.getParams().setDefaults(this.params);
+                HttpParamsLinker.link(request, this.params);
             }
             
             if (runService) {
@@ -201,7 +203,7 @@
             response = this.responseFactory.newHttpResponse
                 (HttpVersion.HTTP_1_0, HttpStatus.SC_INTERNAL_SERVER_ERROR,
                  context);
-            response.getParams().setDefaults(this.params);
+            HttpParamsLinker.link(response, this.params);
             handleException(ex, response);
         }
         

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/mockup/TestHttpClient.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/mockup/TestHttpClient.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/mockup/TestHttpClient.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/mockup/TestHttpClient.java
Mon May 28 06:34:04 2007
@@ -44,6 +44,7 @@
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.BasicHttpProcessor;
 import org.apache.http.protocol.HttpContext;
@@ -81,7 +82,7 @@
         this.httpproc.addInterceptor(new RequestUserAgent());
         this.httpproc.addInterceptor(new RequestExpectContinue());
 
-        this.httpexecutor = new HttpRequestExecutor(this.params);
+        this.httpexecutor = new HttpRequestExecutor();
         this.connStrategy = new DefaultConnectionReuseStrategy();
         this.context = new HttpExecutionContext(null);
     }
@@ -97,9 +98,10 @@
         this.context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
         this.context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, targetHost);
         this.context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
-        request.getParams().setDefaults(httpexecutor.getParams());
+        HttpParamsLinker.link(request, params);
         this.httpexecutor.preProcess(request, this.httpproc, this.context);
         HttpResponse response = this.httpexecutor.execute(request, conn, this.context);
+        HttpParamsLinker.link(response, params);
         this.httpexecutor.postProcess(response, this.httpproc, this.context);
         return response;
     }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
Mon May 28 06:34:04 2007
@@ -56,6 +56,7 @@
 import org.apache.http.nio.util.SimpleInputBuffer;
 import org.apache.http.nio.util.SimpleOutputBuffer;
 import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpExecutionContext;
@@ -253,6 +254,8 @@
         ClientConnState connState = (ClientConnState) context.getAttribute(CONN_STATE);
 
         HttpResponse response = conn.getHttpResponse();
+        HttpParamsLinker.link(response, this.params);
+        
         HttpRequest request = connState.getRequest();
         
         try {
@@ -337,7 +340,7 @@
             return;
         }
         
-        request.getParams().setDefaults(this.params);
+        HttpParamsLinker.link(request, this.params);
         
         context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
         this.httpProcessor.process(request, context);

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java
Mon May 28 06:34:04 2007
@@ -59,6 +59,7 @@
 import org.apache.http.nio.util.SimpleInputBuffer;
 import org.apache.http.nio.util.SimpleOutputBuffer;
 import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpExecutionContext;
 import org.apache.http.protocol.HttpExpectationVerifier;
@@ -142,7 +143,9 @@
 
     public void requestReceived(final NHttpServerConnection conn) {
         HttpContext context = conn.getContext();
+        
         HttpRequest request = conn.getHttpRequest();
+        HttpParamsLinker.link(request, this.params);
 
         ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
 
@@ -165,7 +168,7 @@
                 if (((HttpEntityEnclosingRequest) request).expectContinue()) {
                     response = this.responseFactory.newHttpResponse(
                             ver, HttpStatus.SC_CONTINUE, context);
-                    response.getParams().setDefaults(this.params);
+                    HttpParamsLinker.link(response, this.params);
                     
                     if (this.expectationVerifier != null) {
                         try {
@@ -175,7 +178,7 @@
                                     HttpVersion.HTTP_1_0, 
                                     HttpStatus.SC_INTERNAL_SERVER_ERROR, 
                                     context);
-                            response.getParams().setDefaults(this.params);
+                            HttpParamsLinker.link(response, this.params);
                             handleException(ex, response);
                         }
                     }
@@ -225,7 +228,7 @@
         try {
             HttpResponse response = this.responseFactory.newHttpResponse(
                     HttpVersion.HTTP_1_0, HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
-            response.getParams().setDefaults(this.params);
+            HttpParamsLinker.link(response, this.params);
             handleException(httpex, response);
             sendResponse(conn, response);
             
@@ -367,8 +370,11 @@
             ver = HttpVersion.HTTP_1_1;
         }
 
-        HttpResponse response = this.responseFactory.newHttpResponse(ver, HttpStatus.SC_OK,
conn.getContext());
-        response.getParams().setDefaults(this.params);
+        HttpResponse response = this.responseFactory.newHttpResponse(
+                ver, 
+                HttpStatus.SC_OK, 
+                conn.getContext());
+        HttpParamsLinker.link(response, this.params);
         
         context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
         context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
@@ -392,7 +398,7 @@
         } catch (HttpException ex) {
             response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0, 
                     HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
-            response.getParams().setDefaults(this.params);
+            HttpParamsLinker.link(response, this.params);
             handleException(ex, response);
         }
 

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java?view=diff&rev=542224&r1=542223&r2=542224
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
Mon May 28 06:34:04 2007
@@ -62,6 +62,7 @@
 import org.apache.http.nio.util.SharedInputBuffer;
 import org.apache.http.nio.util.SharedOutputBuffer;
 import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpExecutionContext;
 import org.apache.http.protocol.HttpExpectationVerifier;
@@ -220,7 +221,9 @@
 
     public void requestReceived(final NHttpServerConnection conn) {
         HttpContext context = conn.getContext();
+        
         HttpRequest request = conn.getHttpRequest();
+        HttpParamsLinker.link(request, this.params);
 
         final ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
 
@@ -444,7 +447,7 @@
                         ver, 
                         HttpStatus.SC_CONTINUE, 
                         context);
-                response.getParams().setDefaults(this.params);
+                HttpParamsLinker.link(response, this.params);
                 if (this.expectationVerifier != null) {
                     try {
                         this.expectationVerifier.verify(request, response, context);
@@ -484,7 +487,7 @@
                 ver, 
                 HttpStatus.SC_OK, 
                 context);
-        response.getParams().setDefaults(this.params);
+        HttpParamsLinker.link(response, this.params);
 
         context.setAttribute(HttpExecutionContext.HTTP_RESPONSE, response);
         



Mime
View raw message