@Override public int registerChannel(Channel channel) throws IOException { AbstractSession session = getSession(); int maxChannels = session.getIntProperty(MAX_CONCURRENT_CHANNELS_PROP, DEFAULT_MAX_CHANNELS); int curSize = channels.size(); if (curSize > maxChannels) { throw new IllegalStateException("Currently active channels (" + curSize + ") at max.: " + maxChannels); } int channelId = getNextChannelId(); channel.init(this, session, channelId); boolean registered = false; synchronized (lock) { if (!isClosing()) { channels.put(channelId, channel); registered = true; } } if (!registered) { handleChannelRegistrationFailure(channel, channelId); } if (log.isDebugEnabled()) { log.debug("registerChannel({})[id={}] {}", this, channelId, channel); } return channelId; }
@Override public int registerChannel(Channel channel) throws IOException { AbstractSession session = getSession(); int maxChannels = session.getIntProperty(MAX_CONCURRENT_CHANNELS_PROP, DEFAULT_MAX_CHANNELS); int curSize = channels.size(); if (curSize > maxChannels) { throw new IllegalStateException("Currently active channels (" + curSize + ") at max.: " + maxChannels); } int channelId = getNextChannelId(); channel.init(this, session, channelId); boolean registered = false; synchronized (lock) { if (!isClosing()) { channels.put(channelId, channel); registered = true; } } if (!registered) { handleChannelRegistrationFailure(channel, channelId); } if (log.isDebugEnabled()) { log.debug("registerChannel({})[id={}] {}", this, channelId, channel); } return channelId; }