示例#1
0
  public Backend() throws IOException, SQLException, ClassNotFoundException {
    SDConfig config = SDConfig.getInstance();

    context = ZMQ.context(1);

    keyManager = new H2KeyManager();
    dispatcher = new PublishDispatcher(context);
    RequestManager requestManager =
        new RequestManager(
            dispatcher,
            "",
            config.getSignRequestEnvelope(),
            config.getKeyManagementEnvelope() // TODO: Put this in config file.
            );

    methodCollector =
        new MethodCollector(
            ZMQ.context(1),
            new MethodFactoryImpl(
                new SessionManagerImpl(),
                new SessionFactoryImpl(keyManager, requestManager),
                new KeyOperationsImpl(config.getK(), config.getL(), requestManager, keyManager)));

    resultsCollector = new ResultsCollector(context, requestManager);

    methodCollector.start();
    resultsCollector.start();

    running = true;

    TSLogger.sd.info("Initialization: Done");
  }
示例#2
0
  private synchronized void stopServer() {
    running = false;
    this.notifyAll();

    try {
      resultsCollector.stop();
      methodCollector.stop();
    } catch (InterruptedException e) {
      TSLogger.sd.fatal("Error while closing...");
    }
    try {
      dispatcher.close();
      keyManager.close();
      context.term();
    } catch (IOException e) {
      TSLogger.sd.fatal("Error while closing...");
    }
  }