From 467c5105a16caa80d02cc34c13a6b8b76f9dcc79 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 02 Jul 2009 00:00:35 +0000
Subject: [PATCH] Fix for issue 4082 (stop-ds -p ADMIN_PORT doesn't stop Windows OpenDS service) When the server is configured as a Windows Service, use the class StopWindowsService to stop the server.

---
 opends/src/server/org/opends/server/tasks/ShutdownTask.java |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/opends/src/server/org/opends/server/tasks/ShutdownTask.java b/opends/src/server/org/opends/server/tasks/ShutdownTask.java
index 24e0274..ab30a5c 100644
--- a/opends/src/server/org/opends/server/tasks/ShutdownTask.java
+++ b/opends/src/server/org/opends/server/tasks/ShutdownTask.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
+ *      Copyright 2006-2009 Sun Microsystems, Inc.
  */
 package org.opends.server.tasks;
 
@@ -176,8 +176,24 @@
     // that will be responsible for really invoking the shutdown and then this
     // method will return.  We'll have to use different types of threads
     // depending on whether we're doing a restart or a shutdown.
-    if (restart)
+    boolean configuredAsService =
+      DirectoryServer.isRunningAsWindowsService();
+    if (configuredAsService && !restart)
     {
+      ShutdownTaskThread shutdownThread =
+        new ShutdownTaskThread(shutdownMessage)
+      {
+        public void run()
+        {
+          org.opends.server.tools.StopWindowsService.main(new String[]{});
+        }
+      };
+      shutdownThread.start();
+    }
+    else if (restart)
+    {
+      // Since the process will not be killed, we can proceed exactly the same
+      // way with or without windows service configured.
       RestartTaskThread restartThread = new RestartTaskThread(shutdownMessage);
       restartThread.start();
     }

--
Gitblit v1.10.0