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 package org.apache.http.impl.conn;
28
29 import java.io.IOException;
30
31 import org.apache.http.HttpHost;
32 import org.apache.http.conn.ClientConnectionManager;
33 import org.apache.http.conn.OperatedClientConnection;
34 import org.apache.http.conn.routing.HttpRoute;
35 import org.apache.http.params.HttpParams;
36 import org.apache.http.protocol.HttpContext;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 @Deprecated
53 public abstract class AbstractPooledConnAdapter extends AbstractClientConnAdapter {
54
55
56 protected volatile AbstractPoolEntry poolEntry;
57
58
59
60
61
62
63
64 protected AbstractPooledConnAdapter(final ClientConnectionManager manager,
65 final AbstractPoolEntry entry) {
66 super(manager, entry.connection);
67 this.poolEntry = entry;
68 }
69
70 @Override
71 public String getId() {
72 return null;
73 }
74
75
76
77
78
79
80
81
82 @Deprecated
83 protected AbstractPoolEntry getPoolEntry() {
84 return this.poolEntry;
85 }
86
87
88
89
90
91
92
93
94
95 protected void assertValid(final AbstractPoolEntry entry) {
96 if (isReleased() || entry == null) {
97 throw new ConnectionShutdownException();
98 }
99 }
100
101
102
103
104 @Deprecated
105 protected final void assertAttached() {
106 if (poolEntry == null) {
107 throw new ConnectionShutdownException();
108 }
109 }
110
111
112
113
114
115 @Override
116 protected synchronized void detach() {
117 poolEntry = null;
118 super.detach();
119 }
120
121 @Override
122 public HttpRoute getRoute() {
123 final AbstractPoolEntry entry = getPoolEntry();
124 assertValid(entry);
125 return (entry.tracker == null) ? null : entry.tracker.toRoute();
126 }
127
128 @Override
129 public void open(final HttpRoute route,
130 final HttpContext context, final HttpParams params)
131 throws IOException {
132 final AbstractPoolEntry entry = getPoolEntry();
133 assertValid(entry);
134 entry.open(route, context, params);
135 }
136
137 @Override
138 public void tunnelTarget(final boolean secure, final HttpParams params)
139 throws IOException {
140 final AbstractPoolEntry entry = getPoolEntry();
141 assertValid(entry);
142 entry.tunnelTarget(secure, params);
143 }
144
145 @Override
146 public void tunnelProxy(final HttpHost next, final boolean secure, final HttpParams params)
147 throws IOException {
148 final AbstractPoolEntry entry = getPoolEntry();
149 assertValid(entry);
150 entry.tunnelProxy(next, secure, params);
151 }
152
153 @Override
154 public void layerProtocol(final HttpContext context, final HttpParams params)
155 throws IOException {
156 final AbstractPoolEntry entry = getPoolEntry();
157 assertValid(entry);
158 entry.layerProtocol(context, params);
159 }
160
161 @Override
162 public void close() throws IOException {
163 final AbstractPoolEntry entry = getPoolEntry();
164 if (entry != null) {
165 entry.shutdownEntry();
166 }
167
168 final OperatedClientConnection conn = getWrappedConnection();
169 if (conn != null) {
170 conn.close();
171 }
172 }
173
174 @Override
175 public void shutdown() throws IOException {
176 final AbstractPoolEntry entry = getPoolEntry();
177 if (entry != null) {
178 entry.shutdownEntry();
179 }
180
181 final OperatedClientConnection conn = getWrappedConnection();
182 if (conn != null) {
183 conn.shutdown();
184 }
185 }
186
187 @Override
188 public Object getState() {
189 final AbstractPoolEntry entry = getPoolEntry();
190 assertValid(entry);
191 return entry.getState();
192 }
193
194 @Override
195 public void setState(final Object state) {
196 final AbstractPoolEntry entry = getPoolEntry();
197 assertValid(entry);
198 entry.setState(state);
199 }
200
201 }