1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.io;
20
21 import java.io.IOException;
22
23 import org.eclipse.jetty.util.log.Log;
24 import org.eclipse.jetty.util.log.Logger;
25
26
27 public abstract class AbstractConnection implements Connection
28 {
29 private static final Logger LOG = Log.getLogger(AbstractConnection.class);
30
31 private final long _timeStamp;
32 protected final EndPoint _endp;
33
34 public AbstractConnection(EndPoint endp)
35 {
36 _endp=(EndPoint)endp;
37 _timeStamp = System.currentTimeMillis();
38 }
39
40 public AbstractConnection(EndPoint endp,long timestamp)
41 {
42 _endp=(EndPoint)endp;
43 _timeStamp = timestamp;
44 }
45
46 public long getTimeStamp()
47 {
48 return _timeStamp;
49 }
50
51 public EndPoint getEndPoint()
52 {
53 return _endp;
54 }
55
56 public void onIdleExpired(long idleForMs)
57 {
58 try
59 {
60 LOG.debug("onIdleExpired {}ms {} {}",idleForMs,this,_endp);
61 if (_endp.isInputShutdown() || _endp.isOutputShutdown())
62 _endp.close();
63 else
64 _endp.shutdownOutput();
65 }
66 catch(IOException e)
67 {
68 LOG.ignore(e);
69
70 try
71 {
72 _endp.close();
73 }
74 catch(IOException e2)
75 {
76 LOG.ignore(e2);
77 }
78 }
79 }
80
81 public String toString()
82 {
83 return String.format("%s@%x", getClass().getSimpleName(), hashCode());
84 }
85 }