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 @Override
53 public void connected(final NHttpClientConnection conn, final Object attachment) {
54 this.handler.connected(conn, attachment);
55 }
56
57 @Override
58 public void requestReady(
59 final NHttpClientConnection conn) throws IOException, HttpException {
60 this.handler.requestReady(conn);
61 }
62
63 @Override
64 public void responseReceived(
65 final NHttpClientConnection conn) throws IOException, HttpException {
66 this.handler.responseReceived(conn);
67 }
68
69 @Override
70 public void inputReady(
71 final NHttpClientConnection conn,
72 final ContentDecoder decoder) throws IOException, HttpException {
73 this.handler.inputReady(conn, decoder);
74 }
75
76 @Override
77 public void outputReady(
78 final NHttpClientConnection conn,
79 final ContentEncoder encoder) throws IOException, HttpException {
80 this.handler.outputReady(conn, encoder);
81 }
82
83 @Override
84 public void exception(final NHttpClientConnection conn, final Exception ex) {
85 if (ex instanceof HttpException) {
86 this.handler.exception(conn, (HttpException) ex);
87 } else if (ex instanceof IOException) {
88 this.handler.exception(conn, (IOException) ex);
89 } else {
90 if (ex instanceof RuntimeException) {
91 throw (RuntimeException) ex;
92 }
93 throw new Error("Unexpected exception: ", ex);
94 }
95 }
96
97 @Override
98 public void endOfInput(final NHttpClientConnection conn) throws IOException {
99 conn.close();
100 }
101
102 @Override
103 public void timeout(final NHttpClientConnection conn) {
104 this.handler.timeout(conn);
105 }
106
107 @Override
108 public void closed(final NHttpClientConnection conn) {
109 this.handler.closed(conn);
110 }
111
112 }