Search in sources :

Example 1 with TextLineCodecFactory

use of org.apache.mina.filter.codec.textline.TextLineCodecFactory in project camel by apache.

the class ReverserServer method start.

public void start() throws Exception {
    acceptor = new SocketAcceptor();
    // Prepare the configuration
    SocketAcceptorConfig cfg = new SocketAcceptorConfig();
    cfg.setReuseAddress(true);
    Charset charset = Charset.forName("UTF-8");
    cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(charset)));
    // Bind
    acceptor.bind(new InetSocketAddress(port), new ReverseProtocolHandler(), cfg);
}
Also used : SocketAcceptorConfig(org.apache.mina.transport.socket.nio.SocketAcceptorConfig) InetSocketAddress(java.net.InetSocketAddress) SocketAcceptor(org.apache.mina.transport.socket.nio.SocketAcceptor) Charset(java.nio.charset.Charset) ProtocolCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter) TextLineCodecFactory(org.apache.mina.filter.codec.textline.TextLineCodecFactory)

Example 2 with TextLineCodecFactory

use of org.apache.mina.filter.codec.textline.TextLineCodecFactory in project camel by apache.

the class Mina2ReverserServer method start.

public void start() throws Exception {
    acceptor = new NioSocketAcceptor();
    // Prepare the configuration
    ((NioSocketAcceptor) acceptor).setReuseAddress(true);
    Charset charset = Charset.forName("UTF-8");
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(charset)));
    acceptor.setHandler(new Mina2ReverseProtocolHandler());
    // Bind
    acceptor.bind(new InetSocketAddress(port));
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Charset(java.nio.charset.Charset) ProtocolCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter) NioSocketAcceptor(org.apache.mina.transport.socket.nio.NioSocketAcceptor) TextLineCodecFactory(org.apache.mina.filter.codec.textline.TextLineCodecFactory)

Example 3 with TextLineCodecFactory

use of org.apache.mina.filter.codec.textline.TextLineCodecFactory in project opennms by OpenNMS.

the class AsyncSimpleServer method startServer.

/**
     * <p>startServer</p>
     *
     * @throws java.lang.Exception if any.
     */
public void startServer() throws Exception {
    m_acceptor = new NioSocketAcceptor();
    m_acceptor.getFilterChain().addLast("logger", new LoggingFilter());
    m_acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(StandardCharsets.UTF_8)));
    m_acceptor.setHandler(getServerHandler());
    m_acceptor.getSessionConfig().setReadBufferSize(getBufferSize());
    m_acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, getIdleTime());
    ((NioSocketAcceptor) m_acceptor).setReuseAddress(true);
    m_acceptor.bind(new InetSocketAddress(getPort()));
}
Also used : InetSocketAddress(java.net.InetSocketAddress) LoggingFilter(org.apache.mina.filter.logging.LoggingFilter) ProtocolCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter) NioSocketAcceptor(org.apache.mina.transport.socket.nio.NioSocketAcceptor) TextLineCodecFactory(org.apache.mina.filter.codec.textline.TextLineCodecFactory)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)3 ProtocolCodecFilter (org.apache.mina.filter.codec.ProtocolCodecFilter)3 TextLineCodecFactory (org.apache.mina.filter.codec.textline.TextLineCodecFactory)3 Charset (java.nio.charset.Charset)2 NioSocketAcceptor (org.apache.mina.transport.socket.nio.NioSocketAcceptor)2 LoggingFilter (org.apache.mina.filter.logging.LoggingFilter)1 SocketAcceptor (org.apache.mina.transport.socket.nio.SocketAcceptor)1 SocketAcceptorConfig (org.apache.mina.transport.socket.nio.SocketAcceptorConfig)1