本文整理匯總了Java中org.apache.mina.transport.socket.nio.NioSocketAcceptor.dispose方法的典型用法代碼示例。如果您正苦於以下問題:Java NioSocketAcceptor.dispose方法的具體用法?Java NioSocketAcceptor.dispose怎麽用?Java NioSocketAcceptor.dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.mina.transport.socket.nio.NioSocketAcceptor
的用法示例。
在下文中一共展示了NioSocketAcceptor.dispose方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.apache.mina.transport.socket.nio.NioSocketAcceptor; //導入方法依賴的package包/類
public static final void main(String[] args) {
IoBuffer.setUseDirectBuffer(false);
IoBuffer.setAllocator(new SimpleBufferAllocator());
acceptor = new NioSocketAcceptor();
acceptor.getSessionConfig().setReuseAddress(true); // XXX For debug only
acceptor.getSessionConfig().setTcpNoDelay(true);
acceptor.setCloseOnDeactivation(true);
acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(AuthCodecFactory.getInstance()));
acceptor.setHandler(AuthServerHandler.getInstance());
for (;;) {
try {
acceptor.bind(new InetSocketAddress(PORT));
break;
} catch (IOException e) {
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
break;
}
}
}
LOGGER.info("Auth Server listening on port {}.", PORT);
/*Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public final void run() {
acceptor.unbind();
acceptor.dispose();
}
});*/
while (sc.hasNextLine()) {
if (sc.nextLine().equalsIgnoreCase("q")) {
System.out.println("Shutting down...");
for (IoSession session : acceptor.getManagedSessions().values()) {
session.close(true);
}
acceptor.unbind();
acceptor.dispose(true);
break;
}
}
}
示例2: main
import org.apache.mina.transport.socket.nio.NioSocketAcceptor; //導入方法依賴的package包/類
public static final void main(String[] args) {
IoBuffer.setUseDirectBuffer(false);
IoBuffer.setAllocator(new SimpleBufferAllocator());
acceptor = new NioSocketAcceptor();
acceptor.getSessionConfig().setReuseAddress(true); // XXX For debug only
acceptor.getSessionConfig().setTcpNoDelay(true);
acceptor.setCloseOnDeactivation(true);
acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(RealmCodecFactory.getInstance()));
acceptor.setHandler(RealmServerHandler.getInstance());
for (;;) {
try {
acceptor.bind(new InetSocketAddress(PORT));
break;
} catch (IOException e) {
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
break;
}
}
}
LOGGER.info("Realm Server listening on port {}.", PORT);
/*Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public final void run() {
acceptor.unbind();
acceptor.dispose();
}
});*/
while (sc.hasNextLine()) {
if (sc.nextLine().equalsIgnoreCase("q")) {
System.out.println("Shutting down...");
for (IoSession session : acceptor.getManagedSessions().values()) {
session.close(true);
}
acceptor.unbind();
acceptor.dispose(true);
break;
}
}
}