/** * Find the {@link NetChannel} for the given IO channel object. * * @param ioChannel * The channel object. * @param <C> * The type of the channel object. * * @return The {@link NetChannel} associated with the given channel. */ protected <C> NetChannel<IN, OUT> select(@Nonnull C ioChannel) { Assert.notNull(ioChannel, "Channel cannot be null."); Iterator<Registration<? extends NetChannel<IN, OUT>>> channs = netChannels.select(ioChannel).iterator(); if (channs.hasNext()) { return channs.next().getObject(); } else { NetChannel<IN, OUT> conn = createChannel(ioChannel); register(ioChannel, conn); notifyOpen(conn); return conn; } }