hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r370456 - in /jakarta/httpcomponents/trunk/http-core/src: contrib/org/apache/http/contrib/spring/ java/org/apache/http/protocol/
Date Thu, 19 Jan 2006 10:39:22 GMT
Author: olegk
Date: Thu Jan 19 02:39:03 2006
New Revision: 370456

URL: http://svn.apache.org/viewcvs?rev=370456&view=rev
Log:
Updated Spring bean definitions in the contrib package

Modified:
    jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java
  (contents, props changed)
    jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/http-beans.xml
  (contents, props changed)
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java

Modified: jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java?rev=370456&r1=370455&r2=370456&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java
Thu Jan 19 02:39:03 2006
@@ -28,6 +28,7 @@
  */
 package org.apache.http.contrib.spring;
 
+import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpClientConnection;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpMutableRequest;
@@ -51,23 +52,23 @@
         
         // Set global params if desired
         HttpParams globalparams = (HttpParams) beanfactory.getBean("global-params");
+        globalparams
+            .setParameter(HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1)
+            .setParameter(HttpProtocolParams.HTTP_CONTENT_CHARSET, "UTF-8")
+            .setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, true)
+            .setParameter(HttpProtocolParams.USER_AGENT, "Jakarta-HttpComponents/1.1");
         
         HttpParams params = (HttpParams) beanfactory.getBean("params");
-        params.setDefaults(globalparams);
-        
-        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
-        HttpProtocolParams.setContentCharset(params, "UTF-8");
-        HttpProtocolParams.setUseExpectContinue(params, true);
-        HttpProtocolParams.setUserAgent(params, "Jakarta HTTP Demo");
         
         HttpRequestExecutor httpexec = (HttpRequestExecutor)beanfactory.getBean("http-executor");
         httpexec.setParams(params);
         
-        Scheme http = (Scheme) beanfactory.getBean("http-protocol");
+        Scheme http = (Scheme) beanfactory.getBean("http-scheme");
         HttpHost host = new HttpHost("www.yahoo.com", 80, http);
 
         HttpRequestFactory requestfactory = (HttpRequestFactory) beanfactory.getBean("http-request-factory");
         HttpClientConnection conn = (HttpClientConnection) beanfactory.getBean("http-connection");
+        ConnectionReuseStrategy connStrategy = (ConnectionReuseStrategy) beanfactory.getBean("conn-reuse-strategy");
         conn.setTargetHost(host);
         try {
             HttpMutableRequest request1 = requestfactory.newHttpRequest("GET", "/");
@@ -75,14 +76,23 @@
             System.out.println("<< Response: " + response1.getStatusLine());
             System.out.println(EntityUtils.toString(response1.getEntity()));
             System.out.println("==============");
-            if (conn.isOpen()) {
+            if (connStrategy.keepAlive(response1)) {
                 System.out.println("Connection kept alive...");
+            } else {
+                conn.close();
+                System.out.println("Connection closed...");
             }
             HttpMutableRequest request2 = requestfactory.newHttpRequest("GET", "/stuff");
             HttpResponse response2 = httpexec.execute(request2, conn);
             System.out.println("<< Response: " + response2.getStatusLine());
             System.out.println(EntityUtils.toString(response2.getEntity()));
             System.out.println("==============");
+            if (connStrategy.keepAlive(response2)) {
+                System.out.println("Connection kept alive...");
+            } else {
+                conn.close();
+                System.out.println("Connection closed...");
+            }
         } finally {
             conn.close();
         }

Propchange: jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/SpringHttpDemo.java
            ('svn:executable' removed)

Modified: jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/http-beans.xml
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/http-beans.xml?rev=370456&r1=370455&r2=370456&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/http-beans.xml
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/http-beans.xml
Thu Jan 19 02:39:03 2006
@@ -14,11 +14,11 @@
   </bean>
 
   <bean id="socket-factory" 
-    class="org.apache.http.impl.io.NIOSocketFactory" 
+    class="org.apache.http.impl.io.PlainSocketFactory" 
     singleton="true" />
     
-  <bean id="http-protocol" 
-    class="org.apache.http.Protocol">
+  <bean id="http-scheme" 
+    class="org.apache.http.Scheme">
     <constructor-arg index="0"><value>http</value></constructor-arg>
     <constructor-arg index="1"><ref bean="socket-factory"/></constructor-arg>
     <constructor-arg index="2"><value>80</value></constructor-arg>
@@ -31,44 +31,48 @@
   </bean>
   
   <bean id="http-executor" 
-    class="org.apache.http.executor.HttpRequestExecutor" 
+    class="org.apache.http.protocol.HttpRequestExecutor" 
     singleton="true" >
     <property name="interceptors">
-      <set>
+      <list>
         <!-- Required request interceptors -->
-        <bean class="org.apache.http.interceptor.RequestContent" />
-        <bean class="org.apache.http.interceptor.RequestTargetHost" />
+        <bean class="org.apache.http.protocol.RequestContent" />
+        <bean class="org.apache.http.protocol.RequestTargetHost" />
         <!-- Recommended request interceptors -->
-        <bean class="org.apache.http.interceptor.RequestConnControl" />
-        <bean class="org.apache.http.interceptor.RequestUserAgent" />
-        <bean class="org.apache.http.interceptor.RequestExpectContinue" />
-      </set>
+        <bean class="org.apache.http.protocol.RequestConnControl" />
+        <bean class="org.apache.http.protocol.RequestUserAgent" />
+        <bean class="org.apache.http.protocol.RequestExpectContinue" />
+      </list>
     </property>
     <property name="retryHandler"><ref bean="request-retry-handler"/></property>
   </bean>
   
-  <bean id="http-data-trx-factory" 
-    class="org.apache.http.impl.io.DefaultHttpDataTransmitterFactory" 
-    singleton="true" />
-  
-  <bean id="http-data-rcv-factory" 
-    class="org.apache.http.impl.io.DefaultHttpDataReceiverFactory" 
-    singleton="true" />
-  
   <bean id="http-request-factory"
     class="org.apache.http.impl.DefaultHttpRequestFactory" 
-    singleton="true" />
+    singleton="false" />
   
   <bean id="http-response-factory"
     class="org.apache.http.impl.DefaultHttpResponseFactory" 
-    singleton="true" />
+    singleton="false" />
+  
+  <bean id="http-entity-writer"
+    class="org.apache.http.impl.entity.DefaultClientEntityWriter" 
+    singleton="false" />
+  
+  <bean id="http-entity-generator"
+    class="org.apache.http.impl.entity.DefaultEntityGenerator" 
+    singleton="false" />
   
   <bean id="http-connection" 
     class="org.apache.http.impl.DefaultHttpClientConnection" 
     singleton="false">
-    <property name="receiverFactory"><ref bean="http-data-rcv-factory"/></property>
-    <property name="transmitterFactory"><ref bean="http-data-trx-factory"/></property>
     <property name="responseFactory"><ref bean="http-response-factory"/></property>
+    <property name="entityWriter"><ref bean="http-entity-writer"/></property>
+    <property name="entityGenerator"><ref bean="http-entity-generator"/></property>
   </bean>
-  
+
+  <bean id="conn-reuse-strategy"
+    class="org.apache.http.impl.DefaultConnectionReuseStrategy" 
+    singleton="true" />
+    
 </beans>

Propchange: jakarta/httpcomponents/trunk/http-core/src/contrib/org/apache/http/contrib/spring/http-beans.xml
            ('svn:executable' removed)

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java?rev=370456&r1=370455&r2=370456&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/AbstractHttpProcessor.java
Thu Jan 19 02:39:03 2006
@@ -119,6 +119,27 @@
             }
         }
     }
+
+    public void setInterceptors(final List list) {
+        if (list == null) {
+            return;
+        }
+        if (this.requestInterceptors != null) {
+            this.requestInterceptors.clear();
+        }
+        if (this.responseInterceptors != null) {
+            this.responseInterceptors.clear();
+        }
+        for (int i = 0; i < list.size(); i++) {
+            Object obj = list.get(i);
+            if (obj instanceof HttpRequestInterceptor) {
+                addInterceptor((HttpRequestInterceptor)obj);
+            }
+            if (obj instanceof HttpResponseInterceptor) {
+                addInterceptor((HttpResponseInterceptor)obj);
+            }
+        }
+    }
     
     public void clearInterceptors() {
         this.requestInterceptors = null;

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java?rev=370456&r1=370455&r2=370456&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HttpRequestExecutor.java
Thu Jan 19 02:39:03 2006
@@ -197,4 +197,13 @@
         postprocessResponse(response, this.context);
         return response;
     }
+
+    public HttpRequestRetryHandler getRetryHandler() {
+        return this.retryhandler;
+    }
+
+    public void setRetryHandler(final HttpRequestRetryHandler retryhandler) {
+        this.retryhandler = retryhandler;
+    }
+    
 }



Mime
View raw message