1 package org.eclipse.jetty.io;
2
3 import java.io.IOException;
4
5 import org.eclipse.jetty.util.log.Log;
6 import org.eclipse.jetty.util.log.Logger;
7
8
9 public abstract class AbstractConnection implements Connection
10 {
11 private static final Logger LOG = Log.getLogger(AbstractConnection.class);
12
13 private final long _timeStamp;
14 protected final EndPoint _endp;
15
16 public AbstractConnection(EndPoint endp)
17 {
18 _endp=endp;
19 _timeStamp = System.currentTimeMillis();
20 }
21
22 public AbstractConnection(EndPoint endp,long timestamp)
23 {
24 _endp=endp;
25 _timeStamp = timestamp;
26 }
27
28 public long getTimeStamp()
29 {
30 return _timeStamp;
31 }
32
33 public EndPoint getEndPoint()
34 {
35 return _endp;
36 }
37
38 public void idleExpired()
39 {
40 try
41 {
42 _endp.shutdownOutput();
43 }
44 catch(IOException e)
45 {
46 LOG.ignore(e);
47
48 try
49 {
50 _endp.close();
51 }
52 catch(IOException e2)
53 {
54 LOG.ignore(e2);
55
56 }
57 }
58 }
59
60 public String toString()
61 {
62 return super.toString()+"@"+_endp.getLocalAddr()+":"+_endp.getLocalPort()+"<->"+_endp.getRemoteAddr()+":"+_endp.getRemotePort();
63 }
64 }