本文整理汇总了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;
}
}
}