public void initSessionConfig() throws RuntimeIoException { this.config.setAll(service.getSessionConfig()); }
/** * Create the connector * * @throws LdapException If the connector can't be created */ private void createConnector() throws LdapException { // Use only one thread inside the connector connector = new NioSocketConnector( 1 ); if ( connectionConfig != null ) { ( ( SocketSessionConfig ) connector.getSessionConfig() ).setAll( connectionConfig ); } else { ( ( SocketSessionConfig ) connector.getSessionConfig() ).setReuseAddress( true ); } // Add the codec to the chain connector.getFilterChain().addLast( "ldapCodec", ldapProtocolFilter ); // If we use SSL, we have to add the SslFilter to the chain if ( config.isUseSsl() ) { addSslFilter(); } // Inject the protocolHandler connector.setHandler( this ); }
/** * Create the connector * * @throws LdapException If the connector can't be created */ private void createConnector() throws LdapException { // Use only one thread inside the connector connector = new NioSocketConnector( 1 ); if ( connectionConfig != null ) { ( ( SocketSessionConfig ) connector.getSessionConfig() ).setAll( connectionConfig ); } else { ( ( SocketSessionConfig ) connector.getSessionConfig() ).setReuseAddress( true ); } // Add the codec to the chain connector.getFilterChain().addLast( "ldapCodec", ldapProtocolFilter ); // If we use SSL, we have to add the SslFilter to the chain if ( config.isUseSsl() ) { addSslFilter(); } // Inject the protocolHandler connector.setHandler( this ); }
/** * Create the connector * * @throws LdapException If the connector can't be created */ private void createConnector() throws LdapException { // Use only one thread inside the connector connector = new NioSocketConnector( 1 ); if ( connectionConfig != null ) { ( ( SocketSessionConfig ) connector.getSessionConfig() ).setAll( connectionConfig ); } else { ( ( SocketSessionConfig ) connector.getSessionConfig() ).setReuseAddress( true ); } // Add the codec to the chain connector.getFilterChain().addLast( "ldapCodec", ldapProtocolFilter ); // If we use SSL, we have to add the SslFilter to the chain if ( config.isUseSsl() ) { addSslFilter(); } // Inject the protocolHandler connector.setHandler( this ); }
/** * start Mina serversocket * @throws Exception */ public void start(final int serverPort) throws Exception { IoBuffer.setUseDirectBuffer(false); IoBuffer.setAllocator(new SimpleBufferAllocator()); acceptor = new NioSocketAcceptor(pool); acceptor.setReuseAddress(true); acceptor.getSessionConfig().setAll(getSessionConfig()); logger.info("socket server start at port:{},正在监听客户端的连接...", serverPort); DefaultIoFilterChainBuilder filterChain = acceptor.getFilterChain(); filterChain.addLast("codec", new ProtocolCodecFilter(SerializerHelper.getInstance().getCodecFactory())); filterChain.addLast("moduleEntrance", new ModuleEntranceFilter()); filterChain.addLast("msgTrace", new MessageTraceFilter()); filterChain.addLast("flood", new FloodFilter()); //指定业务逻辑处理器 acceptor.setHandler(new ServerSocketIoHandler(new MessageDispatcher())); //设置端口号 acceptor.setDefaultLocalAddress(new InetSocketAddress(serverPort) ); //启动监听 acceptor.bind(); }
config.setAll(sessionConfig);