zoukankan      html  css  js  c++  java
  • Apache MINA 框架之默认session管理类实现

    DefaultSocketSessionConfig 类

    extends AbstractSocketSessionConfig extends AbstractIoSessionConfig

    implements SocketSessionConfig,IoSessionConfig

    protected IoService parent;
    private boolean defaultReuseAddress;
    private boolean reuseAddress;
    //接受数据缓冲区大小
     private int receiveBufferSize = -1;
    //发送数据缓冲区大小
     private int sendBufferSize = -1;
    
     private int trafficClass = 0private boolean keepAlive = false;
     private boolean oobInline = false;
     private int soLinger = -1;
     private boolean tcpNoDelay = false;
     public void init(IoService parent) {
            this.parent = parent;
    
            if (parent instanceof SocketAcceptor) {
                defaultReuseAddress = true;
            } else {
                defaultReuseAddress = false;
            }
    
            reuseAddress = defaultReuseAddress;
        }

    doSetAll方法

     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());
                }
            }
    }
  • 相关阅读:
    商业研究(10):比呀比-海淘电商-海外正品直邮-高品质跨境购物平台
    商业研究(10):比呀比-海淘电商-海外正品直邮-高品质跨境购物平台
    POJ 2923 Relocation
    ZJU 2425 Inversion
    HDU 1394 Minimum Inversion Number
    POJ 1787 Charlie's Change
    HDU 2191 悼念512汶川大地震
    Gym
    HDU 2069 Coin Change
    UVA 674 Coin Change
  • 原文地址:https://www.cnblogs.com/quyongjin/p/3186741.html
Copyright © 2011-2022 走看看