From 313c7ce226afaa79e811d6fa0f5ad8b8a59f0fd5 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 13 Aug 2007 14:48:19 +0000
Subject: [PATCH] Provide a new org.opends.server.util.EmbeddedUtils class that can be used to simplify the process of running the server as an embedded application.  There are methods to start, stop, and restart the server, as well as to determine whether the server is running.  Also, provide a new org.opends.server.types.DirectoryEnvironmentConfig class that can be used to define a number of "environment" properties that provide information about the way in which the server should run.

---
 opends/src/server/org/opends/server/extensions/ConfigFileHandler.java |   41 +++++++++--------------------------------
 1 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java b/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
index e878102..888b65c 100644
--- a/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
+++ b/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
@@ -655,38 +655,11 @@
     }
 
 
-    // Determine the appropriate server root for the Directory Server.  First,
-    // do this by looking for a Java property.  If that isn't specified, then
-    // look for an environment variable, and if all else fails then try to
-    // figure it out from the location of the configuration file.
-    String rootDirStr = System.getProperty(PROPERTY_SERVER_ROOT);
-    if (rootDirStr == null)
-    {
-      rootDirStr = System.getenv(ENV_VAR_INSTANCE_ROOT);
-    }
-
-    if (rootDirStr != null)
-    {
-      try
-      {
-        File serverRootFile = new File(rootDirStr);
-        serverRoot = serverRootFile.getAbsolutePath();
-      }
-      catch (Exception e)
-      {
-        if (debugEnabled())
-        {
-          TRACER.debugCaught(DebugLogLevel.ERROR, e);
-        }
-
-        int    msgID   = MSGID_CONFIG_CANNOT_DETERMINE_SERVER_ROOT;
-        String message = getMessage(msgID, ENV_VAR_INSTANCE_ROOT);
-        throw new InitializationException(msgID, message);
-      }
-    }
-
-
-    if (serverRoot == null)
+    // Determine the appropriate server root.  If it's not defined in the
+    // environment config, then try to figure it out from the location of the
+    // configuration file.
+    File rootFile = DirectoryServer.getEnvironmentConfig().getServerRoot();
+    if (rootFile == null)
     {
       try
       {
@@ -725,6 +698,10 @@
         throw new InitializationException(msgID, message);
       }
     }
+    else
+    {
+      serverRoot = rootFile.getAbsolutePath();
+    }
 
 
     // Register with the Directory Server as an alert generator.

--
Gitblit v1.10.0