mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

mmarie
18.15.2008 602aba4a13a10f4758f0b411ba157234bf08a93f
Issue 3671 : [RFE] add a config completed listener
1 files added
1 files modified
98 ■■■■■ changed files
opends/src/server/org/opends/server/api/InitializationCompletedListener.java 48 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/DirectoryServer.java 50 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/api/InitializationCompletedListener.java
New file
@@ -0,0 +1,48 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 */
package org.opends.server.api;
/**
 * This interface defines a method that may be used to notify various
 * Directory Server components that the server initialization is
 * completed.
 */
@org.opends.server.types.PublicAPI(
     stability=org.opends.server.types.StabilityLevel.VOLATILE,
     mayInstantiate=false,
     mayExtend=true,
     mayInvoke=false)
public interface InitializationCompletedListener
{
  /**
   * Callback that is executed once the server
   * initialization is complete.
   */
  public void initializationCompleted();
}
opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -55,6 +55,7 @@
import org.opends.server.api.ExtendedOperationHandler;
import org.opends.server.api.IdentityMapper;
import org.opends.server.api.ImportTaskListener;
import org.opends.server.api.InitializationCompletedListener;
import org.opends.server.api.InvokableComponent;
import org.opends.server.api.KeyManagerProvider;
import org.opends.server.api.Extension;
@@ -500,6 +501,11 @@
  // The set of restore task listeners registered with the Directory Server.
  private CopyOnWriteArrayList<RestoreTaskListener> restoreTaskListeners;
  // The set of initialization completed listeners that have been registered
  // with the Directory Server.
  private CopyOnWriteArrayList<InitializationCompletedListener>
          initializationCompletedListeners;
  // The set of shutdown listeners that have been registered with the Directory
  // Server.
  private CopyOnWriteArrayList<ServerShutdownListener> shutdownListeners;
@@ -934,6 +940,8 @@
      directoryServer.baseDnRegistry = new BaseDnRegistry();
      directoryServer.changeNotificationListeners =
           new CopyOnWriteArrayList<ChangeNotificationListener>();
      directoryServer.initializationCompletedListeners =
           new CopyOnWriteArrayList<InitializationCompletedListener>();
      directoryServer.shutdownListeners =
           new CopyOnWriteArrayList<ServerShutdownListener>();
      directoryServer.synchronizationProviders =
@@ -1442,7 +1450,6 @@
      // startup plugins.
      initializePlugins();
      // Initialize any synchronization providers that may be defined.
      if (!environmentConfig.disableSynchronization())
      {
@@ -1452,8 +1459,6 @@
            .initializeSynchronizationProviders();
      }
      // Create and initialize the work queue.
      workQueue = new WorkQueueConfigManager().initializeWorkQueue();
@@ -1468,6 +1473,22 @@
        throw new InitializationException(message);
      }
     // Notify all the initialization completed listeners.
      for (InitializationCompletedListener initializationCompletedListener :
        directoryServer.initializationCompletedListeners)
        {
        try
        {
          initializationCompletedListener.initializationCompleted();
        }
        catch (Exception e)
        {
          if (debugEnabled())
          {
            TRACER.debugCaught(DebugLogLevel.ERROR, e);
          }
        }
      }
      // Start administration connector and connection handlers
      if (startConnectionHandlers)
@@ -7894,7 +7915,30 @@
    }
  }
  /**
   * Registers the provided initialization completed listener with the
   * Directory Server so that it will be notified when the server
   * initialization completes.
   *
   * @param  listener  The initialization competed listener to register with
   *                   the Directory Server.
   */
  public static void registerInitializationCompletedListener(
          InitializationCompletedListener listener) {
    directoryServer.initializationCompletedListeners.add(listener);
  }
  /**
   * Deregisters the provided nitialization completed listener with the
   * Directory Server.
   *
   * @param  listener  The nitialization completed listener to deregister with
   *                   the Directory Server.
   */
  public static void deregisterInitializationCompletedListener(
          InitializationCompletedListener listener) {
    directoryServer.initializationCompletedListeners.remove(listener);
  }
  /**
   * Registers the provided shutdown listener with the Directory Server so that