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