From d80f86a08f6955e0c623a80357c8481b38e92d61 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 28 Sep 2009 15:33:19 +0000
Subject: [PATCH] Fix issue 4043 - intermittent failures in ACI unit tests

---
 opends/src/server/org/opends/server/core/DirectoryServer.java |   64 +++++++++++++++++++++-----------
 1 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index 52f3984..62d23f2 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -123,6 +123,7 @@
 import org.opends.server.api.SynchronizationProvider;
 import org.opends.server.api.TrustManagerProvider;
 import org.opends.server.api.WorkQueue;
+import org.opends.server.api.plugin.InternalDirectoryServerPlugin;
 import org.opends.server.api.plugin.PluginResult;
 import org.opends.server.api.plugin.PluginType;
 import org.opends.server.api.ExtensibleMatchingRule;
@@ -1341,6 +1342,11 @@
       initializeSchema();
 
 
+      // Initialize the plugin manager so that internal plugins can be
+      // registered.
+      pluginConfigManager.initializePluginConfigManager();
+
+
       // Initialize all the virtual attribute handlers.
       initializeVirtualAttributes();
 
@@ -1474,9 +1480,8 @@
       initializePasswordPolicyComponents();
 
 
-      // Load and initialize all the plugins, and then call the registered
-      // startup plugins.
-      initializePlugins();
+      // Load and initialize the user plugins.
+      pluginConfigManager.initializeUserPlugins(null);
 
       // Initialize any synchronization providers that may be defined.
       if (!environmentConfig.disableSynchronization())
@@ -1491,6 +1496,7 @@
       workQueue = new WorkQueueConfigManager().initializeWorkQueue();
 
 
+      // Invoke the startup plugins.
       PluginResult.Startup startupPluginResult =
            pluginConfigManager.invokeStartupPlugins();
       if (! startupPluginResult.continueProcessing())
@@ -2906,24 +2912,6 @@
 
 
   /**
-   * Initializes the set of plugins defined in the Directory Server.
-   *
-   * @throws  ConfigException  If there is a configuration problem with any of
-   *                           the Directory Server plugins.
-   *
-   * @throws  InitializationException  If a problem occurs while initializing
-   *                                   the plugins that is not related to the
-   *                                   server configuration.
-   */
-  public void initializePlugins()
-         throws ConfigException, InitializationException
-  {
-    pluginConfigManager.initializePluginConfig(null);
-  }
-
-
-
-  /**
    * Initializes the set of plugins defined in the Directory Server.  Only the
    * specified types of plugins will be initialized.
    *
@@ -2941,7 +2929,8 @@
          throws ConfigException, InitializationException
   {
     pluginConfigManager = new PluginConfigManager();
-    pluginConfigManager.initializePluginConfig(pluginTypes);
+    pluginConfigManager.initializePluginConfigManager();
+    pluginConfigManager.initializeUserPlugins(pluginTypes);
   }
 
 
@@ -3005,6 +2994,37 @@
 
 
   /**
+   * Registers the provided internal plugin with the Directory Server
+   * and ensures that it will be invoked in the specified ways.
+   *
+   * @param plugin
+   *          The internal plugin to register with the Directory Server.
+   *          The plugin must specify a configuration entry which is
+   *          guaranteed to be unique.
+   */
+  public static void registerInternalPlugin(
+      InternalDirectoryServerPlugin plugin)
+  {
+    directoryServer.pluginConfigManager.registerInternalPlugin(plugin);
+  }
+
+
+
+  /**
+   * Deregisters the provided internal plugin with the Directory Server.
+   *
+   * @param plugin
+   *          The internal plugin to deregister from the Directory Server.
+   */
+  public static void deregisterInternalPlugin(
+      InternalDirectoryServerPlugin plugin)
+  {
+    directoryServer.pluginConfigManager.deregisterInternalPlugin(plugin);
+  }
+
+
+
+  /**
    * Retrieves the requested entry from the Directory Server configuration.
    *
    * @param  entryDN  The DN of the configuration entry to retrieve.

--
Gitblit v1.10.0