Search in sources :

Example 11 with IoSession

use of org.apache.mina.core.session.IoSession in project netty by netty.

the class TestDnsServer method start.

@Override
public void start() throws IOException {
    InetSocketAddress address = new InetSocketAddress(NetUtil.LOCALHOST4, 0);
    UdpTransport transport = new UdpTransport(address.getHostName(), address.getPort());
    setTransports(transport);
    DatagramAcceptor acceptor = transport.getAcceptor();
    acceptor.setHandler(new DnsProtocolHandler(this, store) {

        @Override
        public void sessionCreated(IoSession session) throws Exception {
            // USe our own codec to support AAAA testing
            session.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new TestDnsProtocolUdpCodecFactory()));
        }
    });
    ((DatagramSessionConfig) acceptor.getSessionConfig()).setReuseAddress(true);
    // Start the listener
    acceptor.bind();
}
Also used : UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) DatagramAcceptor(org.apache.mina.transport.socket.DatagramAcceptor) InetSocketAddress(java.net.InetSocketAddress) DatagramSessionConfig(org.apache.mina.transport.socket.DatagramSessionConfig) ProtocolCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter) DnsProtocolHandler(org.apache.directory.server.dns.protocol.DnsProtocolHandler) DnsException(org.apache.directory.server.dns.DnsException) IOException(java.io.IOException) IoSession(org.apache.mina.core.session.IoSession)

Aggregations

IoSession (org.apache.mina.core.session.IoSession)11 IOException (java.io.IOException)3 InetSocketAddress (java.net.InetSocketAddress)3 DnsProtocolHandler (org.apache.directory.server.dns.protocol.DnsProtocolHandler)2 UdpTransport (org.apache.directory.server.protocol.shared.transport.UdpTransport)2 ProtocolCodecFilter (org.apache.mina.filter.codec.ProtocolCodecFilter)2 DatagramSessionConfig (org.apache.mina.transport.socket.DatagramSessionConfig)2 Field (java.lang.reflect.Field)1 SocketAddress (java.net.SocketAddress)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 JMException (javax.management.JMException)1 MBeanServer (javax.management.MBeanServer)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ObjectName (javax.management.ObjectName)1 SSLContext (javax.net.ssl.SSLContext)1 Exchange (org.apache.camel.Exchange)1 DefaultExchange (org.apache.camel.impl.DefaultExchange)1 Entry (org.apache.directory.api.ldap.model.entry.Entry)1