001/* 002 * ==================================================================== 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 * ==================================================================== 020 * 021 * This software consists of voluntary contributions made by many 022 * individuals on behalf of the Apache Software Foundation. For more 023 * information on the Apache Software Foundation, please see 024 * <http://www.apache.org/>. 025 * 026 */ 027 028package org.apache.http.nio; 029 030import java.io.IOException; 031 032import org.apache.http.HttpException; 033 034/** 035 * Abstract server-side HTTP protocol handler. 036 * 037 * @since 4.0 038 * 039 * @deprecated (4.2) use {@link NHttpServerEventHandler} 040 */ 041@Deprecated 042public interface NHttpServiceHandler { 043 044 /** 045 * Triggered when a new incoming connection is created. 046 * 047 * @param conn new incoming connection HTTP connection. 048 */ 049 void connected(NHttpServerConnection conn); 050 051 /** 052 * Triggered when a new HTTP request is received. The connection 053 * passed as a parameter to this method is guaranteed to return 054 * a valid HTTP request object. 055 * <p> 056 * If the request received encloses a request entity this method will 057 * be followed a series of 058 * {@link #inputReady(NHttpServerConnection, ContentDecoder)} calls 059 * to transfer the request content. 060 * 061 * @see NHttpServerConnection 062 * 063 * @param conn HTTP connection that contains a new HTTP request 064 */ 065 void requestReceived(NHttpServerConnection conn); 066 067 /** 068 * Triggered when the underlying channel is ready for reading a 069 * new portion of the request entity through the corresponding 070 * content decoder. 071 * <p> 072 * If the content consumer is unable to process the incoming content, 073 * input event notifications can be temporarily suspended using 074 * {@link IOControl} interface. 075 * 076 * @see NHttpServerConnection 077 * @see ContentDecoder 078 * @see IOControl 079 * 080 * @param conn HTTP connection that can produce a new portion of the 081 * incoming request content. 082 * @param decoder The content decoder to use to read content. 083 */ 084 void inputReady(NHttpServerConnection conn, ContentDecoder decoder); 085 086 /** 087 * Triggered when the connection is ready to accept a new HTTP response. 088 * The protocol handler does not have to submit a response if it is not 089 * ready. 090 * 091 * @see NHttpServerConnection 092 * 093 * @param conn HTTP connection that contains an HTTP response 094 */ 095 void responseReady(NHttpServerConnection conn); 096 097 /** 098 * Triggered when the underlying channel is ready for writing a 099 * next portion of the response entity through the corresponding 100 * content encoder. 101 * <p> 102 * If the content producer is unable to generate the outgoing content, 103 * output event notifications can be temporarily suspended using 104 * {@link IOControl} interface. 105 * 106 * @see NHttpServerConnection 107 * @see ContentEncoder 108 * @see IOControl 109 * 110 * @param conn HTTP connection that can accommodate a new portion 111 * of the outgoing response content. 112 * @param encoder The content encoder to use to write content. 113 */ 114 void outputReady(NHttpServerConnection conn, ContentEncoder encoder); 115 116 /** 117 * Triggered when an I/O error occurs while reading from or writing 118 * to the underlying channel. 119 * 120 * @param conn HTTP connection that caused an I/O error 121 * @param ex I/O exception 122 */ 123 void exception(NHttpServerConnection conn, IOException ex); 124 125 /** 126 * Triggered when an HTTP protocol violation occurs while receiving 127 * an HTTP request. 128 * 129 * @param conn HTTP connection that caused an HTTP protocol violation 130 * @param ex HTTP protocol violation exception 131 */ 132 void exception(NHttpServerConnection conn, HttpException ex); 133 134 /** 135 * Triggered when no input is detected on this connection over the 136 * maximum period of inactivity. 137 * 138 * @param conn HTTP connection that caused timeout condition. 139 */ 140 void timeout(NHttpServerConnection conn); 141 142 /** 143 * Triggered when the connection is closed. 144 * 145 * @param conn closed HTTP connection. 146 */ 147 void closed(NHttpServerConnection conn); 148 149}