public SimulatorServerController() throws SimulatorServerException {

    // load properties from properties file
    props = new Properties();
    try {
      props.load(this.getClass().getResourceAsStream(PROPERTIES_FILE_LOCATION));
    } catch (IOException e) {
      throw new SimulatorServerException("Could not load property file.");
    }

    // get properties
    simType = props.getProperty("simType");
    port = Integer.parseInt(props.getProperty("port"));

    // try to open server socket
    try {
      serverSocket = new ServerSocket(port);
    } catch (IOException e) {
      throw new SimulatorServerException("Could not open the server socket.");
    }

    // start register socket
    registerSocket = new RegisterSocket();
    registerSocket.start();

    // try to initialize the MutliSimulatorEngine (GraphicSimulatorServer of BatchSimulatorServer)
    LOG.info("SimulatorServerEngine: " + simType);
    try {
      Class simClass = Class.forName(simType);
      SimulatorServerEngine simulator =
          (SimulatorServerEngine) simClass.getConstructor(new Class[0]).newInstance(new Object[0]);
      simulator.initialize(this);
    } catch (ClassNotFoundException e) {
      throw new SimulatorServerException(e.getMessage());
    } catch (IllegalArgumentException e) {
      throw new SimulatorServerException(e.getMessage());
    } catch (SecurityException e) {
      throw new SimulatorServerException(e.getMessage());
    } catch (InstantiationException e) {
      throw new SimulatorServerException(e.getMessage());
    } catch (IllegalAccessException e) {
      throw new SimulatorServerException(e.getMessage());
    } catch (InvocationTargetException e) {
      throw new SimulatorServerException(e.getMessage());
    } catch (NoSuchMethodException e) {
      throw new SimulatorServerException(e.getMessage());
    } catch (SimulatorServerException e) {
      throw new SimulatorServerException(e.getMessage());
    }
  }
 public void stop() {
   registerSocket.exitLoop();
 }