Mercurial Hosting > luan
comparison src/org/eclipse/jetty/io/AbstractConnection.java @ 973:4d9fe9cc554d
simplify AbstractConnection
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sat, 15 Oct 2016 23:03:00 -0600 |
| parents | 8e9db0bbf4f9 |
| children | 7422ca1ae146 |
comparison
equal
deleted
inserted
replaced
| 972:5ee36654b383 | 973:4d9fe9cc554d |
|---|---|
| 26 | 26 |
| 27 public abstract class AbstractConnection implements Connection | 27 public abstract class AbstractConnection implements Connection |
| 28 { | 28 { |
| 29 private static final Logger LOG = LoggerFactory.getLogger(AbstractConnection.class); | 29 private static final Logger LOG = LoggerFactory.getLogger(AbstractConnection.class); |
| 30 | 30 |
| 31 private final long _timeStamp; | |
| 32 protected final EndPoint _endp; | 31 protected final EndPoint _endp; |
| 33 | 32 |
| 34 public AbstractConnection(EndPoint endp) | 33 protected AbstractConnection(EndPoint endp) |
| 35 { | 34 { |
| 36 _endp=(EndPoint)endp; | 35 _endp = endp; |
| 37 _timeStamp = System.currentTimeMillis(); | |
| 38 } | 36 } |
| 39 | 37 |
| 40 public AbstractConnection(EndPoint endp,long timestamp) | 38 public final EndPoint getEndPoint() |
| 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 { | 39 { |
| 53 return _endp; | 40 return _endp; |
| 54 } | 41 } |
| 55 | 42 |
| 56 public void onIdleExpired(long idleForMs) | 43 @Override |
| 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.trace("",e); | |
| 69 | |
| 70 try | |
| 71 { | |
| 72 _endp.close(); | |
| 73 } | |
| 74 catch(IOException e2) | |
| 75 { | |
| 76 LOG.trace("",e2); | |
| 77 } | |
| 78 } | |
| 79 } | |
| 80 | |
| 81 public String toString() | 44 public String toString() |
| 82 { | 45 { |
| 83 return String.format("%s@%x", getClass().getSimpleName(), hashCode()); | 46 return String.format("%s@%x", getClass().getSimpleName(), hashCode()); |
| 84 } | 47 } |
| 85 } | 48 } |
