Save This Page
Home » HttpComponents-Core-4.0.1 » org.apache.http.nio » [javadoc | source]
    1   /*
    2    * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0.1/httpcore-nio/src/main/java/org/apache/http/nio/NHttpServiceHandler.java $
    3    * $Revision: 744541 $
    4    * $Date: 2009-02-14 18:26:23 +0100 (Sat, 14 Feb 2009) $
    5    *
    6    * ====================================================================
    7    * Licensed to the Apache Software Foundation (ASF) under one
    8    * or more contributor license agreements.  See the NOTICE file
    9    * distributed with this work for additional information
   10    * regarding copyright ownership.  The ASF licenses this file
   11    * to you under the Apache License, Version 2.0 (the
   12    * "License"); you may not use this file except in compliance
   13    * with the License.  You may obtain a copy of the License at
   14    *
   15    *   http://www.apache.org/licenses/LICENSE-2.0
   16    *
   17    * Unless required by applicable law or agreed to in writing,
   18    * software distributed under the License is distributed on an
   19    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   20    * KIND, either express or implied.  See the License for the
   21    * specific language governing permissions and limitations
   22    * under the License.
   23    * ====================================================================
   24    *
   25    * This software consists of voluntary contributions made by many
   26    * individuals on behalf of the Apache Software Foundation.  For more
   27    * information on the Apache Software Foundation, please see
   28    * <http://www.apache.org/>.
   29    *
   30    */
   31   
   32   package org.apache.http.nio;
   33   
   34   import java.io.IOException;
   35   
   36   import org.apache.http.HttpException;
   37   
   38   /**
   39    * Abstract server-side HTTP protocol handler.   
   40    * 
   41    *
   42    * @version $Revision: 744541 $
   43    *
   44    * @since 4.0
   45    */
   46   public interface NHttpServiceHandler {
   47   
   48       /**
   49        * Triggered when a new incoming connection is created.
   50        * 
   51        * @param conn new incoming connection HTTP connection.
   52        */
   53       void connected(NHttpServerConnection conn);
   54       
   55       /**
   56        * Triggered when a new HTTP request is received. The connection
   57        * passed as a parameter to this method is guaranteed to return
   58        * a valid HTTP request object.
   59        * <p/>
   60        * If the request received encloses a request entity this method will 
   61        * be followed a series of 
   62        * {@link #inputReady(NHttpServerConnection, ContentDecoder)} calls
   63        * to transfer the request content.
   64        * 
   65        * @see NHttpServerConnection
   66        * 
   67        * @param conn HTTP connection that contains a new HTTP request
   68        */
   69       void requestReceived(NHttpServerConnection conn);
   70   
   71       /**
   72        * Triggered when the underlying channel is ready for reading a
   73        * new portion of the request entity through the corresponding 
   74        * content decoder. 
   75        * <p/>
   76        * If the content consumer is unable to process the incoming content,
   77        * input event notifications can be temporarily suspended using 
   78        * {@link IOControl} interface.
   79        * 
   80        * @see NHttpServerConnection
   81        * @see ContentDecoder
   82        * @see IOControl
   83        *  
   84        * @param conn HTTP connection that can produce a new portion of the
   85        * incoming request content.
   86        * @param decoder The content decoder to use to read content.
   87        */
   88       void inputReady(NHttpServerConnection conn, ContentDecoder decoder);
   89       
   90       /**
   91        * Triggered when the connection is ready to accept a new HTTP response. 
   92        * The protocol handler does not have to submit a response if it is not 
   93        * ready.
   94        * 
   95        * @see NHttpServerConnection
   96        * 
   97        * @param conn HTTP connection that contains an HTTP response
   98        */
   99       void responseReady(NHttpServerConnection conn);
  100   
  101       /**
  102        * Triggered when the underlying channel is ready for writing a
  103        * next portion of the response entity through the corresponding 
  104        * content encoder. 
  105        * <p/>
  106        * If the content producer is unable to generate the outgoing content,
  107        * output event notifications can be temporarily suspended using 
  108        * {@link IOControl} interface.
  109        * 
  110        * @see NHttpServerConnection
  111        * @see ContentEncoder
  112        * @see IOControl
  113        *  
  114        * @param conn HTTP connection that can accommodate a new portion 
  115        * of the outgoing response content.
  116        * @param encoder The content encoder to use to write content.
  117        */
  118       void outputReady(NHttpServerConnection conn, ContentEncoder encoder);
  119   
  120       /**
  121        * Triggered when an I/O error occurs while reading from or writing
  122        * to the underlying channel.
  123        * 
  124        * @param conn HTTP connection that caused an I/O error
  125        * @param ex I/O exception
  126        */
  127       void exception(NHttpServerConnection conn, IOException ex);
  128       
  129       /**
  130        * Triggered when an HTTP protocol violation occurs while receiving 
  131        * an HTTP request.
  132        * 
  133        * @param conn HTTP connection that caused an HTTP protocol violation
  134        * @param ex HTTP protocol violation exception
  135        */
  136       void exception(NHttpServerConnection conn, HttpException ex);
  137   
  138       /**
  139        * Triggered when no input is detected on this connection over the
  140        * maximum period of inactivity.
  141        * 
  142        * @param conn HTTP connection that caused timeout condition.
  143        */
  144       void timeout(NHttpServerConnection conn);
  145       
  146       /**
  147        * Triggered when the connection is closed.
  148        * 
  149        * @param conn closed HTTP connection.
  150        */
  151       void closed(NHttpServerConnection conn);
  152           
  153   }

Save This Page
Home » HttpComponents-Core-4.0.1 » org.apache.http.nio » [javadoc | source]