Return-Path: Delivered-To: apmail-hc-commits-archive@www.apache.org Received: (qmail 51568 invoked from network); 10 Mar 2008 19:22:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Mar 2008 19:22:52 -0000 Received: (qmail 17311 invoked by uid 500); 10 Mar 2008 19:22:49 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 17288 invoked by uid 500); 10 Mar 2008 19:22:48 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 17274 invoked by uid 99); 10 Mar 2008 19:22:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Mar 2008 12:22:48 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Mar 2008 19:22:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5F1841A9832; Mon, 10 Mar 2008 12:22:21 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r635662 - in /httpcomponents/httpcore/trunk/module-nio/src: main/java/org/apache/http/nio/protocol/ test/java/org/apache/http/nio/protocol/ Date: Mon, 10 Mar 2008 19:22:13 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080310192221.5F1841A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Mon Mar 10 12:22:07 2008 New Revision: 635662 URL: http://svn.apache.org/viewvc?rev=635662&view=rev Log: * Eliminated superfluous abstract / base protocol handlers Removed: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AbstractNHttpClientHandler.java httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AbstractNHttpServiceHandler.java Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandler.java Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java?rev=635662&r1=635661&r2=635662&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java (original) +++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpClientHandler.java Mon Mar 10 12:22:07 2008 @@ -43,6 +43,7 @@ import org.apache.http.nio.ContentDecoder; import org.apache.http.nio.ContentEncoder; import org.apache.http.nio.NHttpClientConnection; +import org.apache.http.nio.NHttpClientHandler; import org.apache.http.nio.entity.ConsumingNHttpEntity; import org.apache.http.nio.entity.ConsumingNHttpEntityTemplate; import org.apache.http.nio.entity.NHttpEntityWrapper; @@ -68,7 +69,8 @@ * @author Sam Berlin * */ -public class AsyncNHttpClientHandler extends AbstractNHttpClientHandler { +public class AsyncNHttpClientHandler extends NHttpHandlerBase + implements NHttpClientHandler { protected NHttpRequestExecutionHandler execHandler; @@ -109,7 +111,6 @@ requestReady(conn); } - @Override public void closed(final NHttpClientConnection conn) { HttpContext context = conn.getContext(); @@ -123,6 +124,20 @@ } } + public void exception(final NHttpClientConnection conn, final HttpException ex) { + closeConnection(conn, ex); + if (this.eventListener != null) { + this.eventListener.fatalProtocolException(ex, conn); + } + } + + public void exception(final NHttpClientConnection conn, final IOException ex) { + shutdownConnection(conn, ex); + if (this.eventListener != null) { + this.eventListener.fatalIOException(ex, conn); + } + } + public void requestReady(final NHttpClientConnection conn) { HttpContext context = conn.getContext(); Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java?rev=635662&r1=635661&r2=635662&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java (original) +++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java Mon Mar 10 12:22:07 2008 @@ -63,6 +63,7 @@ import org.apache.http.params.HttpParams; import org.apache.http.protocol.ExecutionContext; import org.apache.http.protocol.HttpContext; +import org.apache.http.protocol.HttpExpectationVerifier; import org.apache.http.protocol.HttpProcessor; import org.apache.http.util.EncodingUtils; @@ -92,10 +93,13 @@ * @author Sam Berlin * @author Steffen Pingel */ -public class AsyncNHttpServiceHandler extends AbstractNHttpServiceHandler - implements NHttpServiceHandler { +public class AsyncNHttpServiceHandler extends NHttpHandlerBase + implements NHttpServiceHandler { + + protected final HttpResponseFactory responseFactory; protected NHttpRequestHandlerResolver handlerResolver; + protected HttpExpectationVerifier expectationVerifier; public AsyncNHttpServiceHandler( final HttpProcessor httpProcessor, @@ -103,7 +107,11 @@ final ConnectionReuseStrategy connStrategy, final ByteBufferAllocator allocator, final HttpParams params) { - super(httpProcessor, responseFactory, connStrategy, allocator, params); + super(httpProcessor, connStrategy, allocator, params); + if (responseFactory == null) { + throw new IllegalArgumentException("Response factory may not be null"); + } + this.responseFactory = responseFactory; } public AsyncNHttpServiceHandler( @@ -115,6 +123,10 @@ new HeapByteBufferAllocator(), params); } + public void setExpectationVerifier(final HttpExpectationVerifier expectationVerifier) { + this.expectationVerifier = expectationVerifier; + } + public void setHandlerResolver(final NHttpRequestHandlerResolver handlerResolver) { this.handlerResolver = handlerResolver; } @@ -264,6 +276,18 @@ this.eventListener.fatalProtocolException(ex, conn); } } + } + + public void exception(final NHttpServerConnection conn, final IOException ex) { + shutdownConnection(conn, ex); + + if (this.eventListener != null) { + this.eventListener.fatalIOException(ex, conn); + } + } + + public void timeout(final NHttpServerConnection conn) { + handleTimeout(conn); } public void inputReady(final NHttpServerConnection conn, final ContentDecoder decoder) { Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java?rev=635662&r1=635661&r2=635662&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java (original) +++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpClientHandlerBase.java Mon Mar 10 12:22:07 2008 @@ -31,12 +31,19 @@ package org.apache.http.nio.protocol; +import java.io.IOException; + import org.apache.http.ConnectionReuseStrategy; +import org.apache.http.HttpException; +import org.apache.http.nio.NHttpClientConnection; +import org.apache.http.nio.NHttpClientHandler; import org.apache.http.nio.util.ByteBufferAllocator; import org.apache.http.params.HttpParams; import org.apache.http.protocol.HttpProcessor; -public abstract class NHttpClientHandlerBase extends AbstractNHttpClientHandler { +@Deprecated +public abstract class NHttpClientHandlerBase extends NHttpHandlerBase + implements NHttpClientHandler { protected HttpRequestExecutionHandler execHandler; @@ -51,6 +58,26 @@ throw new IllegalArgumentException("HTTP request execution handler may not be null."); } this.execHandler = execHandler; + } + + public void closed(final NHttpClientConnection conn) { + if (this.eventListener != null) { + this.eventListener.connectionClosed(conn); + } + } + + public void exception(final NHttpClientConnection conn, final HttpException ex) { + closeConnection(conn, ex); + if (this.eventListener != null) { + this.eventListener.fatalProtocolException(ex, conn); + } + } + + public void exception(final NHttpClientConnection conn, final IOException ex) { + shutdownConnection(conn, ex); + if (this.eventListener != null) { + this.eventListener.fatalIOException(ex, conn); + } } } Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java?rev=635662&r1=635661&r2=635662&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java (original) +++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/NHttpServiceHandlerBase.java Mon Mar 10 12:22:07 2008 @@ -31,15 +31,26 @@ package org.apache.http.nio.protocol; +import java.io.IOException; + import org.apache.http.ConnectionReuseStrategy; import org.apache.http.HttpResponseFactory; +import org.apache.http.nio.NHttpServerConnection; +import org.apache.http.nio.NHttpServiceHandler; import org.apache.http.nio.util.ByteBufferAllocator; +import org.apache.http.nio.util.HeapByteBufferAllocator; import org.apache.http.params.HttpParams; +import org.apache.http.protocol.HttpExpectationVerifier; import org.apache.http.protocol.HttpProcessor; import org.apache.http.protocol.HttpRequestHandlerResolver; -public abstract class NHttpServiceHandlerBase extends AbstractNHttpServiceHandler { +@Deprecated +public abstract class NHttpServiceHandlerBase extends NHttpHandlerBase + implements NHttpServiceHandler { + + protected final HttpResponseFactory responseFactory; + protected HttpExpectationVerifier expectationVerifier; protected HttpRequestHandlerResolver handlerResolver; public NHttpServiceHandlerBase( @@ -48,7 +59,11 @@ final ConnectionReuseStrategy connStrategy, final ByteBufferAllocator allocator, final HttpParams params) { - super(httpProcessor, responseFactory, connStrategy, allocator, params); + super(httpProcessor, connStrategy, allocator, params); + if (responseFactory == null) { + throw new IllegalArgumentException("Response factory may not be null"); + } + this.responseFactory = responseFactory; } public NHttpServiceHandlerBase( @@ -56,11 +71,28 @@ final HttpResponseFactory responseFactory, final ConnectionReuseStrategy connStrategy, final HttpParams params) { - super(httpProcessor, responseFactory, connStrategy, params); + this(httpProcessor, responseFactory, connStrategy, + new HeapByteBufferAllocator(), params); } public void setHandlerResolver(final HttpRequestHandlerResolver handlerResolver) { this.handlerResolver = handlerResolver; + } + + public void setExpectationVerifier(final HttpExpectationVerifier expectationVerifier) { + this.expectationVerifier = expectationVerifier; + } + + public void exception(final NHttpServerConnection conn, final IOException ex) { + shutdownConnection(conn, ex); + + if (this.eventListener != null) { + this.eventListener.fatalIOException(ex, conn); + } + } + + public void timeout(final NHttpServerConnection conn) { + handleTimeout(conn); } } Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java?rev=635662&r1=635661&r2=635662&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java (original) +++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java Mon Mar 10 12:22:07 2008 @@ -46,6 +46,7 @@ import org.apache.http.nio.ContentEncoder; import org.apache.http.nio.IOControl; import org.apache.http.nio.NHttpClientConnection; +import org.apache.http.nio.NHttpClientHandler; import org.apache.http.nio.NHttpConnection; import org.apache.http.nio.entity.ContentBufferEntity; import org.apache.http.nio.entity.ContentOutputStream; @@ -81,8 +82,10 @@ * @author Oleg Kalnichevski * */ -public class ThrottlingHttpClientHandler extends NHttpClientHandlerBase { +public class ThrottlingHttpClientHandler extends NHttpHandlerBase + implements NHttpClientHandler { + protected HttpRequestExecutionHandler execHandler; protected final Executor executor; public ThrottlingHttpClientHandler( @@ -92,10 +95,14 @@ final ByteBufferAllocator allocator, final Executor executor, final HttpParams params) { - super(httpProcessor, execHandler, connStrategy, allocator, params); + super(httpProcessor, connStrategy, allocator, params); + if (execHandler == null) { + throw new IllegalArgumentException("HTTP request execution handler may not be null."); + } if (executor == null) { throw new IllegalArgumentException("Executor may not be null"); } + this.execHandler = execHandler; this.executor = executor; } @@ -126,18 +133,31 @@ requestReady(conn); } - @Override public void closed(final NHttpClientConnection conn) { HttpContext context = conn.getContext(); this.execHandler.finalizeContext(context); - // TODO - replace with super.closed(conn); ? if (this.eventListener != null) { this.eventListener.connectionClosed(conn); } } + public void exception(final NHttpClientConnection conn, final HttpException ex) { + closeConnection(conn, ex); + if (this.eventListener != null) { + this.eventListener.fatalProtocolException(ex, conn); + } + } + + public void exception(final NHttpClientConnection conn, final IOException ex) { + shutdownConnection(conn, ex); + if (this.eventListener != null) { + this.eventListener.fatalIOException(ex, conn); + } + } + + public void requestReady(final NHttpClientConnection conn) { HttpContext context = conn.getContext(); Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java?rev=635662&r1=635661&r2=635662&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java (original) +++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java Mon Mar 10 12:22:07 2008 @@ -54,6 +54,7 @@ import org.apache.http.nio.IOControl; import org.apache.http.nio.NHttpConnection; import org.apache.http.nio.NHttpServerConnection; +import org.apache.http.nio.NHttpServiceHandler; import org.apache.http.nio.entity.ContentBufferEntity; import org.apache.http.nio.entity.ContentOutputStream; import org.apache.http.nio.params.NIOReactorPNames; @@ -67,8 +68,10 @@ import org.apache.http.params.DefaultedHttpParams; import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.ExecutionContext; +import org.apache.http.protocol.HttpExpectationVerifier; import org.apache.http.protocol.HttpProcessor; import org.apache.http.protocol.HttpRequestHandler; +import org.apache.http.protocol.HttpRequestHandlerResolver; import org.apache.http.util.EncodingUtils; /** @@ -88,9 +91,14 @@ * @author Oleg Kalnichevski * */ -public class ThrottlingHttpServiceHandler extends NHttpServiceHandlerBase { +public class ThrottlingHttpServiceHandler extends NHttpHandlerBase + implements NHttpServiceHandler { + protected final HttpResponseFactory responseFactory; protected final Executor executor; + + protected HttpRequestHandlerResolver handlerResolver; + protected HttpExpectationVerifier expectationVerifier; public ThrottlingHttpServiceHandler( final HttpProcessor httpProcessor, @@ -99,7 +107,14 @@ final ByteBufferAllocator allocator, final Executor executor, final HttpParams params) { - super(httpProcessor, responseFactory, connStrategy, allocator, params); + super(httpProcessor, connStrategy, allocator, params); + if (responseFactory == null) { + throw new IllegalArgumentException("Response factory may not be null"); + } + if (executor == null) { + throw new IllegalArgumentException("Executor may not be null"); + } + this.responseFactory = responseFactory; this.executor = executor; } @@ -113,6 +128,14 @@ new DirectByteBufferAllocator(), executor, params); } + public void setHandlerResolver(final HttpRequestHandlerResolver handlerResolver) { + this.handlerResolver = handlerResolver; + } + + public void setExpectationVerifier(final HttpExpectationVerifier expectationVerifier) { + this.expectationVerifier = expectationVerifier; + } + public void connected(final NHttpServerConnection conn) { HttpContext context = conn.getContext(); @@ -181,6 +204,18 @@ eventListener.fatalProtocolException(ex, conn); } } + } + + public void exception(final NHttpServerConnection conn, final IOException ex) { + shutdownConnection(conn, ex); + + if (this.eventListener != null) { + this.eventListener.fatalIOException(ex, conn); + } + } + + public void timeout(final NHttpServerConnection conn) { + handleTimeout(conn); } public void requestReceived(final NHttpServerConnection conn) { Modified: httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandler.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandler.java?rev=635662&r1=635661&r2=635662&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandler.java (original) +++ httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandler.java Mon Mar 10 12:22:07 2008 @@ -1,7 +1,7 @@ /* - * $HeadURL:$ - * $Revision:$ - * $Date:$ + * $HeadURL$ + * $Revision$ + * $Date$ * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -82,7 +82,7 @@ * * @author Oleg Kalnichevski * - * @version $Id:$ + * @version $Id$ */ public class TestThrottlingNHttpHandler extends TestCase { @@ -149,7 +149,7 @@ httpproc.addInterceptor(new ResponseContent()); httpproc.addInterceptor(new ResponseConnControl()); - NHttpServiceHandlerBase serviceHandler = new ThrottlingHttpServiceHandler( + ThrottlingHttpServiceHandler serviceHandler = new ThrottlingHttpServiceHandler( httpproc, new DefaultHttpResponseFactory(), new DefaultConnectionReuseStrategy(),