/** * Perform read operation on channel which is now ready for reading */ private void performRead(SelectionKey key) { if (Thread.currentThread().isInterrupted()) { return; } Connection c = (Connection) key.attachment(); try { c.read(); } catch (IOException e) { log.log(Level.FINE, "read failed", e); try { c.close(); } catch (IOException e2) { log.log(Level.FINE, "close failed", e); } } }
/** * Perform write operation(s) on channel which is now ready for * writing */ private void performWrite(SelectionKey key) { if (Thread.currentThread().isInterrupted()) { return; } Connection c = (Connection) key.attachment(); try { c.write(); } catch (IOException e) { log.log(Level.FINE, " write failed", e); try { c.close(); } catch (IOException e2) {// ignore } } }
/** * Complete asynchronous connect operation. <em>Note that * asynchronous connect does not work properly in 1.4, * so you should not use this if you run anything older * than 1.5/5.0</em>. * */ private void performConnect(SelectionKey key) { if (Thread.currentThread().isInterrupted()) { return; } Connection c = (Connection) key.attachment(); try { c.connect(); } catch (IOException e) { log.log(Level.FINE, "connect failed", e); try { c.close(); } catch (IOException e2) { log.log(Level.FINE, "close failed", e); } } }
public void close() { for (Connection c = connectionPool.getConnection(); c != null; c = connectionPool.getConnection()) { try { c.close(); } catch (IOException e) { logWarning("closing", e); } } }