From aaf1f09351c43d52009c6b53b93eb153ace8428e Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 07 Nov 2016 15:05:30 +0000
Subject: [PATCH] OPENDJ-3417 Remove several backend-related methods from DirectoryServer class

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java                                     |    4 
 opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java                                            |   13 
 opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java                           |   11 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/FIFOEntryCache.java                                   |    3 
 opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java                             |    4 
 opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java                                   |   12 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/ExactMatchIdentityMapper.java                         |    9 
 opendj-server-legacy/src/test/java/org/opends/server/core/BackendConfigManagerTestCase.java                           |   60 +++--
 opendj-server-legacy/src/test/java/org/opends/server/extensions/FIFOEntryCacheTestCase.java                           |    7 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectDNToUserAttributeCertificateMapper.java        |    5 
 opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java                                |    3 
 opendj-server-legacy/src/test/java/org/opends/server/replication/DependencyTest.java                                  |    4 
 opendj-server-legacy/src/test/java/org/opends/server/tasks/TasksTestCase.java                                         |    5 
 opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java  |    3 
 opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java                                            |    2 
 opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java                          |    5 
 opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java                     |    4 
 opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java                                            |    2 
 opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java                           |    2 
 opendj-server-legacy/src/test/java/org/opends/server/backends/LDIFBackendTestCase.java                                |    2 
 opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java                                     |    4 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProvider.java          |   11 
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java                    |    4 
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java                 |    5 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/FingerprintCertificateMapper.java                     |    9 
 opendj-server-legacy/src/main/java/org/opends/server/tasks/RestoreTask.java                                           |    4 
 opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java                                        |  147 --------------
 opendj-server-legacy/src/test/java/org/forgerock/server/embedded/EmbeddedDirectoryServerTestCase.java                 |    8 
 opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java                                   |    3 
 opendj-server-legacy/src/main/java/org/opends/server/tasks/RebuildTask.java                                           |    3 
 opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java                                            |    4 
 opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java                        |   11 
 opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java                               |    9 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/RegularExpressionIdentityMapper.java                  |    9 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/SoftReferenceEntryCache.java                          |    3 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProvider.java          |    9 
 opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java                                               |   16 
 opendj-server-legacy/src/test/java/org/opends/server/core/DeleteOperationTestCase.java                                |   12 
 opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java                                    |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java                                            |    2 
 opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java                                   |   62 +++++
 opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java   |    3 
 opendj-server-legacy/src/test/java/org/opends/server/extensions/CommonEntryCacheTestCase.java                         |   44 ++-
 opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java    |    4 
 opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java                              |    3 
 opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java                                |   14 
 opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java                                          |    2 
 opendj-server-legacy/src/test/java/org/opends/server/extensions/DefaultEntryCacheTestCase.java                        |    3 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapper.java |    9 
 opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java                                    |    3 
 50 files changed, 295 insertions(+), 287 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java
index b12ff9b..25ac9d9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java
@@ -25,7 +25,6 @@
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
-
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.ldap.DN;
@@ -40,6 +39,7 @@
 import org.opends.server.api.plugin.PluginResult.PostOperation;
 import org.opends.server.api.plugin.PluginType;
 import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.ServerContext;
 import org.opends.server.protocols.internal.InternalSearchOperation;
 import org.opends.server.protocols.internal.SearchRequest;
 import org.opends.server.protocols.ldap.LDAPControl;
@@ -309,7 +309,8 @@
     this.plugin = new AciChangeListenerPlugin();
 
     // Process ACI from already registered backends.
-    for (LocalBackend<?> backend : DirectoryServer.getBackends())
+    ServerContext serverContext = DirectoryServer.getInstance().getServerContext();
+    for (LocalBackend<?> backend : serverContext.getBackendConfigManager().getLocalBackends())
     {
       performBackendPreInitializationProcessing(backend);
     }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java
index 95c62c0..40e767a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java
@@ -241,7 +241,8 @@
   @Deprecated
   public static ChangelogBackend getInstance()
   {
-    return (ChangelogBackend) DirectoryServer.getLocalBackend(CHANGELOG_BASE_DN);
+    return (ChangelogBackend) DirectoryServer.getInstance().getServerContext().getBackendConfigManager()
+        .getLocalBackend(CHANGELOG_BASE_DN);
   }
 
   @Override
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
index 4b235a8..29f9206 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -680,7 +680,7 @@
       {
         for (DN baseDN : subDNs)
         {
-          LocalBackend<?> backend = DirectoryServer.getLocalBackend(baseDN);
+          LocalBackend<?> backend = serverContext.getBackendConfigManager().getLocalBackend(baseDN);
           if (backend == null)
           {
             unacceptableReasons.add(WARN_ROOTDSE_NO_BACKEND_FOR_SUBORDINATE_BASE.get(baseDN));
@@ -721,7 +721,7 @@
         subBases = new ConcurrentHashMap<>();
         for (DN baseDN : subDNs)
         {
-          LocalBackend<?> backend = DirectoryServer.getLocalBackend(baseDN);
+          LocalBackend<?> backend = serverContext.getBackendConfigManager().getLocalBackend(baseDN);
           if (backend == null)
           {
             // This is not fine.  We can't use a suffix that doesn't exist.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
index 67e78f5..42154c1 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
@@ -51,10 +51,12 @@
 import org.forgerock.opendj.server.config.server.BackendCfg;
 import org.forgerock.opendj.server.config.server.LocalBackendCfg;
 import org.forgerock.opendj.server.config.server.RootCfg;
+import org.forgerock.opendj.server.config.server.RootDSEBackendCfg;
 import org.opends.server.api.LocalBackend;
 import org.opends.server.api.Backend;
 import org.opends.server.api.LocalBackendInitializationListener;
 import org.opends.server.backends.ConfigurationBackend;
+import org.opends.server.backends.RootDSEBackend;
 import org.opends.server.config.ConfigConstants;
 import org.opends.server.monitors.LocalBackendMonitor;
 import org.opends.server.types.DirectoryException;
@@ -87,6 +89,8 @@
   private final ServerContext serverContext;
   private final BaseDnRegistry localBackendsRegistry;
 
+  private RootDSEBackend rootDSEBackend;
+
   /** Lock to protect reads of the backend maps. */
   private final ReadLock readLock;
   /** Lock to protect updates of the backends maps. */
@@ -159,6 +163,32 @@
   }
 
   /**
+   * Creates and initializes the Root DSE backend.
+   *
+   * @throws InitializationException
+   *            If the configuration entry can't be found
+   * @throws ConfigException
+   *            If an error occurs during configuration
+   */
+  public void initializeRootDSEBackend() throws InitializationException, ConfigException
+  {
+    RootDSEBackendCfg rootDSECfg;
+    try
+    {
+      rootDSECfg = serverContext.getRootConfig().getRootDSEBackend();
+    }
+    catch (Exception e)
+    {
+      logger.traceException(e);
+      throw new InitializationException(ERR_CANNOT_GET_ROOT_DSE_CONFIG_ENTRY.get(
+          stackTraceToSingleLineString(e)), e);
+    }
+    rootDSEBackend = new RootDSEBackend();
+    rootDSEBackend.configureBackend(rootDSECfg, serverContext);
+    rootDSEBackend.openBackend();
+  }
+
+  /**
    * Initializes specified backends. If a backend has been already initialized, do nothing.
    * This should only be called at Directory Server startup, after #initializeBackendConfig()
    *
@@ -373,6 +403,16 @@
   }
 
   /**
+   * Retrieves the Root DSE backend.
+   *
+   * @return the Root DSE backend.
+   */
+  public RootDSEBackend getRootDSEBackend()
+  {
+    return rootDSEBackend;
+  }
+
+  /**
    * Retrieves the local backend and the corresponding baseDN that should be used to handle operations
    * on the specified entry.
    *
@@ -381,9 +421,25 @@
    * @return The local backend with its matching base DN or {@code null} if no appropriate backend
    *         is registered with the server.
    */
-  public BackendAndName getLocalBackend(DN entryDN)
+  public BackendAndName getLocalBackendAndName(DN entryDN)
   {
-    return localBackendsRegistry.getBackendAndName(entryDN);
+    return entryDN.isRootDN() ?
+        new BackendAndName(getRootDSEBackend(), entryDN) : localBackendsRegistry.getBackendAndName(entryDN);
+  }
+
+  /**
+   * Retrieves the local backend that should be used to handle operations
+   * on the specified entry.
+   *
+   * @param entryDN
+   *          The DN of the entry for which to retrieve the corresponding backend.
+   * @return The local backend or {@code null} if no appropriate backend
+   *         is registered with the server.
+   */
+  public LocalBackend<?> getLocalBackend(DN entryDN)
+  {
+    BackendAndName backend = getLocalBackendAndName(entryDN);
+    return backend != null ? backend.getBackend() : null;
   }
 
   /**
@@ -1140,7 +1196,7 @@
       }
 
       registeredBackends.remove(backendDN);
-      DirectoryServer.deregisterBackend(localBackend);
+      deregisterLocalBackend(localBackend);
 
       for (LocalBackendInitializationListener listener : initializationListeners)
       {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
index 1a1f225..c973ac6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -73,7 +73,6 @@
 import org.forgerock.opendj.server.config.server.MonitorProviderCfg;
 import org.forgerock.opendj.server.config.server.PasswordValidatorCfg;
 import org.forgerock.opendj.server.config.server.RootCfg;
-import org.forgerock.opendj.server.config.server.RootDSEBackendCfg;
 import org.forgerock.opendj.server.config.server.SynchronizationProviderCfg;
 import org.forgerock.util.Reject;
 import org.opends.server.admin.AdministrationDataSync;
@@ -111,14 +110,12 @@
 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.backends.ConfigurationBackend;
 import org.opends.server.backends.RootDSEBackend;
 import org.opends.server.config.AdministrationConnector;
 import org.opends.server.config.ConfigurationHandler;
 import org.opends.server.config.JMXMBean;
 import org.opends.server.controls.PasswordPolicyErrorType;
 import org.opends.server.controls.PasswordPolicyResponseControl;
-import org.opends.server.core.BackendConfigManager.BackendAndName;
 import org.opends.server.crypto.CryptoManagerImpl;
 import org.opends.server.crypto.CryptoManagerSync;
 import org.opends.server.extensions.DiskSpaceMonitor;
@@ -551,8 +548,6 @@
   /** The result code that should be used for internal "server" errors. */
   private ResultCode serverErrorResultCode;
 
-  /** The special backend used for the Directory Server root DSE. */
-  private RootDSEBackend rootDSEBackend;
   /** The root DN config manager for the server. */
   private RootDNConfigManager rootDNConfigManager;
 
@@ -1730,11 +1725,6 @@
     return directoryServer.compressedSchema;
   }
 
-  private LocalBackend<?> getConfigurationBackend()
-  {
-    return getBackend(ConfigurationBackend.CONFIG_BACKEND_ID);
-  }
-
   /**
    * Registers the provided local backend initialization listener with the Directory
    * Server.
@@ -1764,22 +1754,7 @@
   private void initializeRootAndAdminDataBackends() throws ConfigException, InitializationException
   {
     backendConfigManager.initializeBackendConfig(Arrays.asList("adminRoot", "ads-truststore"));
-
-    RootDSEBackendCfg rootDSECfg;
-    try
-    {
-      rootDSECfg = serverContext.getRootConfig().getRootDSEBackend();
-    }
-    catch (Exception e)
-    {
-      logger.traceException(e);
-      throw new InitializationException(ERR_CANNOT_GET_ROOT_DSE_CONFIG_ENTRY.get(
-          stackTraceToSingleLineString(e)), e);
-    }
-
-    rootDSEBackend = new RootDSEBackend();
-    rootDSEBackend.configureBackend(rootDSECfg, serverContext);
-    rootDSEBackend.openBackend();
+    backendConfigManager.initializeRootDSEBackend();
   }
 
   private void initializeRemainingBackends() throws ConfigException, InitializationException
@@ -3367,110 +3342,6 @@
   }
 
   /**
-   * Retrieves the set of local backends that have been registered with the Directory
-   * Server.
-   *
-   * @return  The set of local backends that have been registered with the Directory
-   *          Server.
-   */
-  public static Collection<LocalBackend<?>> getBackends()
-  {
-    return directoryServer.backendConfigManager.getLocalBackends();
-  }
-
-  /**
-   * Retrieves the backend with the specified backend ID.
-   *
-   * @param  backendID  The backend ID of the backend to retrieve.
-   *
-   * @return  The backend with the specified backend ID, or {@code null} if
-   *          there is none.
-   */
-  public static LocalBackend<?> getBackend(String backendID)
-  {
-    return directoryServer.backendConfigManager.getLocalBackend(backendID);
-  }
-
-  /**
-   * Indicates whether the Directory Server has a backend with the specified
-   * backend ID.
-   *
-   * @param  backendID  The backend ID for which to make the determination.
-   *
-   * @return  {@code true} if the Directory Server has a backend with the
-   *          specified backend ID, or {@code false} if not.
-   */
-  public static boolean hasBackend(String backendID)
-  {
-    return directoryServer.backendConfigManager.hasLocalBackend(backendID);
-  }
-
-  /**
-   * Registers the provided backend with the Directory Server.  Note that this
-   * will not register the set of configured suffixes with the server, as that
-   * must be done by the backend itself.
-   *
-   * @param  backend  The backend to register with the server.  Neither the
-   *                  backend nor its backend ID may be null.
-   *
-   * @throws  DirectoryException  If the backend ID for the provided backend
-   *                              conflicts with the backend ID of an existing
-   *                              backend.
-   */
-  public static void registerBackend(LocalBackend<?> backend) throws DirectoryException
-  {
-    directoryServer.backendConfigManager.registerLocalBackend(backend);
-  }
-
-  /**
-   * Deregisters the provided backend with the Directory Server.  Note that this
-   * will not deregister the set of configured suffixes with the server, as that
-   * must be done by the backend itself.
-   *
-   * @param  backend  The backend to deregister with the server.  It must not be
-   *                  {@code null}.
-   */
-  public static void deregisterBackend(LocalBackend<?> backend)
-  {
-    directoryServer.backendConfigManager.deregisterLocalBackend(backend);
-  }
-
-  /**
-   * Retrieves the local backend with the specified base DN.
-   *
-   * @param  baseDN  The DN that is registered as one of the base DNs for the
-   *                 backend to retrieve.
-   *
-   * @return  The local backend with the specified base DN, or {@code null} if there
-   *          is no local backend registered with the specified base DN.
-   */
-  public static LocalBackend<?> getLocalBackendWithBaseDN(DN baseDN)
-  {
-    return directoryServer.backendConfigManager.getLocalBackendWithBaseDN(baseDN);
-  }
-
-  /**
-   * Retrieves the local backend that should be used to handle operations on the
-   * specified entry.
-   *
-   * @param  entryDN  The DN of the entry for which to retrieve the
-   *                  corresponding backend.
-   *
-   * @return  The backend that should be used to handle operations on the
-   *          specified entry, or {@code null} if no appropriate backend is
-   *          registered with the server.
-   */
-  public static LocalBackend<?> getLocalBackend(DN entryDN)
-  {
-    if (entryDN.isRootDN())
-    {
-      return directoryServer.rootDSEBackend;
-    }
-    BackendAndName backend = directoryServer.backendConfigManager.getLocalBackend(entryDN);
-    return backend != null ? backend.getBackend() : null;
-  }
-
-  /**
    * Retrieves the set of public naming contexts defined in the Directory
    * Server, mapped from the naming context DN to the corresponding backend.
    *
@@ -3534,7 +3405,7 @@
    */
   public static Entry getRootDSE()
   {
-    return directoryServer.rootDSEBackend.getRootDSE();
+    return getRootDSEBackend().getRootDSE();
   }
 
   /**
@@ -3544,7 +3415,7 @@
    */
   public static RootDSEBackend getRootDSEBackend()
   {
-    return directoryServer.rootDSEBackend;
+    return directoryServer.backendConfigManager.getRootDSEBackend();
   }
 
   /**
@@ -3585,9 +3456,9 @@
   {
     if (entryDN.isRootDN())
     {
-      return directoryServer.rootDSEBackend.getRootDSE();
+      return directoryServer.backendConfigManager.getRootDSEBackend().getRootDSE();
     }
-    final LocalBackend<?> backend = getLocalBackend(entryDN);
+    final LocalBackend<?> backend = directoryServer.backendConfigManager.getLocalBackend(entryDN);
     return backend != null ? backend.getEntry(entryDN) : null;
   }
 
@@ -3614,7 +3485,7 @@
 
     // Ask the appropriate backend if the entry exists.
     // If it is not appropriate for any backend, then return false.
-    LocalBackend<?> backend = getLocalBackend(entryDN);
+    LocalBackend<?> backend = directoryServer.backendConfigManager.getLocalBackend(entryDN);
     return backend != null && backend.entryExists(entryDN);
   }
 
@@ -4970,12 +4841,6 @@
     directoryServer = getNewInstance(envConfig);
   }
 
-  /** Shutdown directory server backends. */
-  public static void shutdownBackends()
-  {
-    directoryServer.backendConfigManager.shutdownLocalBackends();
-  }
-
   /**
    * Destroy key structures in the current Directory Server instance in a manner
    * that can help detect any inappropriate cached references to server
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
index 23eb373..d5e9ed2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
@@ -427,7 +427,7 @@
   private TrustStoreBackend getTrustStoreBackend()
        throws ConfigException
   {
-    LocalBackend<?> b = DirectoryServer.getBackend(ID_ADS_TRUST_STORE_BACKEND);
+    LocalBackend<?> b = serverContext.getBackendConfigManager().getLocalBackend(ID_ADS_TRUST_STORE_BACKEND);
     if (b == null)
     {
       throw new ConfigException(ERR_CRYPTOMGR_ADS_TRUST_STORE_BACKEND_NOT_ENABLED.get(ID_ADS_TRUST_STORE_BACKEND));
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
index 0807e77..ea1050c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
@@ -163,7 +163,8 @@
     attrAlias = getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID);
     attrCompromisedTime = getSchema().getAttributeType(ATTR_CRYPTO_KEY_COMPROMISED_TIME);
 
-    if (DirectoryServer.getLocalBackendWithBaseDN(adminSuffixDN) != null)
+    if (DirectoryServer.getInstance().getServerContext()
+          .getBackendConfigManager().getLocalBackendWithBaseDN(adminSuffixDN) != null)
     {
       searchAdminSuffix();
     }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/ExactMatchIdentityMapper.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/ExactMatchIdentityMapper.java
index c0fee94..b53c32d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/ExactMatchIdentityMapper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/ExactMatchIdentityMapper.java
@@ -36,6 +36,7 @@
 import org.forgerock.opendj.server.config.server.IdentityMapperCfg;
 import org.opends.server.api.LocalBackend;
 import org.opends.server.api.IdentityMapper;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
 import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -107,11 +108,13 @@
       cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet();
     }
 
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (AttributeType t : attributeTypes)
     {
       for (DN baseDN : cfgBaseDNs)
       {
-        LocalBackend b = DirectoryServer.getLocalBackend(baseDN);
+        LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
         if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
         {
           throw new ConfigException(ERR_EXACTMAP_ATTR_UNINDEXED.get(
@@ -270,11 +273,13 @@
       cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet();
     }
 
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (AttributeType t : configuration.getMatchAttribute())
     {
       for (DN baseDN : cfgBaseDNs)
       {
-        LocalBackend b = DirectoryServer.getLocalBackend(baseDN);
+        LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
         if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
         {
           unacceptableReasons.add(ERR_EXACTMAP_ATTR_UNINDEXED.get(
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/FIFOEntryCache.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/FIFOEntryCache.java
index 5f24ce5..3db10ea 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/FIFOEntryCache.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/FIFOEntryCache.java
@@ -600,7 +600,8 @@
   {
     // Determine which backend should be used for the provided base DN.  If
     // there is none, then we don't need to do anything.
-    LocalBackend<?> backend = DirectoryServer.getLocalBackend(baseDN);
+    LocalBackend<?> backend =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(baseDN);
     if (backend == null)
     {
       return;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/FingerprintCertificateMapper.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/FingerprintCertificateMapper.java
index 06bb0a4..14c421b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/FingerprintCertificateMapper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/FingerprintCertificateMapper.java
@@ -40,6 +40,7 @@
 import org.forgerock.opendj.server.config.server.FingerprintCertificateMapperCfg;
 import org.opends.server.api.LocalBackend;
 import org.opends.server.api.CertificateMapper;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
 import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -116,9 +117,11 @@
     }
 
     AttributeType t = configuration.getFingerprintAttribute();
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (DN baseDN : cfgBaseDNs)
     {
-      LocalBackend<?> b = DirectoryServer.getLocalBackend(baseDN);
+      LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
       if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
       {
         logger.warn(WARN_SATUACM_ATTR_UNINDEXED, configuration.dn(),
@@ -315,9 +318,11 @@
     }
 
     AttributeType t = configuration.getFingerprintAttribute();
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (DN baseDN : cfgBaseDNs)
     {
-      LocalBackend<?> b = DirectoryServer.getLocalBackend(baseDN);
+      LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
       if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
       {
         LocalizableMessage message = WARN_SATUACM_ATTR_UNINDEXED.get(
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProvider.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProvider.java
index e20dec4..4c53420 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProvider.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProvider.java
@@ -60,7 +60,8 @@
   @Override
   public Attribute getValues(Entry entry, VirtualAttributeRule rule)
   {
-    LocalBackend backend = DirectoryServer.getLocalBackend(entry.getName());
+    LocalBackend<?> backend =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(entry.getName());
 
     try
     {
@@ -81,7 +82,8 @@
   @Override
   public boolean hasValue(Entry entry, VirtualAttributeRule rule)
   {
-    LocalBackend backend = DirectoryServer.getLocalBackend(entry.getName());
+    LocalBackend<?> backend =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(entry.getName());
 
     try
     {
@@ -99,7 +101,8 @@
   @Override
   public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value)
   {
-    LocalBackend backend = DirectoryServer.getLocalBackend(entry.getName());
+    LocalBackend<?> backend =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(entry.getName());
     MatchingRule matchingRule =
         rule.getAttributeType().getEqualityMatchingRule();
 
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProvider.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProvider.java
index 1acb14f..c6844d2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProvider.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProvider.java
@@ -60,8 +60,8 @@
   @Override
   public Attribute getValues(Entry entry, VirtualAttributeRule rule)
   {
-    LocalBackend backend = DirectoryServer.getLocalBackend(entry.getName());
-
+    LocalBackend<?> backend =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(entry.getName());
     try
     {
       long count = backend.getNumberOfChildren(entry.getName());
@@ -81,8 +81,8 @@
   @Override
   public boolean hasValue(Entry entry, VirtualAttributeRule rule)
   {
-    LocalBackend<?> backend = DirectoryServer.getLocalBackend(entry.getName());
-
+    LocalBackend<?> backend =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(entry.getName());
     try
     {
        return backend.getNumberOfChildren(entry.getName()) >= 0;
@@ -97,7 +97,8 @@
   @Override
   public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value)
   {
-    LocalBackend<?> backend = DirectoryServer.getLocalBackend(entry.getName());
+    LocalBackend<?> backend =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(entry.getName());
     try
     {
       long count = backend.getNumberOfChildren(entry.getName());
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/RegularExpressionIdentityMapper.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/RegularExpressionIdentityMapper.java
index cb02007..330f99b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/RegularExpressionIdentityMapper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/RegularExpressionIdentityMapper.java
@@ -44,6 +44,7 @@
 import org.forgerock.opendj.server.config.server.RegularExpressionIdentityMapperCfg;
 import org.opends.server.api.LocalBackend;
 import org.opends.server.api.IdentityMapper;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
 import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -134,11 +135,13 @@
       cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet();
     }
 
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (AttributeType t : attributeTypes)
     {
       for (DN baseDN : cfgBaseDNs)
       {
-        LocalBackend b = DirectoryServer.getLocalBackend(baseDN);
+        LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
         if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
         {
           throw new ConfigException(ERR_REGEXMAP_ATTR_UNINDEXED.get(
@@ -287,11 +290,13 @@
       cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet();
     }
 
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (AttributeType t : configuration.getMatchAttribute())
     {
       for (DN baseDN : cfgBaseDNs)
       {
-        LocalBackend b = DirectoryServer.getLocalBackend(baseDN);
+        LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
         if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
         {
           unacceptableReasons.add(ERR_REGEXMAP_ATTR_UNINDEXED.get(
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SoftReferenceEntryCache.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SoftReferenceEntryCache.java
index 30b8c87..39386c0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SoftReferenceEntryCache.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SoftReferenceEntryCache.java
@@ -327,7 +327,8 @@
   public void clearSubtree(DN baseDN)
   {
     // Determine the backend used to hold the specified base DN and clear it.
-    LocalBackend<?> backend = DirectoryServer.getLocalBackend(baseDN);
+    LocalBackend<?> backend =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(baseDN);
     if (backend == null)
     {
       // FIXME -- Should we clear everything just to be safe?
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapper.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapper.java
index 3fb0635..bc16033 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapper.java
@@ -50,6 +50,7 @@
 import org.forgerock.opendj.server.config.server.SubjectAttributeToUserAttributeCertificateMapperCfg;
 import org.opends.server.api.LocalBackend;
 import org.opends.server.api.CertificateMapper;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
 import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -115,11 +116,13 @@
     // Make sure that all the user attributes are configured with equality
     // indexes in all appropriate backends.
     Set<DN> cfgBaseDNs = getUserBaseDNs(configuration);
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (DN baseDN : cfgBaseDNs)
     {
       for (AttributeType t : attributeMap.values())
       {
-        LocalBackend<?> b = DirectoryServer.getLocalBackend(baseDN);
+        LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
         if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
         {
           logger.warn(WARN_SATUACM_ATTR_UNINDEXED, configuration.dn(),
@@ -292,11 +295,13 @@
     // Make sure that all the user attributes are configured with equality
     // indexes in all appropriate backends.
     Set<DN> cfgBaseDNs = getUserBaseDNs(configuration);
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (DN baseDN : cfgBaseDNs)
     {
       for (AttributeType t : newAttributeMap.values())
       {
-        LocalBackend<?> b = DirectoryServer.getLocalBackend(baseDN);
+        LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
         if (b != null && !b.isIndexed(t, IndexType.EQUALITY))
         {
           LocalizableMessage message =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectDNToUserAttributeCertificateMapper.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectDNToUserAttributeCertificateMapper.java
index 661b0c7..a6fc535 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectDNToUserAttributeCertificateMapper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectDNToUserAttributeCertificateMapper.java
@@ -39,6 +39,7 @@
 import org.forgerock.opendj.server.config.server.SubjectDNToUserAttributeCertificateMapperCfg;
 import org.opends.server.api.LocalBackend;
 import org.opends.server.api.CertificateMapper;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
 import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -103,9 +104,11 @@
     }
 
     AttributeType t = configuration.getSubjectAttribute();
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (DN baseDN : cfgBaseDNs)
     {
-      LocalBackend b = DirectoryServer.getLocalBackend(baseDN);
+      LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
       if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
       {
         logger.warn(WARN_SATUACM_ATTR_UNINDEXED, configuration.dn(),
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
index bb58889..fa785df 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -61,6 +61,7 @@
 import org.opends.server.api.plugin.DirectoryServerPlugin;
 import org.opends.server.api.plugin.PluginResult;
 import org.opends.server.api.plugin.PluginType;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DeleteOperation;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.core.ModifyOperation;
@@ -295,9 +296,11 @@
                              type.getSyntax().getName()));
       }
 
+      BackendConfigManager backendConfigManager =
+          DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
       for (DN baseDN : cfgBaseDNs)
       {
-        LocalBackend<?> b = DirectoryServer.getLocalBackend(baseDN);
+        LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
         if (b != null && !b.isIndexed(type, IndexType.EQUALITY))
         {
           isAcceptable = false;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java
index 52e2b5d..1a04a0f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java
@@ -46,6 +46,7 @@
 import org.opends.server.api.plugin.PluginResult.PostOperation;
 import org.opends.server.api.plugin.PluginResult.PreOperation;
 import org.opends.server.api.plugin.PluginType;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
 import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -154,11 +155,13 @@
       cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet();
     }
 
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (AttributeType t : configuration.getType())
     {
       for (DN baseDN : cfgBaseDNs)
       {
-        LocalBackend<?> b = DirectoryServer.getLocalBackend(baseDN);
+        LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
         if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
         {
           throw new ConfigException(ERR_PLUGIN_UNIQUEATTR_ATTR_UNINDEXED.get(
@@ -686,11 +689,13 @@
       cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet();
     }
 
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
     for (AttributeType t : configuration.getType())
     {
       for (DN baseDN : cfgBaseDNs)
       {
-        LocalBackend<?> b = DirectoryServer.getLocalBackend(baseDN);
+        LocalBackend<?> b = backendConfigManager.getLocalBackend(baseDN);
         if (b != null && ! b.isIndexed(t, IndexType.EQUALITY))
         {
           unacceptableReasons.add(ERR_PLUGIN_UNIQUEATTR_ATTR_UNINDEXED.get(
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 33286eb..50d4f46 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -3694,7 +3694,7 @@
    */
   private LocalBackend<?> getBackend()
   {
-    return DirectoryServer.getLocalBackend(getBaseDN());
+    return DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(getBaseDN());
   }
 
   /*
@@ -3761,7 +3761,7 @@
     }
 
     // Check that the base DN is configured as a base-dn of the directory server
-    if (DirectoryServer.getLocalBackend(dn) == null)
+    if (DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(dn) == null)
     {
       unacceptableReasons.add(ERR_UNKNOWN_DN.get(dn));
       return false;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
index f4d646c..e6d3645 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
@@ -52,6 +52,7 @@
 import org.forgerock.opendj.server.config.server.UserDefinedVirtualAttributeCfg;
 import org.opends.server.api.VirtualAttributeProvider;
 import org.opends.server.backends.ChangelogBackend;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.crypto.CryptoSuite;
 import org.opends.server.replication.common.CSN;
@@ -465,7 +466,9 @@
    */
   private void enableExternalChangeLog() throws ConfigException
   {
-    if (DirectoryServer.hasBackend(ChangelogBackend.BACKEND_ID))
+    BackendConfigManager backendConfigManager =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
+    if (backendConfigManager.hasLocalBackend(ChangelogBackend.BACKEND_ID))
     {
       // Backend has already been created and initialized
       // This can occurs in tests
@@ -477,7 +480,7 @@
       changelogBackend.openBackend();
       try
       {
-        DirectoryServer.registerBackend(changelogBackend);
+        backendConfigManager.registerLocalBackend(changelogBackend);
       }
       catch (Exception e)
       {
@@ -499,7 +502,9 @@
   {
     if (changelogBackend != null)
     {
-      DirectoryServer.deregisterBackend(changelogBackend);
+      BackendConfigManager backendConfigManager =
+          DirectoryServer.getInstance().getServerContext().getBackendConfigManager();
+      backendConfigManager.deregisterLocalBackend(changelogBackend);
       changelogBackend.finalizeBackend();
       changelogBackend = null;
     }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java
index aad3234..498cb40 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java
@@ -255,7 +255,7 @@
     {
       for (Map.Entry<String,Entry> mapEntry : configEntries.entrySet())
       {
-        LocalBackend<?> b = DirectoryServer.getBackend(mapEntry.getKey());
+        LocalBackend<?> b = getServerContext().getBackendConfigManager().getLocalBackend(mapEntry.getKey());
         if (b != null && b.supports(BackendOperation.BACKUP))
         {
           backendsToArchive.add(b);
@@ -268,7 +268,7 @@
       // be used.
       for (String id : backendIDList)
       {
-        LocalBackend<?> b = DirectoryServer.getBackend(id);
+        LocalBackend<?> b = getServerContext().getBackendConfigManager().getLocalBackend(id);
         if (b == null || configEntries.get(id) == null)
         {
           logger.error(ERR_BACKUPDB_NO_BACKENDS_FOR_ID, id);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java
index e89f109..794c5f4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java
@@ -261,7 +261,7 @@
 
     // Get the backend into which the LDIF should be imported.
 
-    LocalBackend<?> backend = DirectoryServer.getBackend(backendID);
+    LocalBackend<?> backend = getServerContext().getBackendConfigManager().getLocalBackend(backendID);
 
     if (backend == null)
     {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
index 4c20cd2..37fccc6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
@@ -42,6 +42,7 @@
 import org.opends.server.api.ClientConnection;
 import org.opends.server.backends.task.Task;
 import org.opends.server.backends.task.TaskState;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.core.LockFileManager;
 import org.opends.server.tools.makeldif.TemplateFile;
@@ -282,7 +283,7 @@
 
     if(backendID != null)
     {
-      backend = DirectoryServer.getBackend(backendID);
+      backend = getServerContext().getBackendConfigManager().getLocalBackend(backendID);
       if (backend == null)
       {
         LocalizableMessage message = ERR_LDIFIMPORT_NO_BACKENDS_FOR_ID.get();
@@ -297,9 +298,10 @@
     else
     {
       // Find the backend that includes all the branches.
+      BackendConfigManager backendConfigManager = getServerContext().getBackendConfigManager();
       for(DN includeBranch : includeBranches)
       {
-        LocalBackend<?> locatedBackend = DirectoryServer.getLocalBackend(includeBranch);
+        LocalBackend<?> locatedBackend = backendConfigManager.getLocalBackend(includeBranch);
         if(locatedBackend != null)
         {
           if(backend == null)
@@ -439,7 +441,7 @@
 
     if(backendID != null)
     {
-      backend = DirectoryServer.getBackend(backendID);
+      backend = getServerContext().getBackendConfigManager().getLocalBackend(backendID);
 
       if (backend == null)
       {
@@ -455,9 +457,10 @@
     else
     {
       // Find the backend that includes all the branches.
+      BackendConfigManager backendConfigManager = getServerContext().getBackendConfigManager();
       for(DN includeBranch : includeBranches)
       {
-        LocalBackend<?> locatedBackend = DirectoryServer.getLocalBackend(includeBranch);
+        LocalBackend<?> locatedBackend = backendConfigManager.getLocalBackend(includeBranch);
         if(locatedBackend != null)
         {
           if(backend == null)
@@ -714,7 +717,7 @@
         // It is necessary to retrieve the backend structure again
         // because disabling and enabling it again may have resulted
         // in a new backend being registered to the server.
-        backend = DirectoryServer.getBackend(backend.getBackendID());
+        backend = getServerContext().getBackendConfigManager().getLocalBackend(backend.getBackendID());
       }
       catch (DirectoryException e)
       {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/RebuildTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/RebuildTask.java
index f541842..40425a0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/RebuildTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/RebuildTask.java
@@ -166,7 +166,8 @@
     rebuildConfig.setTmpDirectory(tmpDirectory);
     rebuildConfig.setRebuildMode(rebuildMode);
 
-    final LocalBackend<?> backend = DirectoryServer.getLocalBackendWithBaseDN(rebuildConfig.getBaseDN());
+    final LocalBackend<?> backend =
+        getServerContext().getBackendConfigManager().getLocalBackendWithBaseDN(rebuildConfig.getBaseDN());
     if (backend == null)
     {
       logger.error(ERR_NO_BACKENDS_FOR_BASE, baseDN);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/RestoreTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/RestoreTask.java
index 91b512c..faf6017 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/RestoreTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/RestoreTask.java
@@ -261,7 +261,7 @@
 
     String backendID = TaskUtils.getBackendID(configEntry);
 
-    LocalBackend<?> backend = DirectoryServer.getBackend(backendID);
+    LocalBackend<?> backend = getServerContext().getBackendConfigManager().getLocalBackend(backendID);
     if (!backend.supports(BackendOperation.RESTORE))
     {
       logger.error(ERR_RESTOREDB_CANNOT_RESTORE, backend.getBackendID());
@@ -341,7 +341,7 @@
           // it is necessary to retrieve the backend structure again
           // because disabling and enabling it again may have resulted
           // in a new backend being registered to the server.
-          backend = DirectoryServer.getBackend(backendID);
+          backend = getServerContext().getBackendConfigManager().getLocalBackend(backendID);
         } catch (DirectoryException e)
         {
           logger.traceException(e);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
index 45f135d..ec3ace5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
@@ -634,7 +634,7 @@
   @Override
   protected void cleanup()
   {
-    DirectoryServer.shutdownBackends();
+    DirectoryServer.getInstance().getServerContext().getBackendConfigManager().shutdownLocalBackends();
   }
 
   private Set<AttributeType> toAttributeTypes(StringArgument attributeArg)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
index 8921577..94ef29e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -904,7 +904,7 @@
   @Override
   protected void cleanup()
   {
-    DirectoryServer.shutdownBackends();
+    DirectoryServer.getInstance().getServerContext().getBackendConfigManager().shutdownLocalBackends();
   }
 
   private boolean useBackend(Set<DN> includeBranches, List<DN> dnlist)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
index 6218d61..97cdab5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
@@ -295,7 +295,7 @@
   @Override
   protected void cleanup()
   {
-    DirectoryServer.shutdownBackends();
+    DirectoryServer.getInstance().getServerContext().getBackendConfigManager().shutdownLocalBackends();
   }
 
   /**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
index 5f3723d..0104749 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
@@ -152,7 +152,8 @@
 
     // If the target entry is in the server configuration, then make sure the
     // requester has the CONFIG_READ privilege.
-    if (DirectoryServer.getBackend(ConfigurationBackend.CONFIG_BACKEND_ID).handlesEntry(entryDN)
+    if (DirectoryServer.getInstance().getServerContext().getBackendConfigManager()
+          .getLocalBackend(ConfigurationBackend.CONFIG_BACKEND_ID).handlesEntry(entryDN)
         && !clientConnection.hasPrivilege(Privilege.CONFIG_READ, this))
     {
       appendErrorMessage(ERR_COMPARE_CONFIG_INSUFFICIENT_PRIVILEGES.get());
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
index 9951236..1f2408a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
@@ -270,7 +270,8 @@
       return;
     }
 
-    LocalBackend<?> newBackend = DirectoryServer.getLocalBackend(newDN);
+    LocalBackend<?> newBackend =
+        DirectoryServer.getInstance().getServerContext().getBackendConfigManager().getLocalBackend(newDN);
     if (newBackend == null)
     {
       setResultCode(ResultCode.NO_SUCH_OBJECT);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
index 9a859e7..f16354b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
@@ -59,7 +59,6 @@
 
 import static org.opends.messages.CoreMessages.*;
 import static org.opends.messages.ProtocolMessages.ERR_PROXYAUTH_AUTHZ_NOT_PERMITTED;
-import static org.opends.server.core.DirectoryServer.getRootDSEBackend;
 import static org.opends.server.util.ServerConstants.*;
 
 /**
@@ -732,8 +731,7 @@
    */
   public static boolean execute(Operation operation, DN entryDN) throws CanceledOperationException
   {
-    BackendAndName backendAndName = entryDN.isRootDN()
-        ? new BackendAndName(getRootDSEBackend(), entryDN) : getBackendManager().getLocalBackend(entryDN);
+    BackendAndName backendAndName = getBackendManager().getLocalBackendAndName(entryDN);
 
     if (backendAndName == null)
     {
diff --git a/opendj-server-legacy/src/test/java/org/forgerock/server/embedded/EmbeddedDirectoryServerTestCase.java b/opendj-server-legacy/src/test/java/org/forgerock/server/embedded/EmbeddedDirectoryServerTestCase.java
index 3bb1809..74f4509 100644
--- a/opendj-server-legacy/src/test/java/org/forgerock/server/embedded/EmbeddedDirectoryServerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/forgerock/server/embedded/EmbeddedDirectoryServerTestCase.java
@@ -36,6 +36,7 @@
 import org.forgerock.opendj.server.embedded.EmbeddedDirectoryServer;
 import org.forgerock.opendj.server.embedded.EmbeddedDirectoryServerException;
 import org.opends.server.TestCaseUtils;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.types.DirectoryEnvironmentConfig;
 import org.opends.server.util.StaticUtils;
@@ -136,14 +137,15 @@
   public void testUpdateConfiguration() throws Exception
   {
     EmbeddedDirectoryServer server = getServer();
-    assertTrue(DirectoryServer.hasBackend(USER_ROOT));
+    BackendConfigManager backendConfigManager = TestCaseUtils.getServerContext().getBackendConfigManager();
+    assertTrue(backendConfigManager.hasLocalBackend(USER_ROOT));
 
     toggleBackendActivation(server, false);
-    assertFalse(DirectoryServer.hasBackend(USER_ROOT));
+    assertFalse(backendConfigManager.hasLocalBackend(USER_ROOT));
 
     // revert to initial configuration
     toggleBackendActivation(server, true);
-    assertTrue(DirectoryServer.hasBackend(USER_ROOT));
+    assertTrue(backendConfigManager.hasLocalBackend(USER_ROOT));
   }
 
   private void toggleBackendActivation(EmbeddedDirectoryServer server, final boolean enabled) throws Exception
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java b/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
index a2da17d..0fd9c4d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
@@ -88,6 +88,7 @@
 import org.opends.server.backends.pluggable.EntryContainer;
 import org.opends.server.backends.pluggable.RootContainer;
 import org.opends.server.core.AddOperation;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DeleteOperation;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.core.ServerContext;
@@ -629,7 +630,7 @@
 
   private static void clearJEBackends() throws Exception
   {
-    for (LocalBackend<?> backend : DirectoryServer.getBackends())
+    for (LocalBackend<?> backend : getServerContext().getBackendConfigManager().getLocalBackends())
     {
       if (backend instanceof BackendImpl) {
         clearBackend(backend.getBackendID());
@@ -889,8 +890,8 @@
     // is re-enabled, a new backend object is in fact created and old reference
     // to memory backend must be invalidated. So to prevent this problem, we
     // retrieve the memory backend reference each time before cleaning it.
-    MemoryBackend memoryBackend = (MemoryBackend) getServerContext().getBackendConfigManager()
-        .getLocalBackend(backendID);
+    BackendConfigManager backendConfigManager = getServerContext().getBackendConfigManager();
+    MemoryBackend memoryBackend = (MemoryBackend) backendConfigManager.getLocalBackend(backendID);
 
     if (memoryBackend == null)
     {
@@ -899,7 +900,7 @@
       memoryBackend.setBaseDNs(baseDN);
       memoryBackend.configureBackend(null, getServerContext());
       memoryBackend.openBackend();
-      DirectoryServer.registerBackend(memoryBackend);
+      backendConfigManager.registerLocalBackend(memoryBackend);
     }
 
     memoryBackend.clearMemoryBackend();
@@ -914,7 +915,8 @@
   /** Clears a memory-based backend. */
   public static void clearMemoryBackend(String backendID) throws Exception
   {
-    MemoryBackend memoryBackend = (MemoryBackend) DirectoryServer.getBackend(backendID);
+    MemoryBackend memoryBackend =
+        (MemoryBackend) getServerContext().getBackendConfigManager().getLocalBackend(backendID);
     // FIXME JNR I suspect we could call finalizeBackend() here (but also in other
     // places in this class), because finalizeBackend() calls clearMemoryBackend().
     if (memoryBackend != null)
@@ -942,11 +944,11 @@
    */
   public static void clearBackend(String backendId, String baseDN) throws Exception
   {
-    LocalBackend<?> b = DirectoryServer.getBackend(backendId);
+    LocalBackend<?> b = getServerContext().getBackendConfigManager().getLocalBackend(backendId);
     if (clearBackend(b) && baseDN != null)
     {
       Entry e = createEntry(DN.valueOf(baseDN));
-      DirectoryServer.getBackend(backendId).addEntry(e, mock(AddOperation.class));
+      b.addEntry(e, mock(AddOperation.class));
     }
   }
 
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
index 6076f6a..b785bc8 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
@@ -51,12 +51,13 @@
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SearchScope;
 import org.forgerock.opendj.server.config.server.ExternalChangelogDomainCfg;
+import org.opends.server.TestCaseUtils;
 import org.opends.server.api.LocalBackend;
 import org.opends.server.backends.ChangelogBackend.ChangeNumberRange;
 import org.opends.server.controls.EntryChangelogNotificationControl;
 import org.opends.server.controls.ExternalChangelogRequestControl;
+import org.opends.server.core.BackendConfigManager;
 import org.opends.server.core.DeleteOperation;
-import org.opends.server.core.DirectoryServer;
 import org.opends.server.core.ModifyDNOperation;
 import org.opends.server.core.ModifyDNOperationBasis;
 import org.opends.server.core.ModifyOperation;
@@ -1527,7 +1528,9 @@
     //  is re-enabled, a new backend object is in fact created and old reference
     //  to memory backend must be invalidated. So to prevent this problem, we
     //  retrieve the memory backend reference each time before cleaning it.
-    MemoryBackend memoryBackend = (MemoryBackend) DirectoryServer.getBackend(backendId);
+    BackendConfigManager backendConfigManager = TestCaseUtils.getServerContext().getBackendConfigManager();
+    MemoryBackend memoryBackend =
+        (MemoryBackend) backendConfigManager.getLocalBackend(backendId);
 
     if (memoryBackend == null)
     {
@@ -1536,7 +1539,7 @@
       memoryBackend.setBaseDNs(baseDN);
       memoryBackend.configureBackend(null, getServerContext());
       memoryBackend.openBackend();
-      DirectoryServer.registerBackend(memoryBackend);
+      backendConfigManager.registerLocalBackend(memoryBackend);
     }
 
     memoryBackend.clearMemoryBackend();
@@ -1557,7 +1560,7 @@
         MemoryBackend memoryBackend = (MemoryBackend) backend;
         memoryBackend.clearMemoryBackend();
         memoryBackend.finalizeBackend();
-        DirectoryServer.deregisterBackend(memoryBackend);
+        TestCaseUtils.getServerContext().getBackendConfigManager().deregisterLocalBackend(memoryBackend);
       }
     }
   }
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java
index 597ee4d..fdcd92f 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java
@@ -27,7 +27,6 @@
 import org.opends.server.TestCaseUtils;
 import org.opends.server.api.LocalBackend;
 import org.opends.server.api.LocalBackend.BackendOperation;
-import org.opends.server.core.DirectoryServer;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
@@ -52,7 +51,8 @@
   @DataProvider(name = "backends")
   public Object[][] getBackends()
   {
-    List<LocalBackend<?>> backendList = new ArrayList<>(DirectoryServer.getBackends());
+    List<LocalBackend<?>> backendList = new ArrayList<>(
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackends());
     Object[][] objectArray = new Object[backendList.size()][1];
     for (int i=0; i < objectArray.length; i++)
     {
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/LDIFBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/LDIFBackendTestCase.java
index 0a68562..4eaa3a4 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/LDIFBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/LDIFBackendTestCase.java
@@ -726,7 +726,7 @@
 
   private LDIFBackend getLDIFBackend()
   {
-    LocalBackend<?> b = DirectoryServer.getBackend("ldifRoot");
+    LocalBackend<?> b = TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend("ldifRoot");
     assertNotNull(b);
     assertTrue(b instanceof LDIFBackend);
     return (LDIFBackend) b;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
index a99b122..4ed0698 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -90,7 +90,8 @@
   {
     TestCaseUtils.startServer();
 
-    schemaBackend = (SchemaBackend) DirectoryServer.getBackend("schema");
+    schemaBackend =
+        (SchemaBackend) TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend("schema");
     assertNotNull(schemaBackend);
   }
 
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java
index 8c08a50..da5dc9c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/task/TaskBackendTestCase.java
@@ -472,7 +472,7 @@
     String taskSchedule = "00 * * " + scheduledMonth + " *";
 
     TaskBackend taskBackend =
-      (TaskBackend) DirectoryServer.getLocalBackend(DN.valueOf("cn=tasks"));
+      (TaskBackend) TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("cn=tasks"));
     long tasksCountBefore = taskBackend.getNumberOfEntriesInBaseDN(DN.valueOf("cn=Scheduled Tasks,cn=tasks"));
 
     assertTrue(addRecurringTask(taskID, taskSchedule));
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
index 7a8f72d..7aed2f1 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
@@ -72,7 +72,8 @@
   /** Some of the tests disable the backends, so we reenable them here. */
   @AfterMethod(alwaysRun=true)
   public void reenableBackend() throws DirectoryException {
-    LocalBackend<?> b = DirectoryServer.getLocalBackend(DN.valueOf("o=test"));
+    LocalBackend<?> b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test"));
     b.setWritabilityMode(WritabilityMode.ENABLED);
   }
 
@@ -1209,7 +1210,8 @@
          "cn: Test User",
          "userPassword: password");
 
-    LocalBackend<?> b = DirectoryServer.getLocalBackend(DN.valueOf("o=test"));
+    LocalBackend<?> b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test"));
     b.setWritabilityMode(WritabilityMode.DISABLED);
 
     AddOperation addOperation = getRootConnection().processAdd(entry);
@@ -1241,7 +1243,8 @@
          "cn: Test User",
          "userPassword: password");
 
-    LocalBackend<?> b = DirectoryServer.getLocalBackend(DN.valueOf("o=test"));
+    LocalBackend<?> b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test"));
     b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
 
     AddOperation addOperation = getRootConnection().processAdd(entry);
@@ -1266,7 +1269,8 @@
     {
       conn.bind("cn=Directory Manager", "password");
 
-      LocalBackend<?> b = DirectoryServer.getLocalBackend(DN.valueOf("o=test"));
+      LocalBackend<?> b =
+          TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test"));
       b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
 
       long addRequests  = ldapStatistics.getAddRequests();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/BackendConfigManagerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/BackendConfigManagerTestCase.java
index 212d29e..ef40508 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/BackendConfigManagerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/BackendConfigManagerTestCase.java
@@ -88,7 +88,7 @@
   @Test(expectedExceptions = { DirectoryException.class })
   public void testDeregisterNonExistentBaseDN() throws Exception
   {
-    DirectoryServer.getInstance().getServerContext().getBackendConfigManager()
+    getBackendConfigManager()
       .deregisterBaseDN(DN.valueOf("o=unregistered"));
   }
 
@@ -129,8 +129,8 @@
     Entry backendEntry = createBackendEntry(backendID, false, baseDN);
 
     processAdd(backendEntry);
-    assertNull(DirectoryServer.getBackend(backendID));
-    assertNull(DirectoryServer.getLocalBackendWithBaseDN(baseDN));
+    assertNull(getBackendConfigManager().getLocalBackend(backendID));
+    assertNull(getBackendConfigManager().getLocalBackendWithBaseDN(baseDN));
 
     DeleteOperation deleteOperation = getRootConnection().processDelete(backendEntry.getName());
     assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
@@ -153,13 +153,13 @@
 
     processAdd(backendEntry);
 
-    LocalBackend<?> backend = DirectoryServer.getBackend(backendID);
+    LocalBackend<?> backend = getBackendConfigManager().getLocalBackend(backendID);
     assertBackend(baseDN, backend);
     createEntry(baseDN, backend);
 
     DeleteOperation deleteOperation = getRootConnection().processDelete(backendEntry.getName());
     assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
-    assertNull(DirectoryServer.getBackend(backendID));
+    assertNull(getBackendConfigManager().getLocalBackend(backendID));
   }
 
 
@@ -225,7 +225,7 @@
                                                   parentBaseDN);
     processAdd(parentBackendEntry);
 
-    LocalBackend<?> parentBackend = DirectoryServer.getBackend(parentBackendID);
+    LocalBackend<?> parentBackend = getBackendConfigManager().getLocalBackend(parentBackendID);
     assertBackend(parentBaseDN, parentBackend);
     createEntry(parentBaseDN, parentBackend);
 
@@ -237,10 +237,9 @@
                                                  childBaseDN);
     processAdd(childBackendEntry);
 
-    LocalBackend<?> childBackend = DirectoryServer.getBackend(childBackendID);
+    LocalBackend<?> childBackend = getBackendConfigManager().getLocalBackend(childBackendID);
     assertNotNull(childBackend);
-    assertEquals(childBackend,
-                 DirectoryServer.getLocalBackendWithBaseDN(childBaseDN));
+    assertEquals(childBackend, getBackendConfigManager().getLocalBackendWithBaseDN(childBaseDN));
     assertNotNull(childBackend.getParentBackend());
     assertEquals(parentBackend, childBackend.getParentBackend());
     assertEquals(parentBackend.getSubordinateBackends().length, 1);
@@ -262,17 +261,22 @@
     // Make sure that we can't remove the parent backend with the child still in place.
     DeleteOperation deleteOperation = conn.processDelete(parentBackendEntry.getName());
     assertNotEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
-    assertNotNull(DirectoryServer.getBackend(parentBackendID));
+    assertNotNull(getBackendConfigManager().getLocalBackend(parentBackendID));
 
     // Delete the child and then delete the parent.
     deleteOperation = conn.processDelete(childBackendEntry.getName());
     assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
-    assertNull(DirectoryServer.getBackend(childBackendID));
+    assertNull(getBackendConfigManager().getLocalBackend(childBackendID));
     assertEquals(parentBackend.getSubordinateBackends().length, 0);
 
     deleteOperation = conn.processDelete(parentBackendEntry.getName());
     assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
-    assertNull(DirectoryServer.getBackend(parentBackendID));
+    assertNull(getBackendConfigManager().getLocalBackend(parentBackendID));
+  }
+
+  private BackendConfigManager getBackendConfigManager()
+  {
+    return TestCaseUtils.getServerContext().getBackendConfigManager();
   }
 
 
@@ -294,7 +298,7 @@
                                                  childBaseDN);
     processAdd(childBackendEntry);
 
-    LocalBackend<?> childBackend = DirectoryServer.getBackend(childBackendID);
+    LocalBackend<?> childBackend = getBackendConfigManager().getLocalBackend(childBackendID);
     assertBackend(childBaseDN, childBackend);
     createEntry(childBaseDN, childBackend);
     assertTrue(DirectoryServer.isNamingContext(childBaseDN));
@@ -308,10 +312,9 @@
                                                   parentBaseDN);
     processAdd(parentBackendEntry);
 
-    LocalBackend<?> parentBackend = DirectoryServer.getBackend(parentBackendID);
+    LocalBackend<?> parentBackend = getBackendConfigManager().getLocalBackend(parentBackendID);
     assertNotNull(parentBackend);
-    assertEquals(parentBackend,
-                 DirectoryServer.getLocalBackendWithBaseDN(parentBaseDN));
+    assertEquals(parentBackend, getBackendConfigManager().getLocalBackendWithBaseDN(parentBaseDN));
     assertNotNull(childBackend.getParentBackend());
     assertEquals(parentBackend, childBackend.getParentBackend());
     assertEquals(parentBackend.getSubordinateBackends().length, 1);
@@ -331,18 +334,18 @@
     // Delete the backends from the server.
     DeleteOperation deleteOperation = getRootConnection().processDelete(childBackendEntry.getName());
     assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
-    assertNull(DirectoryServer.getBackend(childBackendID));
+    assertNull(getBackendConfigManager().getLocalBackend(childBackendID));
     assertEquals(parentBackend.getSubordinateBackends().length, 0);
 
     deleteOperation = getRootConnection().processDelete(parentBackendEntry.getName());
     assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
-    assertNull(DirectoryServer.getBackend(parentBackendID));
+    assertNull(getBackendConfigManager().getLocalBackend(parentBackendID));
   }
 
   private void assertBackend(DN baseDN, LocalBackend<?> backend) throws DirectoryException
   {
     assertNotNull(backend);
-    assertEquals(backend, DirectoryServer.getLocalBackendWithBaseDN(baseDN));
+    assertEquals(backend, getBackendConfigManager().getLocalBackendWithBaseDN(baseDN));
     assertFalse(backend.entryExists(baseDN));
     assertNull(backend.getParentBackend());
     assertEquals(backend.getSubordinateBackends().length, 0);
@@ -367,7 +370,7 @@
                                                   parentBaseDN);
     processAdd(parentBackendEntry);
 
-    LocalBackend<?> parentBackend = DirectoryServer.getBackend(parentBackendID);
+    LocalBackend<?> parentBackend = getBackendConfigManager().getLocalBackend(parentBackendID);
     assertBackend(parentBaseDN, parentBackend);
     createEntry(parentBaseDN, parentBackend);
     assertTrue(DirectoryServer.isNamingContext(parentBaseDN));
@@ -380,10 +383,9 @@
                                                       grandchildBaseDN);
     processAdd(grandchildBackendEntry);
 
-    LocalBackend<?> grandchildBackend = DirectoryServer.getBackend(grandchildBackendID);
+    LocalBackend<?> grandchildBackend = getBackendConfigManager().getLocalBackend(grandchildBackendID);
     assertNotNull(grandchildBackend);
-    assertEquals(grandchildBackend,
-                 DirectoryServer.getLocalBackendWithBaseDN(grandchildBaseDN));
+    assertEquals(grandchildBackend, getBackendConfigManager().getLocalBackendWithBaseDN(grandchildBaseDN));
     assertNotNull(grandchildBackend.getParentBackend());
     assertEquals(grandchildBackend.getParentBackend(), parentBackend);
     assertEquals(parentBackend.getSubordinateBackends().length, 1);
@@ -404,7 +406,7 @@
                                                  childBaseDN);
     processAdd(childBackendEntry);
 
-    LocalBackend<?> childBackend = DirectoryServer.getBackend(childBackendID);
+    LocalBackend<?> childBackend = getBackendConfigManager().getLocalBackend(childBackendID);
     createBackend(childBaseDN, childBackend, parentBackend, grandchildBackend);
     createEntry(childBaseDN, childBackend);
 
@@ -429,7 +431,7 @@
     // Update our reference to the child backend since the old one is no longer
     // valid, and make sure that it got re-inserted back into the same place in
     // the hierarchy.
-    childBackend = DirectoryServer.getBackend(childBackendID);
+    childBackend = getBackendConfigManager().getLocalBackend(childBackendID);
     createBackend(childBaseDN, childBackend, parentBackend, grandchildBackend);
 
 
@@ -453,18 +455,18 @@
     DeleteOperation deleteOperation =
          conn.processDelete(grandchildBackendEntry.getName());
     assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
-    assertNull(DirectoryServer.getBackend(grandchildBackendID));
+    assertNull(getBackendConfigManager().getLocalBackend(grandchildBackendID));
     assertEquals(childBackend.getSubordinateBackends().length, 0);
     assertEquals(parentBackend.getSubordinateBackends().length, 1);
 
     deleteOperation = conn.processDelete(childBackendEntry.getName());
     assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
-    assertNull(DirectoryServer.getBackend(childBackendID));
+    assertNull(getBackendConfigManager().getLocalBackend(childBackendID));
     assertEquals(parentBackend.getSubordinateBackends().length, 0);
 
     deleteOperation = conn.processDelete(parentBackendEntry.getName());
     assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
-    assertNull(DirectoryServer.getBackend(parentBackendID));
+    assertNull(getBackendConfigManager().getLocalBackend(parentBackendID));
   }
 
   private void enableBackend(Entry entry, boolean enabled)
@@ -486,7 +488,7 @@
       LocalBackend<?> grandchildBackend) throws DirectoryException
   {
     assertNotNull(childBackend);
-    assertEquals(childBackend, DirectoryServer.getLocalBackendWithBaseDN(childBaseDN));
+    assertEquals(childBackend, getBackendConfigManager().getLocalBackendWithBaseDN(childBaseDN));
     assertNotNull(childBackend.getParentBackend());
     assertEquals(parentBackend, childBackend.getParentBackend());
     assertEquals(parentBackend.getSubordinateBackends().length, 1);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/DeleteOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/DeleteOperationTestCase.java
index 1df2b10..b84b636 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/DeleteOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/DeleteOperationTestCase.java
@@ -58,7 +58,8 @@
   /** Some of the tests disable the backends, so we reenable them here. */
   @AfterMethod(alwaysRun=true)
   public void reenableBackend() throws DirectoryException {
-    LocalBackend<?> b = DirectoryServer.getLocalBackend(DN.valueOf("o=test"));
+    LocalBackend<?> b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test"));
     b.setWritabilityMode(WritabilityMode.ENABLED);
   }
 
@@ -569,7 +570,8 @@
   {
     TestCaseUtils.initializeTestBackend(true);
 
-    LocalBackend<?> backend = DirectoryServer.getLocalBackend(DN.valueOf("o=test"));
+    LocalBackend<?> backend =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test"));
     backend.setWritabilityMode(WritabilityMode.DISABLED);
 
     DeleteOperation deleteOperation = processDeleteRaw("o=test");
@@ -591,7 +593,8 @@
   {
     TestCaseUtils.initializeTestBackend(true);
 
-    LocalBackend<?> backend = DirectoryServer.getLocalBackend(DN.valueOf("o=test"));
+    LocalBackend<?> backend =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test"));
     backend.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
 
     DeleteOperation deleteOperation = processDeleteRaw("o=test");
@@ -613,7 +616,8 @@
   {
     TestCaseUtils.initializeTestBackend(true);
 
-    LocalBackend<?> backend = DirectoryServer.getLocalBackend(DN.valueOf("o=test"));
+    LocalBackend<?> backend =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test"));
     backend.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
 
     String[] args = getArgs("o=test");
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
index 4e8ae51..3c1ff72 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
@@ -96,7 +96,7 @@
     for (Object[] backendBaseDN2 : getBaseDNs())
     {
       final DN baseDN = DN.valueOf(backendBaseDN2[0].toString());
-      LocalBackend<?> b = DirectoryServer.getLocalBackend(baseDN);
+      LocalBackend<?> b = TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(baseDN);
       b.setWritabilityMode(WritabilityMode.ENABLED);
     }
   }
@@ -2429,7 +2429,7 @@
          "mail: foo",
          "employeeNumber: 1");
 
-    LocalBackend<?> b = DirectoryServer.getLocalBackend(DN.valueOf(baseDN));
+    LocalBackend<?> b = TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf(baseDN));
     b.setWritabilityMode(WritabilityMode.DISABLED);
 
     RawModification mod = newRawModification(ADD, "objectClass", "extensibleObject");
@@ -2467,7 +2467,7 @@
          "mail: foo",
          "employeeNumber: 1");
 
-    LocalBackend<?> b = DirectoryServer.getLocalBackend(DN.valueOf(baseDN));
+    LocalBackend<?> b = TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf(baseDN));
     b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
 
     RawModification mod = newRawModification(ADD, "objectClass", "extensibleObject");
@@ -2505,7 +2505,7 @@
          "mail: foo",
          "employeeNumber: 1");
 
-    LocalBackend<?> b = DirectoryServer.getLocalBackend(DN.valueOf(baseDN));
+    LocalBackend<?> b = TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf(baseDN));
     b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);
 
     try (RemoteConnection conn = new RemoteConnection("localhost", TestCaseUtils.getServerLdapPort()))
@@ -3230,7 +3230,8 @@
         "cn: Test User",
         "userPassword: password",
         "userPassword;deleted: oldpassword");
-    LocalBackend<?> backend = DirectoryServer.getBackend(TEST_BACKEND_ID);
+    LocalBackend<?> backend =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(TEST_BACKEND_ID);
     backend.addEntry(e, null); // Don't use add operation.
 
     // Constraint violation.
@@ -3271,7 +3272,8 @@
         "cn: Test User",
         "userPassword: password",
         "userPassword;deleted: oldpassword");
-    LocalBackend<?> backend = DirectoryServer.getBackend(TEST_BACKEND_ID);
+    LocalBackend<?> backend =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(TEST_BACKEND_ID);
     backend.addEntry(e, null); // Don't use add operation.
 
     // Constraint violation.
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/CommonEntryCacheTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/CommonEntryCacheTestCase.java
index a3a1de4..ef3a56f 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/CommonEntryCacheTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/CommonEntryCacheTestCase.java
@@ -23,7 +23,6 @@
 import org.opends.server.TestCaseUtils;
 import org.forgerock.opendj.server.config.server.EntryCacheCfg;
 import org.opends.server.api.EntryCache;
-import org.opends.server.core.DirectoryServer;
 import org.forgerock.opendj.ldap.DN;
 import org.opends.server.types.Entry;
 import org.opends.server.util.ServerConstants;
@@ -95,7 +94,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     assertFalse(cache.containsEntry(testEntriesList.get(0).getName()),
       "Not expected to find " + testEntriesList.get(0).getName() +
@@ -129,7 +129,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     assertNull(cache.getEntry(testEntriesList.get(0).getName()),
       "Not expected to find " + testEntriesList.get(0).getName() +
@@ -163,7 +164,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     assertNull(cache.getEntry(testEntriesList.get(0).getName()),
       "Not expected to find " + testEntriesList.get(0).getName() +
@@ -197,7 +199,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     assertNull(cache.getEntry(b, -1),
       "Not expected to find entry id " + -1 +
@@ -230,7 +233,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     assertEquals(cache.getEntryID(testEntriesList.get(0).getName()), -1,
       "Not expected to find " + testEntriesList.get(0).getName() +
@@ -263,7 +267,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     cache.putEntry(testEntriesList.get(0), b, 1);
 
@@ -296,7 +301,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     assertTrue(cache.putEntryIfAbsent(testEntriesList.get(0), b, 1),
       "Not expected to find " + testEntriesList.get(0).getName() +
@@ -337,7 +343,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     cache.removeEntry(testEntriesList.get(0).getName());
     cache.putEntry(testEntriesList.get(0), b, 1);
@@ -372,7 +379,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     cache.clear();
     cache.putEntry(testEntriesList.get(0), b, 1);
@@ -407,8 +415,11 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
-    String c = DirectoryServer.getLocalBackend(DN.valueOf("cn=config")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String c =
+        TestCaseUtils.getServerContext().getBackendConfigManager()
+          .getLocalBackend(DN.valueOf("cn=config")).getBackendID();
 
     cache.clearBackend(b);
     cache.putEntry(testEntriesList.get(0), b, 1);
@@ -449,8 +460,10 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
-    String c = DirectoryServer.getLocalBackend(DN.valueOf("cn=config")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String c = TestCaseUtils.getServerContext().getBackendConfigManager()
+        .getLocalBackend(DN.valueOf("cn=config")).getBackendID();
 
     cache.putEntry(testEntriesList.get(0), b, 1);
     Entry testEntry = testEntriesList.get(1);
@@ -510,7 +523,8 @@
   public void testCacheConcurrency()
          throws Exception
   {
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     for(int loops = 0; loops < CONCURRENCYLOOPS; loops++) {
       for(int i = 0; i < NUMTESTENTRIES; i++) {
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/DefaultEntryCacheTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/DefaultEntryCacheTestCase.java
index 01fc19d..aa87ccc 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/DefaultEntryCacheTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/DefaultEntryCacheTestCase.java
@@ -361,7 +361,8 @@
       cache.toVerboseString());
 
     TestCaseUtils.initializeTestBackend(false);
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     // Spread test entries among all cache levels via default cache.
     for (int i = 0; i < NUMTESTENTRIES; i++) {
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/FIFOEntryCacheTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/FIFOEntryCacheTestCase.java
index 41a0853..9b7e866 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/FIFOEntryCacheTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/FIFOEntryCacheTestCase.java
@@ -22,7 +22,6 @@
 import org.testng.annotations.BeforeClass;
 import org.forgerock.opendj.server.config.meta.*;
 import org.forgerock.opendj.server.config.server.FIFOEntryCacheCfg;
-import org.opends.server.core.DirectoryServer;
 import org.forgerock.opendj.ldap.DN;
 import org.opends.server.types.Entry;
 import org.opends.server.util.ServerConstants;
@@ -252,7 +251,8 @@
       "Expected empty cache.  " + "Cache contents:" + ServerConstants.EOL +
       cache.toVerboseString());
 
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     for(int i = 0; i < super.NUMTESTENTRIES; i++ ) {
       super.cache.putEntry(super.testEntriesList.get(i), b, i);
@@ -322,7 +322,8 @@
       "Expected empty cache.  " + "Cache contents:" + ServerConstants.EOL +
       cache.toVerboseString());
 
-    String b = DirectoryServer.getLocalBackend(DN.valueOf("o=test")).getBackendID();
+    String b =
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("o=test")).getBackendID();
 
     for(int i = 0; i < super.NUMTESTENTRIES; i++ ) {
       super.cache.putEntry(super.testEntriesList.get(i), b, i);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
index e08faba..a4d80d8 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
@@ -440,7 +440,7 @@
     }
     exportConfig = new LDIFExportConfig(ldif.getAbsolutePath(),
                               ExistingFileBehavior.OVERWRITE);
-    backend = DirectoryServer.getBackend("test");
+    backend = TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend("test");
     backend.exportLDIF(exportConfig);
   }
 
@@ -454,7 +454,7 @@
   {
     importConfig = new LDIFImportConfig(ldif.getAbsolutePath());
     TestCaseUtils.initializeTestBackend(false);
-    backend = DirectoryServer.getBackend("test");
+    backend = TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend("test");
     backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
   }
 }
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/DependencyTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/DependencyTest.java
index 1d60731..0dc873e 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/DependencyTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/DependencyTest.java
@@ -33,7 +33,6 @@
 import org.forgerock.opendj.ldap.SearchScope;
 import org.opends.server.TestCaseUtils;
 import org.opends.server.backends.MemoryBackend;
-import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalSearchOperation;
 import org.opends.server.protocols.internal.SearchRequest;
 import org.opends.server.replication.common.CSNGenerator;
@@ -321,7 +320,8 @@
          "o: test",
          "entryuuid: " + stringUID(1));
 
-    MemoryBackend memoryBackend = (MemoryBackend) DirectoryServer.getBackend(TEST_BACKEND_ID);
+    MemoryBackend memoryBackend =
+        (MemoryBackend) TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(TEST_BACKEND_ID);
     memoryBackend.addEntry(topEntry, null);
   }
 
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
index 8c1ed23..d6af00f 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
@@ -490,7 +490,8 @@
     // non persistent data
     LDIFImportConfig importConfig = new LDIFImportConfig(ldifFile.getAbsolutePath());
 
-    MemoryBackend memoryBackend = (MemoryBackend) DirectoryServer.getBackend(TEST_BACKEND_ID);
+    MemoryBackend memoryBackend =
+        (MemoryBackend) TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(TEST_BACKEND_ID);
     memoryBackend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
   }
 
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/tasks/TasksTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/tasks/TasksTestCase.java
index 78b8cb5..86a972a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/tasks/TasksTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/tasks/TasksTestCase.java
@@ -23,11 +23,11 @@
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SearchScope;
 import org.opends.server.DirectoryServerTestCase;
+import org.opends.server.TestCaseUtils;
 import org.opends.server.backends.task.Task;
 import org.opends.server.backends.task.TaskBackend;
 import org.opends.server.backends.task.TaskState;
 import org.opends.server.core.AddOperation;
-import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalSearchOperation;
 import org.opends.server.protocols.internal.SearchRequest;
 import org.opends.server.types.Entry;
@@ -108,7 +108,8 @@
   @Test(enabled=false) // This isn't a test method, but TestNG thinks it is.
   public static Task getTask(final DN taskEntryDN) throws Exception
   {
-    final TaskBackend taskBackend = (TaskBackend) DirectoryServer.getLocalBackend(DN.valueOf("cn=tasks"));
+    final TaskBackend taskBackend = (TaskBackend)
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("cn=tasks"));
 
     TestTimer timer = new TestTimer.Builder()
       .maxSleep(10, SECONDS)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
index 7749801..41e84dd 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
@@ -2377,8 +2377,8 @@
    */
   private Task getCompletedTask(DN taskEntryDN) throws Exception
   {
-    TaskBackend taskBackend =
-         (TaskBackend) DirectoryServer.getLocalBackend(DN.valueOf("cn=tasks"));
+    TaskBackend taskBackend = (TaskBackend)
+        TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackend(DN.valueOf("cn=tasks"));
     Task task = taskBackend.getScheduledTask(taskEntryDN);
     if (task == null)
     {

--
Gitblit v1.10.0