示例#1
0
  /**
   * create the singelton EventService object if it doesn't exist already. Check if directory server
   * supports the Persistent Search Control and the Proxy Auth Control
   *
   * @supported.api
   */
  public static synchronized EventService getEventService() throws EventException, LDAPException {

    if (_shutdownCalled) {
      return null;
    }

    // Make sure only one instance of this class is created.
    if (_instance == null) {
      // Determine the Idle time out value for Event Service (LB/Firewall)
      // scenarios. Value == 0 imples no idle timeout.
      _idleTimeOut = getPropertyIntValue(EVENT_IDLE_TIMEOUT_INTERVAL, _idleTimeOut);
      _idleTimeOutMills = _idleTimeOut * 60000;
      ShutdownManager shutdownMan = ShutdownManager.getInstance();
      if (shutdownMan.acquireValidLock()) {
        try {
          if (_idleTimeOut == 0) {
            _instance = new EventService();
          } else {
            _instance = new EventServicePolling();
          }
          shutdownMan.addShutdownListener(
              new ShutdownListener() {
                public void shutdown() {
                  if (_instance != null) {
                    _instance.finalize();
                  }
                }
              });
        } finally {
          shutdownMan.releaseLockAndNotify();
        }
      }
    }
    return _instance;
  }
示例#2
0
 public void destroy() {
   ShutdownManager shutdownMan = ShutdownManager.getInstance();
   if (shutdownMan.acquireValidLock()) {
     try {
       shutdownMan.shutdown();
     } finally {
       shutdownMan.releaseLockAndNotify();
     }
   }
 }
示例#3
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);
  }