Search in sources :

Example 1 with CommandProcess

use of CommandHandler.CommandProcess in project SmartCity-Market by TechnionYP5777.

the class Main method main.

public static void main(String[] args) {
    if (!parseArguments(args))
        return;
    /* Setting log properties */
    PropertyConfigurator.configure("../log4j.properties");
    log.setLevel(verbosity);
    CommandProcess commandProcess = new CommandProcess();
    ThreadPooledServer server = null;
    try {
        server = new ThreadPooledServer(port, numOfThreads, commandProcess, serverIP);
    } catch (UnknownHostException e1) {
        log.fatal("Server IP address leads to unknown host, server won't start.");
        return;
    }
    SQLDatabaseConnection connection = new SQLDatabaseConnection();
    log.info("Disconnect from all clients");
    try {
        connection.logoutAllUsers();
        connection.close();
    } catch (CriticalError e1) {
        log.fatal("Disconnect failed");
        return;
    }
    log.info("Starting Server.");
    new Thread(server).start();
    try {
        Thread.sleep(1000 * timeout);
    } catch (InterruptedException e) {
        /* Get interrupt to stop server */
        log.info("Server Got interrupted.");
    }
    log.info("Stopping server.");
    server.stop();
}
Also used : CommandProcess(CommandHandler.CommandProcess) SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) UnknownHostException(java.net.UnknownHostException) ThreadPooledServer(ClientServerCommunication.ThreadPooledServer)

Aggregations

ThreadPooledServer (ClientServerCommunication.ThreadPooledServer)1 CommandProcess (CommandHandler.CommandProcess)1 SQLDatabaseConnection (SQLDatabase.SQLDatabaseConnection)1 CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)1 UnknownHostException (java.net.UnknownHostException)1