1. 程式人生 > >Apache MINA 框架之預設session管理類實現

Apache MINA 框架之預設session管理類實現

 protected final void doSetAll(IoSessionConfig config) {
        if (!(config instanceof SocketSessionConfig)) {
            return;
        }

        if (config instanceof AbstractSocketSessionConfig) {
            // Minimize unnecessary system calls by checking all 'propertyChanged' properties.
            AbstractSocketSessionConfig cfg = (AbstractSocketSessionConfig) config;
            
if (cfg.isKeepAliveChanged()) { setKeepAlive(cfg.isKeepAlive()); } if (cfg.isOobInlineChanged()) { setOobInline(cfg.isOobInline()); } if (cfg.isReceiveBufferSizeChanged()) { setReceiveBufferSize(cfg.getReceiveBufferSize()); }
if (cfg.isReuseAddressChanged()) { setReuseAddress(cfg.isReuseAddress()); } if (cfg.isSendBufferSizeChanged()) { setSendBufferSize(cfg.getSendBufferSize()); } if (cfg.isSoLingerChanged()) { setSoLinger(cfg.getSoLinger()); }
if (cfg.isTcpNoDelayChanged()) { setTcpNoDelay(cfg.isTcpNoDelay()); } if (cfg.isTrafficClassChanged() && getTrafficClass() != cfg.getTrafficClass()) { setTrafficClass(cfg.getTrafficClass()); } } else { SocketSessionConfig cfg = (SocketSessionConfig) config; setKeepAlive(cfg.isKeepAlive()); setOobInline(cfg.isOobInline()); setReceiveBufferSize(cfg.getReceiveBufferSize()); setReuseAddress(cfg.isReuseAddress()); setSendBufferSize(cfg.getSendBufferSize()); setSoLinger(cfg.getSoLinger()); setTcpNoDelay(cfg.isTcpNoDelay()); if (getTrafficClass() != cfg.getTrafficClass()) { setTrafficClass(cfg.getTrafficClass()); } } }