1 /*
2 * ====================================================================
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 * ====================================================================
20 *
21 * This software consists of voluntary contributions made by many
22 * individuals on behalf of the Apache Software Foundation. For more
23 * information on the Apache Software Foundation, please see
24 * <http://www.apache.org/>.
25 *
26 */
27
28 package org.apache.http.nio;
29
30 import java.io.IOException;
31
32 import org.apache.http.HttpException;
33
34 /**
35 * Abstract server-side HTTP protocol handler.
36 *
37 * @since 4.0
38 *
39 * @deprecated (4.2) use {@link NHttpServerEventHandler}
40 */
41 @Deprecated
42 public interface NHttpServiceHandler {
43
44 /**
45 * Triggered when a new incoming connection is created.
46 *
47 * @param conn new incoming connection HTTP connection.
48 */
49 void connected(NHttpServerConnection conn);
50
51 /**
52 * Triggered when a new HTTP request is received. The connection
53 * passed as a parameter to this method is guaranteed to return
54 * a valid HTTP request object.
55 * <p/>
56 * If the request received encloses a request entity this method will
57 * be followed a series of
58 * {@link #inputReady(NHttpServerConnection, ContentDecoder)} calls
59 * to transfer the request content.
60 *
61 * @see NHttpServerConnection
62 *
63 * @param conn HTTP connection that contains a new HTTP request
64 */
65 void requestReceived(NHttpServerConnection conn);
66
67 /**
68 * Triggered when the underlying channel is ready for reading a
69 * new portion of the request entity through the corresponding
70 * content decoder.
71 * <p/>
72 * If the content consumer is unable to process the incoming content,
73 * input event notifications can be temporarily suspended using
74 * {@link IOControl} interface.
75 *
76 * @see NHttpServerConnection
77 * @see ContentDecoder
78 * @see IOControl
79 *
80 * @param conn HTTP connection that can produce a new portion of the
81 * incoming request content.
82 * @param decoder The content decoder to use to read content.
83 */
84 void inputReady(NHttpServerConnection conn, ContentDecoder decoder);
85
86 /**
87 * Triggered when the connection is ready to accept a new HTTP response.
88 * The protocol handler does not have to submit a response if it is not
89 * ready.
90 *
91 * @see NHttpServerConnection
92 *
93 * @param conn HTTP connection that contains an HTTP response
94 */
95 void responseReady(NHttpServerConnection conn);
96
97 /**
98 * Triggered when the underlying channel is ready for writing a
99 * 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 }