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 public String getId() {
71 return null;
72 }
73
74
75
76
77
78
79
80
81 @Deprecated
82 protected AbstractPoolEntry getPoolEntry() {
83 return this.poolEntry;
84 }
85
86
87
88
89
90
91
92
93
94 protected void assertValid(final AbstractPoolEntry entry) {
95 if (isReleased() || entry == null) {
96 throw new ConnectionShutdownException();
97 }
98 }
99
100
101
102
103 @Deprecated
104 protected final void assertAttached() {
105 if (poolEntry == null) {
106 throw new ConnectionShutdownException();
107 }
108 }
109
110
111
112
113
114 @Override
115 protected synchronized void detach() {
116 poolEntry = null;
117 super.detach();
118 }
119
120 public HttpRoute getRoute() {
121 final AbstractPoolEntry entry = getPoolEntry();
122 assertValid(entry);
123 return (entry.tracker == null) ? null : entry.tracker.toRoute();
124 }
125
126 public void open(final HttpRoute route,
127 final HttpContext context, final HttpParams params)
128 throws IOException {
129 final AbstractPoolEntry entry = getPoolEntry();
130 assertValid(entry);
131 entry.open(route, context, params);
132 }
133
134 public void tunnelTarget(final boolean secure, final HttpParams params)
135 throws IOException {
136 final AbstractPoolEntry entry = getPoolEntry();
137 assertValid(entry);
138 entry.tunnelTarget(secure, params);
139 }
140
141 public void tunnelProxy(final HttpHost next, final boolean secure, final HttpParams params)
142 throws IOException {
143 final AbstractPoolEntry entry = getPoolEntry();
144 assertValid(entry);
145 entry.tunnelProxy(next, secure, params);
146 }
147
148 public void layerProtocol(final HttpContext context, final HttpParams params)
149 throws IOException {
150 final AbstractPoolEntry entry = getPoolEntry();
151 assertValid(entry);
152 entry.layerProtocol(context, params);
153 }
154
155 public void close() throws IOException {
156 final AbstractPoolEntry entry = getPoolEntry();
157 if (entry != null) {
158 entry.shutdownEntry();
159 }
160
161 final OperatedClientConnection conn = getWrappedConnection();
162 if (conn != null) {
163 conn.close();
164 }
165 }
166
167 public void shutdown() throws IOException {
168 final AbstractPoolEntry entry = getPoolEntry();
169 if (entry != null) {
170 entry.shutdownEntry();
171 }
172
173 final OperatedClientConnection conn = getWrappedConnection();
174 if (conn != null) {
175 conn.shutdown();
176 }
177 }
178
179 public Object getState() {
180 final AbstractPoolEntry entry = getPoolEntry();
181 assertValid(entry);
182 return entry.getState();
183 }
184
185 public void setState(final Object state) {
186 final AbstractPoolEntry entry = getPoolEntry();
187 assertValid(entry);
188 entry.setState(state);
189 }
190
191 }