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 2006/10/19 17:19:34 UTC
svn commit: r465656 -
/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/
Author: olegk
Date: Thu Oct 19 08:19:32 2006
New Revision: 465656
URL: http://svn.apache.org/viewvc?view=rev&rev=465656
Log:
Added non-blocking, event-driven HTTP transport interfaces (API)
Added:
jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/
jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentDecoder.java (with props)
jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentEncoder.java (with props)
jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientConnection.java (with props)
jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientHandler.java (with props)
jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpConnection.java (with props)
jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServerConnection.java (with props)
jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServiceHandler.java (with props)
Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentDecoder.java?view=auto&rev=465656
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentDecoder.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentDecoder.java Thu Oct 19 08:19:32 2006
@@ -0,0 +1,63 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2006 The Apache Software Foundation
+ *
+ * Licensed 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.nio.handler;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * Abstract HTTP content decoder. HTTP content decoders can be used
+ * to read entity content from the underlying channel in small
+ * chunks and apply the required coding transformation.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public interface ContentDecoder {
+
+ /**
+ * Reads a portion of content from the underlying channel
+ *
+ * @param dst The buffer into which entity content is to be transferred
+ * @return The number of bytes read, possibly zero, or -1 if the
+ * channel has reached end-of-stream
+ * @throws IOException if I/O error occurs while reading content
+ */
+ int read(ByteBuffer dst) throws IOException;
+
+ /**
+ * Returns <tt>true</tt> if the entity has been received in its
+ * entirety.
+ *
+ * @return <tt>true</tt> if all the content has been consumed,
+ * <tt>false</tt> otherwise.
+ */
+ boolean isCompeted();
+
+}
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentDecoder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentDecoder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentEncoder.java?view=auto&rev=465656
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentEncoder.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentEncoder.java Thu Oct 19 08:19:32 2006
@@ -0,0 +1,69 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2006 The Apache Software Foundation
+ *
+ * Licensed 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.nio.handler;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * Abstract HTTP content encoder. HTTP content encoders can be used
+ * to apply the required coding transformation and write entity
+ * content to the underlying channel in small chunks.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public interface ContentEncoder {
+
+ /**
+ * Writes a portion of entity content to the underlying channel.
+ *
+ * @param src The buffer from which content is to be retrieved
+ * @return The number of bytes read, possibly zero
+ * @throws IOException if I/O error occurs while writing content
+ */
+ int write(ByteBuffer src) throws IOException;
+
+ /**
+ * Terminates the content stream.
+ *
+ * @throws IOException if I/O error occurs while writing content
+ */
+ void complete() throws IOException;
+
+ /**
+ * Returns <tt>true</tt> if the entity has been transferred in its
+ * entirety.
+ *
+ * @return <tt>true</tt> if all the content has been produced,
+ * <tt>false</tt> otherwise.
+ */
+ boolean isCompeted();
+
+}
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentEncoder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/ContentEncoder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientConnection.java?view=auto&rev=465656
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientConnection.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientConnection.java Thu Oct 19 08:19:32 2006
@@ -0,0 +1,69 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2006 The Apache Software Foundation
+ *
+ * Licensed 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.nio.handler;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+
+/**
+ * Abstract non-blocking client-side HTTP connection. It can be used to
+ * submit HTTP requests and asynchronously receive HTTP responses.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public interface NHttpClientConnection extends NHttpConnection {
+
+ /**
+ * Returns an HTTP response if it is already available. Otherwise returns
+ * <tt>null</tt>.
+ *
+ * @return an HTTP response if available. Otherwise returns <tt>null</tt>.
+ */
+ HttpResponse getHttpResponse();
+
+ /**
+ * Submits the HTTP request to the target server.
+ *
+ * @param request HTTP request
+ * @throws HttpException if the HTTP request violates the HTTP protocol.
+ */
+ void submitRequest(HttpRequest request) throws HttpException;
+
+ /**
+ * Returns <tt>true</tt> if an HTTP request has been submitted to the
+ * target server.
+ *
+ * @return <tt>true</tt> if an HTTP request has been submitted,
+ * <tt>false</tt> otherwise.
+ */
+ boolean isRequestSubmitted();
+
+}
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientConnection.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientConnection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientHandler.java?view=auto&rev=465656
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientHandler.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientHandler.java Thu Oct 19 08:19:32 2006
@@ -0,0 +1,128 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2006 The Apache Software Foundation
+ *
+ * Licensed 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.nio.handler;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+
+/**
+ * Abstract client-side HTTP event handler.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public interface NHttpClientHandler {
+
+ /**
+ * Triggered when an HTTP response is received. The connection
+ * passed as a parameter to this method is guaranteed to return
+ * a valid HTTP response object.
+ * <p/>
+ * If the response received encloses a response entity this method will
+ * be followed a series of
+ * {@link #inputReady(NHttpClientConnection, ContentDecoder)} calls
+ * to transfer the response content.
+ *
+ * @see NHttpClientConnection
+ *
+ * @param conn HTTP connection that contains an HTTP response
+ */
+ void responseReceived(NHttpClientConnection conn);
+
+ /**
+ * Triggered when the underlying channel is ready for reading a
+ * new portion of the response entity through the corresponding
+ * content decoder.
+ * <p/>
+ * If the content consumer is unable to process the incoming content,
+ * input event notifications can be temorarily suspended using
+ * {@link NHttpConnection#suspendInput()}.
+ *
+ * @see NHttpConnection
+ * @see ContentDecoder
+ *
+ * @param conn HTTP connection that can produce a new portion of the
+ * incoming response content.
+ * @param decoder The content decoder to use to read content.
+ */
+ void inputReady(NHttpClientConnection conn, ContentDecoder decoder);
+
+ /**
+ * Triggered when the underlying channel is ready for writing a
+ * next portion of the request entity through the corresponding
+ * content encoder.
+ * <p/>
+ * If the content producer is unable to generate the outgoing content,
+ * output event notifications can be temorarily suspended using
+ * {@link NHttpConnection#suspendOutput()}.
+ *
+ * @see NHttpConnection
+ * @see ContentEncoder
+ *
+ * @param conn HTTP connection that can accommodate a new portion
+ * of the outgoing request content.
+ * @param encoder The content encoder to use to write content.
+ */
+ void outputReady(NHttpClientConnection conn, ContentEncoder encoder);
+
+ /**
+ * Triggered when an I/O error occurrs while reading from or writing
+ * to the underlying channel.
+ *
+ * @param conn HTTP connection that caused an I/O error
+ * @param ex I/O exception
+ */
+ void exception(NHttpClientConnection conn, IOException ex);
+
+ /**
+ * Triggered when an HTTP protocol violation occurs while receiving
+ * an HTTP response.
+ *
+ * @param conn HTTP connection that caused an HTTP protocol violation
+ * @param ex HTTP protocol violation exception
+ */
+ void exception(NHttpClientConnection conn, HttpException ex);
+
+ /**
+ * Triggered when no input is detected on this connection over the
+ * maximum period of inactivity.
+ *
+ * @param conn HTTP connection that caused timeout condition.
+ */
+ void timeout(NHttpClientConnection conn);
+
+ /**
+ * Triggered when the connection is closed.
+ *
+ * @param conn closed HTTP connection.
+ */
+ void closed(NHttpClientConnection conn);
+
+}
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpClientHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpConnection.java?view=auto&rev=465656
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpConnection.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpConnection.java Thu Oct 19 08:19:32 2006
@@ -0,0 +1,74 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2006 The Apache Software Foundation
+ *
+ * Licensed 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.nio.handler;
+
+import org.apache.http.HttpConnection;
+import org.apache.http.protocol.HttpContext;
+
+/**
+ * Abstract non-blocking HTTP connection interface. It can be used to request or
+ * temporarily suspend event notifications that are triggered when the underlying
+ * channel is ready for input / output operations.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public interface NHttpConnection extends HttpConnection {
+
+ /**
+ * Requests event notifications to be triggered when the underlying
+ * channel is ready for input oprtations.
+ */
+ void requestInput();
+
+ /**
+ * Suspends event notifications about the underlying channel being
+ * ready for input operations.
+ */
+ void suspendInput();
+
+ /**
+ * Requests event notifications to be triggered when the underlying
+ * channel is ready for output oprtations.
+ */
+ void requestOutput();
+
+ /**
+ * Suspends event notifications about the underlying channel being
+ * ready for output operations.
+ */
+ void suspendOutput();
+
+ /**
+ * Returns an HTTP execution context associated with this connection.
+ * @return HTTP context
+ */
+ HttpContext getContext();
+
+}
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpConnection.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpConnection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServerConnection.java?view=auto&rev=465656
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServerConnection.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServerConnection.java Thu Oct 19 08:19:32 2006
@@ -0,0 +1,77 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2006 The Apache Software Foundation
+ *
+ * Licensed 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.nio.handler;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+
+/**
+ * Abstract non-blocking server-side HTTP connection. It can be used to
+ * receive HTTP requests and asynchronously submit HTTP responses.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public interface NHttpServerConnection extends NHttpConnection {
+
+ /**
+ * Returns an HTTP request if it is already available. Otherwise returns
+ * <tt>null</tt>.
+ *
+ * @return an HTTP request if available. Otherwise returns <tt>null</tt>.
+ */
+ HttpRequest getHttpRequest();
+
+ /**
+ * Submits the HTTP response to the client.
+ *
+ * @param response HTTP response
+ *
+ * @throws HttpException if the HTTP response violates the HTTP protocol.
+ */
+ void submitResponse(HttpResponse response) throws HttpException;
+
+ /**
+ * Submits the 100-continue response to the client.
+ *
+ * @throws HttpException if the HTTP response violates the HTTP protocol.
+ */
+ void submitContinue() throws HttpException;
+
+ /**
+ * Returns <tt>true</tt> if an HTTP response has been submitted to the
+ * client.
+ *
+ * @return <tt>true</tt> if an HTTP response has been submitted,
+ * <tt>false</tt> otherwise.
+ */
+ boolean isResponseSubmitted();
+
+}
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServerConnection.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServerConnection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServiceHandler.java?view=auto&rev=465656
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServiceHandler.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServiceHandler.java Thu Oct 19 08:19:32 2006
@@ -0,0 +1,128 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2006 The Apache Software Foundation
+ *
+ * Licensed 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.nio.handler;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+
+/**
+ * Abstract server-side HTTP event handler.
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ */
+public interface NHttpServiceHandler {
+
+ /**
+ * Triggered when a new HTTP request is received. The connection
+ * passed as a parameter to this method is guaranteed to return
+ * a valid HTTP request object.
+ * <p/>
+ * If the request received encloses a request entity this method will
+ * be followed a series of
+ * {@link #inputReady(NHttpServerConnection, ContentDecoder)} calls
+ * to transfer the request content.
+ *
+ * @see NHttpServerConnection
+ *
+ * @param conn HTTP connection that contains a new HTTP request
+ */
+ void requestReceived(NHttpServerConnection conn);
+
+ /**
+ * Triggered when the underlying channel is ready for reading a
+ * new portion of the request entity through the corresponding
+ * content decoder.
+ * <p/>
+ * If the content consumer is unable to process the incoming content,
+ * input event notifications can be temorarily suspended using
+ * {@link NHttpConnection#suspendInput()}.
+ *
+ * @see NHttpConnection
+ * @see ContentDecoder
+ *
+ * @param conn HTTP connection that can produce a new portion of the
+ * incoming request content.
+ * @param decoder The content decoder to use to read content.
+ */
+ void inputReady(NHttpServerConnection conn, ContentDecoder decoder);
+
+ /**
+ * Triggered when the underlying channel is ready for writing a
+ * next portion of the response entity through the corresponding
+ * content encoder.
+ * <p/>
+ * If the content producer is unable to generate the outgoing content,
+ * output event notifications can be temorarily suspended using
+ * {@link NHttpConnection#suspendOutput()}.
+ *
+ * @see NHttpConnection
+ * @see ContentEncoder
+ *
+ * @param conn HTTP connection that can accommodate a new portion
+ * of the outgoing response content.
+ * @param encoder The content encoder to use to write content.
+ */
+ void outputReady(NHttpServerConnection conn, ContentEncoder encoder);
+
+ /**
+ * Triggered when an I/O error occurrs while reading from or writing
+ * to the underlying channel.
+ *
+ * @param conn HTTP connection that caused an I/O error
+ * @param ex I/O exception
+ */
+ void exception(NHttpServerConnection conn, IOException ex);
+
+ /**
+ * Triggered when an HTTP protocol violation occurs while receiving
+ * an HTTP request.
+ *
+ * @param conn HTTP connection that caused an HTTP protocol violation
+ * @param ex HTTP protocol violation exception
+ */
+ void exception(NHttpServerConnection conn, HttpException ex);
+
+ /**
+ * Triggered when no input is detected on this connection over the
+ * maximum period of inactivity.
+ *
+ * @param conn HTTP connection that caused timeout condition.
+ */
+ void timeout(NHttpServerConnection conn);
+
+ /**
+ * Triggered when the connection is closed.
+ *
+ * @param conn closed HTTP connection.
+ */
+ void closed(NHttpServerConnection conn);
+
+}
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServiceHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/handler/NHttpServiceHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain