a default program entry point.
* / static void main (String ... args) {commander=new Commander (new ConsoleView (), args); br=new BufferedReader (new InputStreamReader (System.in)); run= true;
{. view.showDefault ();
} catch (IOException e) {. printStackTrace ();
} (run) {[] message; {= br.readLine (). getBytes (); (commander.view.readMessage (message)) {Help: commander.view.showHelp (); break; Start_Server: commander.startServer (); break; Stop_Server: commander.stopServer (); break; Undefined: commander.view.showMessage («Undefined command.»); break; Exit: run=false; break;: commander.view.showMessage («Not supported yet.»);
}
} catch (IOException e) {. printStackTrace ();
}
}
}
}com.gmail.dosofredriver.ajax.serviceserver.server;com.gmail.dosofredriver.ajax.serviceserver.server.handlers.ConnectionFilter;com.gmail.dosofredriver.ajax.serviceserver.server.pipeline.ServerPipelineFactory;com.gmail.dosofredriver.ajax.serviceserver.util.logger.ServerLogger;org.jbossty.bootstrap.ServerBootstrap;org.jbossty.channel.Channel;org.jbossty.channel.ChannelFuture;org.jbossty.channel.socket.nio.NioServerSocketChannelFactory;java.InetSocketAddress;java.util.concurrent.ExecutorService;java.util.concurrent.Executors;java.util.logging.Level;
/ **
* Date: 25.02.13
* Time: 23:47
*
* @ author DoSOfRR
* / class TCPServer {static final String DEFAULT_IP_ADDRESS=«127.0.0.1»; static final int DEFAULT_POOL_SIZE=4; static final int DEFAULT_PORT=777; ServerPipelineFactory serverPipeline; ServerBootstrap server; ServerLogger logger; Channel mainChannel; String address; boolean isStarted=false; boolean isLogged=false; int poolSize; int port; TCPServer () {(DEFAULT_PORT, DEFAULT_POOL_SIZE, DEFAULT_IP_ADDRESS);
} TCPServer (int port) {(port, DEFAULT_POOL_SIZE, DEFAULT_IP_ADDRESS);
} TCPServer (int port, int poolSize) {(port, poolSize, DEFAULT_IP_ADDRESS);
} TCPServer (int port, int poolSize, String address) {. port=port;. address=address;. poolSize=poolSize;=new ServerPipelineFactory ();
} void start () {
(! isStarted) {{bossExec=Executors.newFixedThreadPool (1); workExec=Executors.newFixedThreadPool (poolSize);=new ServerBootstrap (new NioServerSocketChannelFactory (bossExec, workExec, poolSize));. setOption ( «backlog», 500);// Todo config.setOption («connectTimeoutMillis», 10000);. SetPipelineFactory (serverPipeline);=server.bind (new InetSocketAddress (address, port));=true; (isLogged) {. Log (Level.INFO, « ; Server started on »+ port +« port. »);
}. out.println («Server started on» + port + «port.»);
} catch (Exception e) {(isLogged) {. out.println («An error occupied while starting server. See log for more info.»);. log (Level.SEVERE, «An error occupied while starting server.», e);
} else {. out.println («An error occupied while starting server. n» + e);
}
}
} else {. out.println («...