From 856bfa759bec64b3cfc710fa26b755855bcc61c8 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 28 Feb 2007 11:35:55 +0000
Subject: [PATCH] Fix for issue 1285.

---
 opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java |   38 ++++++++++++++++++++++++++++++++------
 1 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java b/opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java
index b5afae0..9b39593 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java
@@ -213,14 +213,40 @@
   }
 
   /**
-   * Indicates whether there is the server is running.
-   *
-   * @return <CODE>true</CODE> if the server is running, or <CODE>false</CODE>
-   *         if not.
+   * Returns if the server is running on the given path.
+   * NOTE: this method is to be called only when the OpenDS.jar class has
+   * already been loaded as it uses classes in that jar.
+   * @return <CODE>true</CODE> if the server is running and <CODE>false</CODE>
+   * otherwise.
    */
-  public boolean isServerRunning()
+  public static boolean isServerRunning()
   {
-    return Utils.isServerRunning(Utils.getInstallPathFromClasspath());
+    boolean isServerRunning;
+    String lockFile =
+      org.opends.server.core.LockFileManager.getServerLockFileName();
+    StringBuilder failureReason = new StringBuilder();
+    try
+    {
+      if (org.opends.server.core.LockFileManager.acquireExclusiveLock(lockFile,
+          failureReason))
+      {
+        org.opends.server.core.LockFileManager.releaseLock(lockFile,
+            failureReason);
+        isServerRunning = false;
+      }
+      else
+      {
+        isServerRunning = true;
+      }
+    }
+    catch (Throwable t)
+    {
+      t.printStackTrace();
+      // Assume that if we cannot acquire the lock file the server is
+      // running.
+      isServerRunning = true;
+    }
+    return isServerRunning;
   }
 
   /**

--
Gitblit v1.10.0