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

neil_a_wilson
17.24.2007 476ab6a2f8e1c5f60321626a27f7d82a008243af
Provide a new EmbeddedUtils.initializeForClientUse() method that can be used to
initialize the proper internal structures so that OpenDS code can be more
easily used for client-side applications that could benefit from the code but
don't want or need to be running in the same JVM as the server.

Also, update the DirectoryServer.bootstrapClient() method (which is what
EmbeddedUtils.initializeForClientUse() uses behind the scenes) can be called
multiple times on the same server instance without interfering with any
previous initialization that might have been done. In short, it will ensure
that this initialization occurs no more than once during the life of the
DirectoryServer object instance.
8 files modified
53 ■■■■ changed files
opends/src/server/org/opends/server/core/DirectoryServer.java 13 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPCompare.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPDelete.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPModify.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPPasswordModify.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPSearch.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/EmbeddedUtils.java 15 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -347,6 +347,9 @@
  // Indicates whether the server has been bootstrapped.
  private boolean isBootstrapped;
  // Indicates whether the server has been bootstrapped for client use.
  private boolean isClientBootstrapped;
  // Indicates whether the server is currently online.
  private boolean isRunning;
@@ -723,6 +726,7 @@
  {
    environmentConfig        = config;
    isBootstrapped           = false;
    isClientBootstrapped     = false;
    isRunning                = false;
    shuttingDown             = false;
    lockdownMode             = false;
@@ -825,6 +829,14 @@
   */
  public static void bootstrapClient()
  {
    synchronized (directoryServer)
    {
      if (directoryServer.isClientBootstrapped)
      {
        return;
      }
    // Set default values for variables that may be needed during schema
    // processing.
    directoryServer.syntaxEnforcementPolicy = AcceptRejectWarn.REJECT;
@@ -914,6 +926,7 @@
    directoryServer.returnBindErrorMessages = false;
    directoryServer.idleTimeLimit = 0L;
  }
  }
opends/src/server/org/opends/server/tools/LDAPCompare.java
@@ -47,11 +47,11 @@
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.protocols.ldap.LDAPMessage;
import org.opends.server.protocols.ldap.ProtocolOp;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.LDAPException;
import org.opends.server.util.Base64;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.PasswordReader;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
@@ -852,7 +852,7 @@
      if (initializeServer)
      {
        // Bootstrap and initialize directory data structures.
        DirectoryServer.bootstrapClient();
        EmbeddedUtils.initializeForClientUse();
      }
      // Connect to the specified host with the supplied userDN and password.
opends/src/server/org/opends/server/tools/LDAPDelete.java
@@ -38,7 +38,6 @@
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicInteger;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1Exception;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.protocols.ldap.DeleteRequestProtocolOp;
@@ -49,6 +48,7 @@
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.LDAPException;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.PasswordReader;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
@@ -730,7 +730,7 @@
      if (initializeServer)
      {
        // Bootstrap and initialize directory data structures.
        DirectoryServer.bootstrapClient();
        EmbeddedUtils.initializeForClientUse();
      }
      // Connect to the specified host with the supplied userDN and password.
opends/src/server/org/opends/server/tools/LDAPModify.java
@@ -38,7 +38,6 @@
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicInteger;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1Element;
import org.opends.server.protocols.asn1.ASN1Exception;
import org.opends.server.protocols.asn1.ASN1OctetString;
@@ -67,6 +66,7 @@
import org.opends.server.types.RawModification;
import org.opends.server.util.AddChangeRecordEntry;
import org.opends.server.util.ChangeRecordEntry;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.ModifyChangeRecordEntry;
@@ -1128,7 +1128,7 @@
      if (initializeServer)
      {
        // Bootstrap and initialize directory data structures.
        DirectoryServer.bootstrapClient();
        EmbeddedUtils.initializeForClientUse();
      }
      // Connect to the specified host with the supplied userDN and password.
opends/src/server/org/opends/server/tools/LDAPPasswordModify.java
@@ -37,7 +37,6 @@
import org.opends.server.controls.PasswordPolicyErrorType;
import org.opends.server.controls.PasswordPolicyResponseControl;
import org.opends.server.controls.PasswordPolicyWarningType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1Element;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.protocols.asn1.ASN1Sequence;
@@ -49,6 +48,7 @@
import org.opends.server.protocols.ldap.UnbindRequestProtocolOp;
import org.opends.server.types.DN;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.BooleanArgument;
@@ -535,7 +535,7 @@
    // Perform a basic Directory Server bootstrap if appropriate.
    if (initializeServer)
    {
      DirectoryServer.bootstrapClient();
      EmbeddedUtils.initializeForClientUse();
    }
opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -50,8 +50,8 @@
import org.opends.server.controls.ServerSideSortResponseControl;
import org.opends.server.controls.VLVRequestControl;
import org.opends.server.controls.VLVResponseControl;
import org.opends.server.core.DirectoryServer;
import org.opends.server.util.Base64;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.PasswordReader;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
@@ -1588,7 +1588,7 @@
      if (initializeServer)
      {
        // Bootstrap and initialize directory data structures.
        DirectoryServer.bootstrapClient();
        EmbeddedUtils.initializeForClientUse();
      }
      // Connect to the specified host with the supplied userDN and password.
opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java
@@ -51,11 +51,11 @@
import org.opends.server.admin.Tag;
import org.opends.server.admin.client.ManagedObjectDecodingException;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.tools.ClientException;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.InitializationException;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.BooleanArgument;
@@ -210,8 +210,7 @@
   */
  public void initializeClientEnvironment() throws InitializationException {
    if (environmentInitialized == false) {
      // TODO: do we need to do this?
      DirectoryServer.bootstrapClient();
      EmbeddedUtils.initializeForClientUse();
      // Bootstrap definition classes.
      ClassLoaderProvider.getInstance().enable();
opends/src/server/org/opends/server/util/EmbeddedUtils.java
@@ -119,5 +119,20 @@
  {
    DirectoryServer.restart(className, reason, config);
  }
  /**
   * Sets up a number of internal server data structures to ensure that they are
   * properly initialized for use.  This is necessary if server libraries are
   * going to be used without the server running (e.g., to facilitate use in an
   * LDAP client API, for DN processing, etc.).  This will have no effect if the
   * server has already been initialized for client use.
   */
  public static void initializeForClientUse()
  {
    DirectoryServer directoryServer = DirectoryServer.getInstance();
    directoryServer.bootstrapClient();
  }
}