List of usage examples for java.nio.channels.spi AbstractSelectableChannel register
public final SelectionKey register(Selector sel, int ops, Object att) throws ClosedChannelException
From source file:net.timewalker.ffmq4.transport.tcp.nio.NIOTcpMultiplexer.java
protected void addInterest(AbstractSelectableChannel channel, int interest, Object attachment, Selector selector) {/*from w w w. j av a 2 s . co m*/ try { SelectionKey sk = channel.keyFor(selector); if (sk != null) { if (!sk.isValid()) return; int actualInterests = sk.interestOps(); if ((actualInterests & interest) != interest) sk.interestOps(actualInterests | interest); if (attachment != null) sk.attach(attachment); } else channel.register(selector, interest, attachment); } catch (ClosedChannelException e) { log.warn("Cannot add interest to selector channel : channel is closed"); } }