Index: apache/directory/server/ntp/NtpServer.java =================================================================== --- apache/directory/server/ntp/NtpServer.java (revision 746339) +++ apache/directory/server/ntp/NtpServer.java (working copy) @@ -20,66 +20,59 @@ package org.apache.directory.server.ntp; - import java.io.IOException; import java.net.InetSocketAddress; -import java.util.Dictionary; import org.apache.directory.server.ntp.protocol.NtpProtocolHandler; import org.apache.mina.common.IoAcceptor; import org.apache.mina.common.IoHandler; -import org.apache.mina.common.IoServiceConfig; +import org.apache.mina.common.ThreadModel; +import org.apache.mina.transport.socket.nio.DatagramAcceptor; +import org.apache.mina.transport.socket.nio.DatagramAcceptorConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +public class NtpServer { + /** the log for this class */ + private static final Logger log = LoggerFactory.getLogger(NtpServer.class); -public class NtpServer -{ - /** the log for this class */ - private static final Logger log = LoggerFactory.getLogger( NtpServer.class ); + private IoAcceptor acceptor; - private NtpConfiguration config; - private IoAcceptor acceptor; + private IoHandler handler; - private IoHandler handler; + private int port; + public NtpServer(int port) { - public NtpServer( NtpConfiguration config, IoAcceptor acceptor, IoServiceConfig serviceConfig ) - { - this.config = config; - this.acceptor = acceptor; + String name = "TIME SERVER"; + this.port = port; + try { + DatagramAcceptorConfig udpConfig = new DatagramAcceptorConfig(); + acceptor = new DatagramAcceptor(); - String name = config.getName(); - int port = config.getPort(); + udpConfig.setThreadModel(ThreadModel.MANUAL); - try - { - handler = new NtpProtocolHandler(); + handler = new NtpProtocolHandler(); - acceptor.bind( new InetSocketAddress( port ), handler, serviceConfig ); + acceptor.bind(new InetSocketAddress(port), handler, udpConfig); - log.debug( name + " listening on port " + port ); - } - catch ( IOException ioe ) - { - log.error( ioe.getMessage(), ioe ); - } - } + log.info(name + " listening on port " + port); + } catch (IOException ioe) { + log.error(ioe.getMessage(), ioe); + } + } + public void destroy() { + acceptor.unbind(new InetSocketAddress(port)); - public boolean isDifferent( Dictionary newConfig ) - { - return config.isDifferent( newConfig ); - } + acceptor = null; + handler = null; + System.out.println("ntp has stopped listening on port " + port); + } - public void destroy() - { - acceptor.unbind( new InetSocketAddress( config.getPort() ) ); + public static void main(String arv[]) { + NtpServer udpNtpServer = new NtpServer(10123); - acceptor = null; - handler = null; - - log.debug( config.getName() + " has stopped listening on port " + config.getPort() ); - } + } }