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.tsccm;
28
29 import java.lang.ref.ReferenceQueue;
30 import java.util.concurrent.TimeUnit;
31
32 import org.apache.http.conn.OperatedClientConnection;
33 import org.apache.http.conn.ClientConnectionOperator;
34 import org.apache.http.conn.routing.HttpRoute;
35 import org.apache.http.impl.conn.AbstractPoolEntry;
36
37
38
39
40
41
42
43
44 @Deprecated
45 public class BasicPoolEntry extends AbstractPoolEntry {
46
47 private final long created;
48
49 private long updated;
50 private long validUntil;
51 private long expiry;
52
53 public BasicPoolEntry(ClientConnectionOperator op,
54 HttpRoute route,
55 ReferenceQueue<Object> queue) {
56 super(op, route);
57 if (route == null) {
58 throw new IllegalArgumentException("HTTP route may not be null");
59 }
60 this.created = System.currentTimeMillis();
61 this.validUntil = Long.MAX_VALUE;
62 this.expiry = this.validUntil;
63 }
64
65
66
67
68
69
70
71 public BasicPoolEntry(ClientConnectionOperator op,
72 HttpRoute route) {
73 this(op, route, -1, TimeUnit.MILLISECONDS);
74 }
75
76
77
78
79
80
81
82
83
84
85
86 public BasicPoolEntry(ClientConnectionOperator op,
87 HttpRoute route, long connTTL, TimeUnit timeunit) {
88 super(op, route);
89 if (route == null) {
90 throw new IllegalArgumentException("HTTP route may not be null");
91 }
92 this.created = System.currentTimeMillis();
93 if (connTTL > 0) {
94 this.validUntil = this.created + timeunit.toMillis(connTTL);
95 } else {
96 this.validUntil = Long.MAX_VALUE;
97 }
98 this.expiry = this.validUntil;
99 }
100
101 protected final OperatedClientConnection getConnection() {
102 return super.connection;
103 }
104
105 protected final HttpRoute getPlannedRoute() {
106 return super.route;
107 }
108
109 protected final BasicPoolEntryRef getWeakRef() {
110 return null;
111 }
112
113 @Override
114 protected void shutdownEntry() {
115 super.shutdownEntry();
116 }
117
118
119
120
121 public long getCreated() {
122 return this.created;
123 }
124
125
126
127
128 public long getUpdated() {
129 return this.updated;
130 }
131
132
133
134
135 public long getExpiry() {
136 return this.expiry;
137 }
138
139 public long getValidUntil() {
140 return this.validUntil;
141 }
142
143
144
145
146 public void updateExpiry(long time, TimeUnit timeunit) {
147 this.updated = System.currentTimeMillis();
148 long newExpiry;
149 if (time > 0) {
150 newExpiry = this.updated + timeunit.toMillis(time);
151 } else {
152 newExpiry = Long.MAX_VALUE;
153 }
154 this.expiry = Math.min(validUntil, newExpiry);
155 }
156
157
158
159
160 public boolean isExpired(long now) {
161 return now >= this.expiry;
162 }
163
164 }
165
166