You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2007/06/16 14:06:13 UTC

svn commit: r547912 - /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java

Author: olegk
Date: Sat Jun 16 05:06:12 2007
New Revision: 547912

URL: http://svn.apache.org/viewvc?view=rev&rev=547912
Log:
HTTPCORE-64: Do not create a new HTTP context per each request execution. Request handlers may need to persist some custom state information between invocations.

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java

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=547912&r1=547911&r2=547912
==============================================================================
--- 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 Sat Jun 16 05:06:12 2007
@@ -271,8 +271,7 @@
                 public void run() {
                     try {
 
-                        HttpContext context = new HttpExecutionContext(conn.getContext());
-                        handleRequest(connState, conn, request, context);
+                        handleRequest(connState, conn);
                         
                     } catch (IOException ex) {
                         shutdownConnection(conn);
@@ -461,11 +460,12 @@
     
     private void handleRequest(
             final ServerConnState connState,
-            final NHttpServerConnection conn,
-            final HttpRequest request,
-            final HttpContext context) throws HttpException, IOException {
+            final NHttpServerConnection conn) throws HttpException, IOException {
 
         waitForOutputState(connState, ServerConnState.READY);
+
+        HttpContext context = conn.getContext();
+        HttpRequest request = connState.getRequest();
         
         HttpParamsLinker.link(request, this.params);
         



[HttpCore] Managing execution contexts was Re: svn commit: r547912

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2007-06-16 at 15:22 +0200, Roland Weber wrote:
> Hi Oleg,
> 
> > HTTPCORE-64: Do not create a new HTTP context per each request execution.
> > Request handlers may need to persist some custom state information between
> > invocations.
> 
> That's going to become an interesting design issue.
> When we discussed parent/child contexts last year, you
> suggested that the application should put shared objects
> into the different contexts to allow for shared data.
> Let's wait and see what use cases we'll get.
> 

Yes, I think this should be the case. However, whereas protocol handlers
in HttpCore base module do not impose any specific approach to managing
the execution context, those in HttpCore NIO do, because event-driven
API always assumes some kind of a context within which events occur. 

HttpService and HttpRequestExecutor simply take an instance of
HttpContext as a parameter and leave the gory details of context
management up to the caller. The user can create one context per
connection or per request or have a context hierarchy of a sort. Clean
and neat. 

We do not have the same flexibility in HttpCore NIO. So, if we use one
context per connection approach we at the very least give the users an
option to maintain state between request invocations, if so they desire.
If we used the context per request approach we would make this
impossible.

Cheers,

Oleg

> cheers,
>   Roland
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Re: svn commit: r547912

Posted by Roland Weber <os...@dubioso.net>.
Hi Oleg,

> HTTPCORE-64: Do not create a new HTTP context per each request execution.
> Request handlers may need to persist some custom state information between
> invocations.

That's going to become an interesting design issue.
When we discussed parent/child contexts last year, you
suggested that the application should put shared objects
into the different contexts to allow for shared data.
Let's wait and see what use cases we'll get.

cheers,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org