Trying to figure out how to create a server using Mina that listens on 2
different ports, each speaking their own protocol. Is it as simple as
setting up 2 IoAcceptors, and binding each to their own port? i.e.,:
protocolAcceptor1 = new NioSocketAcceptor(processor1);
protocolAcceptor1.setReuseAddress(true);
protocolAcceptor1.getFilterChain().addLast("logger", new LoggingFilter());
protocolAcceptor1.getFilterChain().addLast("codec", new
ProtocolCodecFilter(new TextLineCodecFactory()));
protocolAcceptor1.setHandler(new ProtocolOneHandler());
protocolAcceptor1.bind(new InetSocketAddress(PROTOCOL_ONE_PORT));
protocolAcceptor2 = new NioSocketAcceptor(processor2);
protocolAcceptor2.setReuseAddress(true);
protocolAcceptor2.getFilterChain().addLast("logger", new LoggingFilter());
protocolAcceptor2.getFilterChain().addLast("codec", new
ProtocolCodecFilter(new TextLineCodecFactory()));
protocolAcceptor2.setHandler(new ProtocolTwoHandler());
protocolAcceptor2.bind(new InetSocketAddress(PROTOCOL_TWO_PORT));
Also, if so, is it possible for both acceptors to share a processing
thread pool? i.e.:
processorThreadPool = Executors.newCachedThreadPool();
protocolAcceptor1 = new NioSocketAcceptor(new
NioProcessor(processorThreadPool));
protocolAcceptor2 = new NioSocketAcceptor(new
NioProcessor(processorThreadPool));
Thanks,
DR