1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.http.impl.nio;
29
30 import java.io.IOException;
31
32 import org.apache.http.HttpException;
33 import org.apache.http.nio.ContentDecoder;
34 import org.apache.http.nio.ContentEncoder;
35 import org.apache.http.nio.NHttpClientConnection;
36 import org.apache.http.nio.NHttpClientEventHandler;
37 import org.apache.http.nio.NHttpClientHandler;
38
39
40
41
42 @Deprecated
43 class NHttpClientEventHandlerAdaptor implements NHttpClientEventHandler {
44
45 private final NHttpClientHandler handler;
46
47 public NHttpClientEventHandlerAdaptor(final NHttpClientHandler handler) {
48 super();
49 this.handler = handler;
50 }
51
52 public void connected(final NHttpClientConnection conn, final Object attachment) {
53 this.handler.connected(conn, attachment);
54 }
55
56 public void requestReady(
57 final NHttpClientConnection conn) throws IOException, HttpException {
58 this.handler.requestReady(conn);
59 }
60
61 public void responseReceived(
62 final NHttpClientConnection conn) throws IOException, HttpException {
63 this.handler.responseReceived(conn);
64 }
65
66 public void inputReady(
67 final NHttpClientConnection conn,
68 final ContentDecoder decoder) throws IOException, HttpException {
69 this.handler.inputReady(conn, decoder);
70 }
71
72 public void outputReady(
73 final NHttpClientConnection conn,
74 final ContentEncoder encoder) throws IOException, HttpException {
75 this.handler.outputReady(conn, encoder);
76 }
77
78 public void exception(final NHttpClientConnection conn, final Exception ex) {
79 if (ex instanceof HttpException) {
80 this.handler.exception(conn, (HttpException) ex);
81 } else if (ex instanceof IOException) {
82 this.handler.exception(conn, (IOException) ex);
83 } else {
84 if (ex instanceof RuntimeException) {
85 throw (RuntimeException) ex;
86 } else {
87 throw new Error("Unexpected exception: ", ex);
88 }
89 }
90 }
91
92 public void endOfInput(final NHttpClientConnection conn) throws IOException {
93 conn.close();
94 }
95
96 public void timeout(final NHttpClientConnection conn) {
97 this.handler.timeout(conn);
98 }
99
100 public void closed(final NHttpClientConnection conn) {
101 this.handler.closed(conn);
102 }
103
104 }