Пример #1
0
  /**
   * Starts the embedded <code>OpenDJ</code> instance.
   *
   * @param odsRoot File system directory where <code>OpenDJ</code> is installed.
   * @throws Exception upon encountering errors.
   */
  public static void startServer(String odsRoot) throws Exception {
    if (isStarted()) {
      return;
    }
    Debug debug = Debug.getInstance(SetupConstants.DEBUG_NAME);
    debug.message("EmbeddedOpenDS.startServer(" + odsRoot + ")");

    DirectoryEnvironmentConfig config = new DirectoryEnvironmentConfig();
    config.setServerRoot(new File(odsRoot));
    config.setForceDaemonThreads(true);
    config.setConfigClass(ConfigFileHandler.class);
    config.setConfigFile(new File(odsRoot + "/config", "config.ldif"));
    debug.message("EmbeddedOpenDS.startServer:starting DS Server...");
    EmbeddedUtils.startServer(config);
    debug.message("...EmbeddedOpenDS.startServer:DS Server started.");

    int sleepcount = 0;
    while (!EmbeddedUtils.isRunning() && (sleepcount < 60)) {
      sleepcount++;
      SetupProgress.reportStart("emb.waitingforstarted", null);
      Thread.sleep(1000);
    }

    if (EmbeddedUtils.isRunning()) {
      SetupProgress.reportEnd("emb.success", null);
    } else {
      SetupProgress.reportEnd("emb.failed", null);
    }

    serverStarted = true;

    ShutdownManager shutdownMan = com.sun.identity.common.ShutdownManager.getInstance();

    shutdownMan.addShutdownListener(
        new ShutdownListener() {
          public void shutdown() {
            try {
              shutdownServer("Graceful Shutdown");
            } catch (Exception ex) {
              Debug debug = Debug.getInstance(SetupConstants.DEBUG_NAME);
              debug.error("EmbeddedOpenDS:shutdown hook failed", ex);
            }
          }
        },
        ShutdownPriority.LOWEST);
  }
Пример #2
0
 /** Initialises OpenDJ for client use, used by the CLI tools */
 public static void initializeForClientUse() {
   EmbeddedUtils.initializeForClientUse();
 }