}
class ServerAction implements PrivilegedExceptionAction {
public Object run() throws Exception {
ThreadPool tp = new ThreadPool();
tp.setKeepAliveTime(1 * 1000);
tp.setPoolSize(1);
tp.setPoolName("Server TP");
tp.doStart();
ClockPool cp = new ClockPool();
cp.setPoolName("Server CP");
cp.doStart();
SelectorManager sm = new SelectorManager();
sm.setThreadPool(tp);
sm.setThreadName("Server Selector Manager");
sm.doStart();
ControlServerProtocolStack templateStack = new ControlServerProtocolStack();
SocketProtocol spt = new SocketProtocol();
spt.setTimeout(10 * 1000);
spt.setSelectorManager(sm);
templateStack.push(spt);
ControlServerProtocol csp = new ControlServerProtocol();
csp.setTimeout(1 * 1000);
csp.setThreadPool(tp);
csp.setClockPool(cp);
csp.setSelectorManager(sm);
csp.setControlServerListener(new ControlServerListener() {
public void shutdown() {
log.trace("SERVER SIDE SHUTDOWN");
}
});
templateStack.push(csp);
ControlServerProtocolWaiter waiter = new ControlServerProtocolWaiter();
SubjectCarryingServerProtocol scp = new SubjectCarryingServerProtocol();
waiter.push(scp);
waiter.push(new CountingProtocol());
TestProtocol test = new TestProtocol();
test.setValue("SimpleTest");
test.setThreadPool(tp);
test.setClockPool(cp);
test.setSelectorManager(sm);
waiter.push(test);
templateStack.push(waiter);
ProtocolFactory pf = new ProtocolFactory();
pf.setClockPool(cp);
pf.setMaxAge(Long.MAX_VALUE);
pf.setMaxInactivity(1 * 60 * 60 * 1000);
pf.setReclaimPeriod(10 * 1000);
pf.setTemplate(templateStack);
ssa = new ServerSocketAcceptor();
ssa.setSelectorManager(sm);
ssa.setTimeOut(5 * 1000);
ssa.setUri(new URI("async://localhost:0/?tcp.nodelay=true&tcp.backlog=5#"));
ssa.setAcceptorListener(pf);
ssa.startup();
startLatch.release();
shutdownLatch.acquire();
ssa.drain();
pf.drain();
sm.doStop();
cp.doStop();
tp.doStop();
return null;
}