From 744da8ea9d6c0b9acdc19a51f2107fc64e8bfdfe Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 26 Apr 2016 07:54:21 +0000
Subject: [PATCH] Code cleanup in DirectoryServer

---
 opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java                         |    8 
 opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java                                |    3 
 opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java                |   16 
 opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java                   |   24 +-
 opendj-server-legacy/src/test/java/org/opends/server/backends/GenericBackendTestCase.java              |    2 
 opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java                         |  411 ++--------------------------------------
 opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java                      |    6 
 opendj-server-legacy/src/test/java/org/opends/server/monitors/TraditionalWorkQueueMonitorTestCase.java |    3 
 opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java                        |   88 --------
 opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java              |    4 
 opendj-server-legacy/src/test/java/org/opends/server/monitors/BackendMonitorTestCase.java              |    8 
 opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java  |   20 -
 12 files changed, 69 insertions(+), 524 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 5ca19b6..68dbcfd 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
@@ -16,11 +16,15 @@
  */
 package org.opends.server.authorization.dseecompat;
 
+import static org.opends.messages.AccessControlMessages.*;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
+import static org.opends.server.util.ServerConstants.*;
+
 import java.util.EnumSet;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -54,11 +58,6 @@
 import org.opends.server.types.operation.PostSynchronizationModifyOperation;
 import org.opends.server.workflowelement.localbackend.LocalBackendSearchOperation;
 
-import static org.opends.messages.AccessControlMessages.*;
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.opends.server.protocols.internal.Requests.*;
-import static org.opends.server.util.ServerConstants.*;
-
 /**
  * The AciListenerManager updates an ACI list after each modification
  * operation. Also, updates ACI list when backends are initialized and
@@ -310,12 +309,9 @@
     this.plugin = new AciChangeListenerPlugin();
 
     // Process ACI from already registered backends.
-    Map<String, Backend<?>> backendMap = DirectoryServer.getBackends();
-    if (backendMap != null) {
-      for (Backend<?> backend : backendMap.values())
-      {
-        performBackendPreInitializationProcessing(backend);
-      }
+    for (Backend<?> backend : DirectoryServer.getBackends())
+    {
+      performBackendPreInitializationProcessing(backend);
     }
 
     DirectoryServer.registerInternalPlugin(plugin);
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 d5475a8..adea116 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
@@ -444,7 +444,7 @@
 
     // Add the "supportedExtension" attribute.
     Attribute supportedExtensionAttr = createAttribute(
-        ATTR_SUPPORTED_EXTENSION, DirectoryServer.getSupportedExtensions().keySet());
+        ATTR_SUPPORTED_EXTENSION, DirectoryServer.getSupportedExtensions());
     addAttribute(supportedExtensionAttr, dseUserAttrs, dseOperationalAttrs);
 
     // Add the "supportedFeature" attribute.
@@ -454,7 +454,7 @@
 
     // Add the "supportedSASLMechanisms" attribute.
     Attribute supportedSASLMechAttr = createAttribute(
-        ATTR_SUPPORTED_SASL_MECHANISMS, DirectoryServer.getSupportedSASLMechanisms().keySet());
+        ATTR_SUPPORTED_SASL_MECHANISMS, DirectoryServer.getSupportedSASLMechanisms());
     addAttribute(supportedSASLMechAttr, dseUserAttrs, dseOperationalAttrs);
 
     // Add the "supportedLDAPVersions" attribute.
@@ -744,7 +744,7 @@
     {
       return subordinateBaseDNs;
     }
-    return (Map) DirectoryServer.getPublicNamingContexts();
+    return DirectoryServer.getPublicNamingContexts();
   }
 
   @Override
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 ad573c3..9a84ed4 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
@@ -37,6 +37,7 @@
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
 import java.text.DecimalFormat;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -641,10 +642,10 @@
   private WritabilityMode writabilityMode;
 
   /** The memory reservation system. */
-  private MemoryQuota memoryQuota;
+  private final MemoryQuota memoryQuota;
 
   /** The Disk Space Monitor. */
-  private DiskSpaceMonitor diskSpaceMonitor;
+  private final DiskSpaceMonitor diskSpaceMonitor;
 
   /** The lock manager which will be used for coordinating access to LDAP entries. */
   private final LockManager lockManager = new LockManager();
@@ -694,9 +695,9 @@
       ERROR_DEBUG_LOGGERS;
     }
 
-    private String configFile;
-    private Set<PluginType> pluginTypes = new HashSet<>();
-    private static EnumSet<SubSystem> subSystemsToInitialize = EnumSet.noneOf(SubSystem.class);
+    private final String configFile;
+    private final Set<PluginType> pluginTypes = new HashSet<>();
+    private final EnumSet<SubSystem> subSystemsToInitialize = EnumSet.noneOf(SubSystem.class);
     private PrintStream loggingOut;
     private PrintStream errConfiguringLogging;
 
@@ -815,7 +816,7 @@
       }
     }
 
-    private static void checkSubsystemIsInitialized(SubSystem subsystem) throws InitializationException
+    private void checkSubsystemIsInitialized(SubSystem subsystem) throws InitializationException
     {
       if (!subSystemsToInitialize.contains(subsystem))
       {
@@ -2161,30 +2162,6 @@
   }
 
   /**
-   * Initialize the root DSE in the Directory Server.
-   *
-   * @throws ConfigException If a problem occurs retrieving the root DSE backend
-   *                         configuration.
-   * @throws InitializationException If a problem occurs initializing the root
-   *                                 root DSE backend.
-   */
-  public void initializeRootDSE()
-         throws ConfigException, InitializationException {
-  RootDSEBackendCfg rootDSECfg;
-  try {
-    rootDSECfg = serverContext.getRootConfig().getRootDSEBackend();
-  }  catch (Exception e) {
-    logger.traceException(e);
-    LocalizableMessage message = ERR_CANNOT_GET_ROOT_DSE_CONFIG_ENTRY.get(
-        stackTraceToSingleLineString(e));
-    throw new InitializationException(message, e);
-  }
-  rootDSEBackend = new RootDSEBackend();
-  rootDSEBackend.configureBackend(rootDSECfg, serverContext);
-  rootDSEBackend.openBackend();
-}
-
-  /**
    * Retrieves a reference to the Directory Server plugin configuration manager.
    *
    * @return  A reference to the Directory Server plugin configuration manager.
@@ -2398,16 +2375,6 @@
   }
 
   /**
-   * Retrieves the set of objectclasses defined in the Directory Server.
-   *
-   * @return  The set of objectclasses defined in the Directory Server.
-   */
-  public static ConcurrentMap<String, ObjectClass> getObjectClasses()
-  {
-    return directoryServer.schema.getObjectClasses();
-  }
-
-  /**
    * Retrieves the objectclass for the provided lowercase name or OID.
    *
    * @param  lowerName  The lowercase name or OID for the objectclass to
@@ -2613,40 +2580,6 @@
   }
 
   /**
-   * Registers the provided attribute type with the Directory Server.
-   *
-   * @param  attributeType      The attribute type to register with the
-   *                            Directory Server.
-   * @param  overwriteExisting  Indicates whether to overwrite an existing
-   *                            mapping if there are any conflicts (i.e.,
-   *                            another attribute type with the same OID or
-   *                            name).
-   *
-   * @throws  DirectoryException  If a conflict is encountered and the
-   *                              <CODE>overwriteExisting</CODE> flag is set to
-   *                              <CODE>false</CODE>
-   */
-  public static void registerAttributeType(AttributeType attributeType,
-                                           boolean overwriteExisting)
-         throws DirectoryException
-  {
-    directoryServer.schema.registerAttributeType(attributeType, overwriteExisting);
-  }
-
-  /**
-   * Deregisters the provided attribute type with the Directory Server.
-   *
-   * @param  attributeType  The attribute type to deregister with the Directory
-   *                        Server.
-   * @throws DirectoryException
-   *           If the attribute type is referenced by another schema element.
-   */
-  public static void deregisterAttributeType(AttributeType attributeType) throws DirectoryException
-  {
-    directoryServer.schema.deregisterAttributeType(attributeType);
-  }
-
-  /**
    * Retrieves the attribute type for the "objectClass" attribute.
    *
    * @return  The attribute type for the "objectClass" attribute.
@@ -2673,7 +2606,7 @@
    * @return  The default attribute syntax that should be used for attributes
    *          that are not defined in the server schema.
    */
-  public static Syntax getDefaultAttributeSyntax()
+  private static Syntax getDefaultAttributeSyntax()
   {
     return DirectoryServer.directoryServer.schema.getDefaultSyntax();
   }
@@ -2806,17 +2739,6 @@
   }
 
   /**
-   * Retrieves the set of DIT content rules defined in the Directory Server.
-   *
-   * @return  The set of DIT content rules defined in the Directory Server.
-   */
-  public static ConcurrentMap<ObjectClass, DITContentRule>
-                     getDITContentRules()
-  {
-    return directoryServer.schema.getDITContentRules();
-  }
-
-  /**
    * Retrieves the DIT content rule associated with the specified objectclass.
    *
    * @param  objectClass  The objectclass for which to retrieve the associated
@@ -2831,28 +2753,6 @@
   }
 
   /**
-   * Registers the provided DIT content rule with the Directory Server.
-   *
-   * @param  ditContentRule     The DIT content rule to register with the
-   *                            server.
-   * @param  overwriteExisting  Indicates whether to overwrite an existing
-   *                            mapping if there are any conflicts (i.e.,
-   *                            another DIT content rule with the same
-   *                            structural objectclass).
-   *
-   * @throws  DirectoryException  If a conflict is encountered and the
-   *                              <CODE>overwriteExisting</CODE> flag is set to
-   *                              <CODE>false</CODE>
-   */
-  public static void registerDITContentRule(DITContentRule ditContentRule,
-                                            boolean overwriteExisting)
-         throws DirectoryException
-  {
-    directoryServer.schema.registerDITContentRule(ditContentRule,
-                                                  overwriteExisting);
-  }
-
-  /**
    * Deregisters the provided DIT content rule with the Directory Server.
    *
    * @param  ditContentRule  The DIT content rule to deregister with the server.
@@ -2863,17 +2763,6 @@
   }
 
   /**
-   * Retrieves the set of DIT structure rules defined in the Directory Server.
-   *
-   * @return  The set of DIT structure rules defined in the Directory Server.
-   */
-  public static ConcurrentMap<NameForm, DITStructureRule>
-                     getDITStructureRules()
-  {
-    return directoryServer.schema.getDITStructureRulesByNameForm();
-  }
-
-  /**
    * Retrieves the DIT structure rule associated with the provided rule ID.
    *
    * @param  ruleID  The rule ID for which to retrieve the associated DIT
@@ -2902,28 +2791,6 @@
   }
 
   /**
-   * Registers the provided DIT structure rule with the Directory Server.
-   *
-   * @param  ditStructureRule   The DIT structure rule to register with the
-   *                            server.
-   * @param  overwriteExisting  Indicates whether to overwrite an existing
-   *                            mapping if there are any conflicts (i.e.,
-   *                            another DIT structure rule with the same name
-   *                            form).
-   *
-   * @throws  DirectoryException  If a conflict is encountered and the
-   *                              <CODE>overwriteExisting</CODE> flag is set to
-   *                              <CODE>false</CODE>
-   */
-  public static void registerDITStructureRule(DITStructureRule ditStructureRule,
-                                              boolean overwriteExisting)
-         throws DirectoryException
-  {
-    directoryServer.schema.registerDITStructureRule(ditStructureRule,
-                                                    overwriteExisting);
-  }
-
-  /**
    * Deregisters the provided DIT structure rule with the Directory Server.
    *
    * @param  ditStructureRule  The DIT structure rule to deregister with the
@@ -2936,16 +2803,6 @@
   }
 
   /**
-   * Retrieves the set of name forms defined in the Directory Server.
-   *
-   * @return  The set of name forms defined in the Directory Server.
-   */
-  public static ConcurrentMap<ObjectClass, List<NameForm>> getNameForms()
-  {
-    return directoryServer.schema.getNameFormsByObjectClass();
-  }
-
-  /**
    * Retrieves the name forms associated with the specified objectclass.
    *
    * @param  objectClass  The objectclass for which to retrieve the associated
@@ -2974,26 +2831,6 @@
   }
 
   /**
-   * Registers the provided name form with the Directory Server.
-   *
-   * @param  nameForm           The name form to register with the server.
-   * @param  overwriteExisting  Indicates whether to overwrite an existing
-   *                            mapping if there are any conflicts (i.e.,
-   *                            another name form with the same structural
-   *                            objectclass).
-   *
-   * @throws  DirectoryException  If a conflict is encountered and the
-   *                              <CODE>overwriteExisting</CODE> flag is set to
-   *                              <CODE>false</CODE>
-   */
-  public static void registerNameForm(NameForm nameForm,
-                                      boolean overwriteExisting)
-         throws DirectoryException
-  {
-    directoryServer.schema.registerNameForm(nameForm, overwriteExisting);
-  }
-
-  /**
    * Deregisters the provided name form with the Directory Server.
    *
    * @param  nameForm  The name form to deregister with the server.
@@ -3075,9 +2912,9 @@
    *
    * @return  The set of JMX MBeans that are associated with the server.
    */
-  public static ConcurrentHashMap<DN,JMXMBean> getJMXMBeans()
+  public static Collection<JMXMBean> getJMXMBeans()
   {
-    return directoryServer.mBeans;
+    return directoryServer.mBeans.values();
   }
 
   /**
@@ -3247,9 +3084,9 @@
    * @return  The set of password storage schemes defined in the Directory
    *          Server.
    */
-  public static ConcurrentHashMap<String, PasswordStorageScheme<?>> getPasswordStorageSchemes()
+  public static Collection<PasswordStorageScheme<?>> getPasswordStorageSchemes()
   {
-    return directoryServer.passwordStorageSchemes;
+    return directoryServer.passwordStorageSchemes.values();
   }
 
   /**
@@ -3343,21 +3180,6 @@
   }
 
   /**
-   * Retrieves the set of password validators that have been registered for use
-   * with the Directory Server as a mapping between the DN of the associated
-   * validator configuration entry and the validator implementation.
-   *
-   * @return  The set of password validators that have been registered for use
-   *          with the Directory Server.
-   */
-  public static ConcurrentMap<DN,
-            PasswordValidator<? extends PasswordValidatorCfg>>
-            getPasswordValidators()
-  {
-    return directoryServer.passwordValidators;
-  }
-
-  /**
    * Retrieves the password validator registered with the provided configuration
    * entry DN.
    *
@@ -3403,20 +3225,6 @@
   }
 
   /**
-   * Retrieves the set of account status notification handlers defined in the
-   * Directory Server, as a mapping between the DN of the configuration entry
-   * and the notification handler implementation.
-   *
-   * @return  The set of account status notification handlers defined in the
-   *          Directory Server.
-   */
-  public static ConcurrentMap<DN, AccountStatusNotificationHandler<?>>
-                     getAccountStatusNotificationHandlers()
-  {
-    return directoryServer.accountStatusNotificationHandlers;
-  }
-
-  /**
    * Retrieves the account status notification handler with the specified
    * configuration entry DN.
    *
@@ -3460,19 +3268,6 @@
   }
 
   /**
-   * Retrieves the set of password generators that have been registered for use
-   * with the Directory Server as a mapping between the DN of the associated
-   * generator configuration entry and the generator implementation.
-   *
-   * @return  The set of password generators that have been registered for use
-   *          with the Directory Server.
-   */
-  public static ConcurrentMap<DN, PasswordGenerator<?>> getPasswordGenerators()
-  {
-    return directoryServer.passwordGenerators;
-  }
-
-  /**
    * Retrieves the password generator registered with the provided configuration
    * entry DN.
    *
@@ -3788,21 +3583,6 @@
   }
 
   /**
-   * Retrieves the monitor provider with the specified name.
-   *
-   * @param  lowerName  The name of the monitor provider to retrieve, in all
-   *                    lowercase characters.
-   *
-   * @return  The requested resource monitor, or {@code null} if none
-   *          exists with the specified name.
-   */
-  public static MonitorProvider<? extends MonitorProviderCfg>
-                     getMonitorProvider(String lowerName)
-  {
-    return directoryServer.monitorProviders.get(lowerName);
-  }
-
-  /**
    * Registers the provided monitor provider with the Directory Server.  Note
    * that if a monitor provider is already registered with the specified name,
    * then it will be replaced with the provided implementation.
@@ -3897,18 +3677,6 @@
   }
 
   /**
-   * Retrieves the set of key manager providers registered with the Directory
-   * Server.
-   *
-   * @return  The set of key manager providers registered with the Directory
-   *          Server.
-   */
-  public static Map<DN, KeyManagerProvider<?>> getKeyManagerProviders()
-  {
-    return directoryServer.keyManagerProviders;
-  }
-
-  /**
    * Retrieves the key manager provider registered with the provided entry DN.
    *
    * @param  providerDN  The DN with which the key manager provider is
@@ -3947,18 +3715,6 @@
   }
 
   /**
-   * Retrieves the set of trust manager providers registered with the Directory
-   * Server.
-   *
-   * @return  The set of trust manager providers registered with the Directory
-   *          Server.
-   */
-  public static Map<DN, TrustManagerProvider<?>> getTrustManagerProviders()
-  {
-    return directoryServer.trustManagerProviders;
-  }
-
-  /**
    * Retrieves the trust manager provider registered with the provided entry DN.
    *
    * @param  providerDN  The DN with which the trust manager provider is
@@ -3997,18 +3753,6 @@
   }
 
   /**
-   * Retrieves the set of certificate mappers registered with the Directory
-   * Server.
-   *
-   * @return  The set of certificate mappers registered with the Directory
-   *          Server.
-   */
-  public static Map<DN, CertificateMapper<?>> getCertificateMappers()
-  {
-    return directoryServer.certificateMappers;
-  }
-
-  /**
    * Retrieves the certificate mapper registered with the provided entry DN.
    *
    * @param  mapperDN  The DN with which the certificate mapper is registered.
@@ -4104,19 +3848,6 @@
   }
 
   /**
-   * Retrieves the set of alternate bind DNs for root users, mapped between the
-   * alternate DN and the real DN.  The contents of the returned map must not be
-   * altered by the caller.
-   *
-   * @return  The set of alternate bind DNs for root users, mapped between the
-   *          alternate DN and the real DN.
-   */
-  public static ConcurrentMap<DN, DN> getAlternateRootBindDNs()
-  {
-    return directoryServer.alternateRootBindDNs;
-  }
-
-  /**
    * Retrieves the real entry DN for the root user with the provided alternate
    * bind DN.
    *
@@ -4369,9 +4100,9 @@
    * @return  The set of backends that have been registered with the Directory
    *          Server.
    */
-  public static Map<String, Backend<?>> getBackends()
+  public static Collection<Backend<?>> getBackends()
   {
-    return new TreeMap<>(directoryServer.backends);
+    return new ArrayList<>(directoryServer.backends.values());
   }
 
   /**
@@ -4485,18 +4216,6 @@
   }
 
   /**
-   * Retrieves the entire set of base DNs registered with the Directory Server,
-   * mapped from the base DN to the backend responsible for that base DN.  The
-   * same backend may be present multiple times, mapped from different base DNs.
-   *
-   * @return  The entire set of base DNs registered with the Directory Server.
-   */
-  public static Map<DN, Backend<?>> getBaseDNs()
-  {
-    return directoryServer.baseDnRegistry.getBaseDnMap();
-  }
-
-  /**
    * Retrieves the backend with the specified base DN.
    *
    * @param  baseDN  The DN that is registered as one of the base DNs for the
@@ -4908,9 +4627,9 @@
    * @return  The set of extended operations that may be processed by the
    *         Directory Server.
    */
-  public static ConcurrentMap<String, ExtendedOperationHandler<?>> getSupportedExtensions()
+  public static Set<String> getSupportedExtensions()
   {
-    return directoryServer.extendedOperationHandlers;
+    return directoryServer.extendedOperationHandlers.keySet();
   }
 
   /**
@@ -4957,9 +4676,9 @@
    * @return  The set of SASL mechanisms that are supported by the Directory
    *          Server.
    */
-  public static ConcurrentMap<String, SASLMechanismHandler<?>> getSupportedSASLMechanisms()
+  public static Set<String> getSupportedSASLMechanisms()
   {
-    return directoryServer.saslMechanismHandlers;
+    return directoryServer.saslMechanismHandlers.keySet();
   }
 
   /**
@@ -5062,19 +4781,6 @@
   }
 
   /**
-   * Retrieves the set of identity mappers defined in the Directory Server
-   * configuration, as a mapping between the DN of the configuration entry and
-   * the identity mapper.
-   *
-   * @return  The set of identity mappers defined in the Directory Server
-   *          configuration.
-   */
-  public static ConcurrentMap<DN, IdentityMapper<?>> getIdentityMappers()
-  {
-    return directoryServer.identityMappers;
-  }
-
-  /**
    * Retrieves the Directory Server identity mapper whose configuration resides
    * in the specified configuration entry.
    *
@@ -5561,18 +5267,6 @@
   }
 
   /**
-   * Indicates whether the Directory Server should save a copy of its
-   * configuration whenever it is started successfully.
-   *
-   * @return  {@code true} if the server should save a copy of its configuration
-   *          whenever it is started successfully, or {@code false} if not.
-   */
-  public static boolean saveConfigOnSuccessfulStartup()
-  {
-    return directoryServer.saveConfigOnSuccessfulStartup;
-  }
-
-  /**
    * Specifies whether the Directory Server should save a copy of its
    * configuration whenever it is started successfully.
    *
@@ -6289,23 +5983,6 @@
    * Reinitializes the server following a shutdown, preparing it for a call to
    * {@code startServer}.
    *
-   * @return  The new Directory Server instance created during the
-   *          re-initialization process.
-   *
-   * @throws  InitializationException  If a problem occurs while trying to
-   *                                   initialize the config handler or
-   *                                   bootstrap that server.
-   */
-  public static DirectoryServer reinitialize()
-         throws InitializationException
-  {
-    return reinitialize(directoryServer.environmentConfig);
-  }
-
-  /**
-   * Reinitializes the server following a shutdown, preparing it for a call to
-   * {@code startServer}.
-   *
    * @param  config  The environment configuration for the Directory Server.
    *
    * @return  The new Directory Server instance created during the
@@ -6328,18 +6005,6 @@
   }
 
   /**
-   * Retrieves the maximum number of concurrent client connections that may be
-   * established.
-   *
-   * @return  The maximum number of concurrent client connections that may be
-   *          established, or -1 if there is no limit.
-   */
-  public static long getMaxAllowedConnections()
-  {
-    return directoryServer.maxAllowedConnections;
-  }
-
-  /**
    * Specifies the maximum number of concurrent client connections that may be
    * established.  A value that is less than or equal to zero will indicate that
    * no limit should be enforced.
@@ -6469,8 +6134,7 @@
    * @throws  IOException  If a problem occurs while attempting to write the
    *                       version information to the provided output stream.
    */
-  public static void printVersion(OutputStream outputStream)
-  throws IOException
+  private static void printVersion(OutputStream outputStream) throws IOException
   {
     outputStream.write(PRINTABLE_VERSION_STRING.getBytes());
 
@@ -6679,17 +6343,6 @@
   }
 
   /**
-   * Indicates whether an unauthenticated request should be rejected.
-   *
-   * @return <CODE>true</CODE>if an unauthenticated request should be
-   *         rejected, or <CODE>false</CODE>f if not.
-   */
-  public static boolean rejectUnauthenticatedRequests()
-  {
-     return directoryServer.rejectUnauthenticatedRequests;
-  }
-
-  /**
    * Specifies whether an unauthenticated request should be rejected.
    *
    * @param  rejectUnauthenticatedRequests   Indicates whether an
@@ -6745,17 +6398,6 @@
   }
 
   /**
-   * Sets the message to be displayed on the command-line when the user asks for
-   * the usage.
-   * @param msg the message to be displayed on the command-line when the user
-   * asks for the usage.
-   */
-  public static void setToolDescription (LocalizableMessage msg)
-  {
-    toolDescription = msg;
-  }
-
-  /**
    * Retrieves the DN of the configuration entry with which this alert generator
    * is associated.
    *
@@ -6854,10 +6496,9 @@
     StringArgument  configFile             = null;
 
     // Create the command-line argument parser for use with this program.
-    LocalizableMessage theToolDescription = DirectoryServer.toolDescription;
     ArgumentParser argParser =
          new ArgumentParser("org.opends.server.core.DirectoryServer",
-                            theToolDescription, false);
+                            DirectoryServer.toolDescription, false);
     argParser.setShortToolDescription(REF_SHORT_DESC_START_DS.get());
 
     // Initialize all the command-line argument types and register them with the parser.
@@ -7228,14 +6869,14 @@
   }
 
   /**
-   * Gets the class loader to be used with this directory server
-   * application.
+   * Gets the class loader to be used with this directory server application.
    * <p>
-   * The class loader will automatically load classes from plugins
-   * where required.
+   * The class loader will automatically load classes from plugins where required.
+   * <p>
+   * Note: {@code public} access is required for compiling the
+   * {@code org.opends.server.snmp.SNMPConnectionHandler}.
    *
-   * @return Returns the class loader to be used with this directory
-   *         server application.
+   * @return Returns the class loader to be used with this directory server application.
    */
   public static ClassLoader getClassLoader()
   {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java
index 7192a71..26fa924 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java
@@ -16,12 +16,15 @@
  */
 package org.opends.server.extensions;
 
-import org.forgerock.i18n.LocalizableMessage;
+import static org.opends.messages.ConfigMessages.*;
+import static org.opends.messages.ExtensionMessages.*;
+import static org.opends.server.util.ServerConstants.*;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
+
 import javax.management.Attribute;
 import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
@@ -38,22 +41,20 @@
 import javax.management.NotificationBroadcasterSupport;
 import javax.management.ObjectName;
 
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigChangeResult;
+import org.forgerock.opendj.config.server.ConfigException;
 import org.forgerock.opendj.config.server.ConfigurationChangeListener;
+import org.forgerock.opendj.ldap.DN;
 import org.forgerock.opendj.server.config.server.AlertHandlerCfg;
 import org.forgerock.opendj.server.config.server.JMXAlertHandlerCfg;
 import org.opends.server.api.AlertGenerator;
 import org.opends.server.api.AlertHandler;
 import org.opends.server.api.DirectoryServerMBean;
-import org.forgerock.opendj.config.server.ConfigException;
 import org.opends.server.config.JMXMBean;
 import org.opends.server.core.DirectoryServer;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.ldap.DN;
 import org.opends.server.types.InitializationException;
-import static org.opends.messages.ConfigMessages.*;
-import static org.opends.messages.ExtensionMessages.*;
-import static org.opends.server.util.ServerConstants.*;
 
 /**
  * This class provides an implementation of a Directory Server alert handler
@@ -189,9 +190,8 @@
   @Override
   public MBeanNotificationInfo[] getNotificationInfo()
   {
-    ArrayList<MBeanNotificationInfo> notifications = new ArrayList<>();
-    ConcurrentHashMap<DN,JMXMBean> mBeans = DirectoryServer.getJMXMBeans();
-    for (JMXMBean mBean : mBeans.values())
+    List<MBeanNotificationInfo> notifications = new ArrayList<>();
+    for (JMXMBean mBean : DirectoryServer.getJMXMBeans())
     {
       MBeanInfo mBeanInfo = mBean.getMBeanInfo();
       Collections.addAll(notifications, mBeanInfo.getNotifications());
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
index 1af0aef..8132dba 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
@@ -31,8 +31,8 @@
 import java.io.OutputStream;
 import java.io.PrintStream;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
-import java.util.concurrent.ConcurrentHashMap;
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.opendj.ldap.ByteString;
@@ -299,7 +299,7 @@
     {
       if (authPasswordSyntax.isPresent())
       {
-        listPasswordStorageSchemes(out, err, DirectoryServer.getAuthPasswordStorageSchemes(), true);
+        listPasswordStorageSchemes(out, err, DirectoryServer.getAuthPasswordStorageSchemes().values(), true);
       }
       else
       {
@@ -520,7 +520,7 @@
   }
 
   private static void listPasswordStorageSchemes(PrintStream out, PrintStream err,
-      ConcurrentHashMap<String, PasswordStorageScheme<?>> storageSchemes, boolean authPasswordSchemeName)
+      Collection<PasswordStorageScheme<?>> storageSchemes, boolean authPasswordSchemeName)
   {
     if (storageSchemes.isEmpty())
     {
@@ -529,7 +529,7 @@
     else
     {
       ArrayList<String> nameList = new ArrayList<>(storageSchemes.size());
-      for (PasswordStorageScheme<?> s : storageSchemes.values())
+      for (PasswordStorageScheme<?> s : storageSchemes)
       {
         if (authPasswordSchemeName)
         {
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java b/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
index 2fc6c67..b3e69f6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
@@ -215,22 +215,6 @@
   }
 
   /**
-   * Retrieves the set of objectclasses registered with the Directory
-   * Server.  The mapping will be between the lowercase name or OID
-   * for each objectclass and the objectclass implementation.  The
-   * same objectclass instance may be included multiple times with
-   * different keys.  The returned map must not be altered by the
-   * caller.
-   *
-   * @return  The set of objectclasses defined in the Directory
-   *          Server.
-   */
-  public static Map<String,ObjectClass> getObjectClasses()
-  {
-    return DirectoryServer.getObjectClasses();
-  }
-
-  /**
    * Retrieves the objectclass for the provided lowercase name or OID.
    * It can optionally return a generated "default" version if the
    * requested objectclass is not defined in the schema.
@@ -404,21 +388,6 @@
   }
 
   /**
-   * Retrieves the set of DIT content rules defined in the Directory
-   * Server.  The mapping will be between the structural objectclass
-   * and its corresponding DIT content rule.  The returned map must
-   * not be altered by the caller.
-   *
-   * @return  The set of DIT content rules defined in the Directory
-   *          Server.
-   */
-  public static Map<ObjectClass,DITContentRule>
-       getDITContentRules()
-  {
-    return DirectoryServer.getDITContentRules();
-  }
-
-  /**
    * Retrieves the DIT content rule associated with the specified
    * objectclass.
    *
@@ -435,21 +404,6 @@
   }
 
   /**
-   * Retrieves the set of DIT structure rules defined in the Directory
-   * Server.  The mapping will be between the name form and its
-   * corresponding DIT structure rule.  The returned map must not be
-   * altered by the caller.
-   *
-   * @return  The set of DIT structure rules defined in the Directory
-   *          Server.
-   */
-  public static Map<NameForm,DITStructureRule>
-       getDITStructureRules()
-  {
-    return DirectoryServer.getDITStructureRules();
-  }
-
-  /**
    * Retrieves the DIT structure rule associated with the provided
    * rule ID.
    *
@@ -481,19 +435,6 @@
   }
 
   /**
-   * Retrieves the set of name forms defined in the Directory Server.
-   * The mapping will be between the structural objectclass and its
-   * corresponding name forms.  The returned map must not be altered
-   * by the caller.
-   *
-   * @return  The set of name forms defined in the Directory Server.
-   */
-  public static Map<ObjectClass,List<NameForm>> getNameForms()
-  {
-    return DirectoryServer.getNameForms();
-  }
-
-  /**
    * Retrieves the list of name forms associated with the specified
    * structural objectclass.
    *
@@ -727,21 +668,6 @@
   }
 
   /**
-   * Retrieves the set of extended operations that may be processed by
-   * the Directory Server.  The mapping will be between the OID and
-   * the extended operation handler providing the logic for the
-   * extended operation with that OID.  The returned map must not be
-   * altered by the caller.
-   *
-   * @return  The set of extended operations that may be processed by
-   *          the Directory Server.
-   */
-  public static Map<String, ExtendedOperationHandler<?>> getSupportedExtensions()
-  {
-    return DirectoryServer.getSupportedExtensions();
-  }
-
-  /**
    * Retrieves the handler for the extended operation for the provided
    * extended operation OID.
    *
@@ -780,20 +706,6 @@
   }
 
   /**
-   * Retrieves the set of SASL mechanisms that are supported by the
-   * Directory Server.  The mapping will be between the mechanism name
-   * and the SASL mechanism handler that implements support for that
-   * mechanism.  The returned map must not be altered by the caller.
-   *
-   * @return  The set of SASL mechanisms that are supported by the
-   *          Directory Server.
-   */
-  public static Map<String, SASLMechanismHandler<?>> getSupportedSASLMechanisms()
-  {
-    return DirectoryServer.getSupportedSASLMechanisms();
-  }
-
-  /**
    * Retrieves the handler for the specified SASL mechanism.
    *
    * @param  name  The name of the SASL mechanism to retrieve.
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 2427b94..6ac8c6c 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
@@ -569,7 +569,8 @@
 
   private static void clearJEBackends() throws Exception
   {
-    for (Backend<?> backend : DirectoryServer.getBackends().values()) {
+    for (Backend<?> backend : DirectoryServer.getBackends())
+    {
       if (backend instanceof BackendImpl) {
         clearBackend(backend.getBackendID());
       }
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 af92aff..d4cda66 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
@@ -52,7 +52,7 @@
   @DataProvider(name = "backends")
   public Object[][] getBackends()
   {
-    List<Backend<?>> backendList = new ArrayList<>(DirectoryServer.getBackends().values());
+    List<Backend<?>> backendList = new ArrayList<>(DirectoryServer.getBackends());
     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/monitors/BackendMonitorTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/monitors/BackendMonitorTestCase.java
index 52fe35a..47615d9 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/monitors/BackendMonitorTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/monitors/BackendMonitorTestCase.java
@@ -16,7 +16,6 @@
  */
 package org.opends.server.monitors;
 
-import org.forgerock.opendj.server.config.server.MonitorProviderCfg;
 import org.opends.server.api.MonitorProvider;
 import org.opends.server.core.DirectoryServer;
 import org.testng.annotations.Test;
@@ -43,12 +42,9 @@
    * @throws  Exception  If an unexpected problem occurs.
    */
   @Override
-  protected MonitorProvider getMonitorInstance()
-         throws Exception
+  protected MonitorProvider<?> getMonitorInstance() throws Exception
   {
-    String monitorName = "userroot backend";
-    MonitorProvider<? extends MonitorProviderCfg> provider =
-         DirectoryServer.getMonitorProvider(monitorName);
+    MonitorProvider<?> provider = DirectoryServer.getMonitorProviders().get("userroot backend");
     provider.initializeMonitorProvider(null);
     return provider;
   }
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/monitors/TraditionalWorkQueueMonitorTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/monitors/TraditionalWorkQueueMonitorTestCase.java
index 6e85068..b499bd9 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/monitors/TraditionalWorkQueueMonitorTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/monitors/TraditionalWorkQueueMonitorTestCase.java
@@ -40,7 +40,6 @@
   @Override
   protected MonitorProvider<?> getMonitorInstance() throws Exception
   {
-    String monitorName = "work queue";
-    return DirectoryServer.getMonitorProvider(monitorName);
+    return DirectoryServer.getMonitorProviders().get("work queue");
   }
 }
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java
index 9be6fdd..efc1214 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java
@@ -139,13 +139,13 @@
          throws Exception
   {
     AttributeType entryUUIDType = DirectoryServer.getAttributeType("entryuuid");
-    DirectoryServer.deregisterAttributeType(entryUUIDType);
+    DirectoryServer.getSchema().deregisterAttributeType(entryUUIDType);
 
     EntryUUIDPlugin plugin = initializePlugin(e);
     plugin.finalizePlugin();
 
 
-    DirectoryServer.registerAttributeType(entryUUIDType, false);
+    DirectoryServer.getSchema().registerAttributeType(entryUUIDType, false);
   }
 
 
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
index 1bc945d..6bd451b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
@@ -163,20 +163,20 @@
     AttributeType mtType = DirectoryServer.getAttributeType("modifytimestamp");
     AttributeType mnType = DirectoryServer.getAttributeType("modifiersname");
 
-    DirectoryServer.deregisterAttributeType(ctType);
-    DirectoryServer.deregisterAttributeType(cnType);
-    DirectoryServer.deregisterAttributeType(mtType);
-    DirectoryServer.deregisterAttributeType(mnType);
+    DirectoryServer.getSchema().deregisterAttributeType(ctType);
+    DirectoryServer.getSchema().deregisterAttributeType(cnType);
+    DirectoryServer.getSchema().deregisterAttributeType(mtType);
+    DirectoryServer.getSchema().deregisterAttributeType(mnType);
 
 
     LastModPlugin plugin = pp(e);
     plugin.finalizePlugin();
 
 
-    DirectoryServer.registerAttributeType(ctType, false);
-    DirectoryServer.registerAttributeType(cnType, false);
-    DirectoryServer.registerAttributeType(mtType, false);
-    DirectoryServer.registerAttributeType(mnType, false);
+    DirectoryServer.getSchema().registerAttributeType(ctType, false);
+    DirectoryServer.getSchema().registerAttributeType(cnType, false);
+    DirectoryServer.getSchema().registerAttributeType(mtType, false);
+    DirectoryServer.getSchema().registerAttributeType(mnType, false);
   }
 
 

--
Gitblit v1.10.0