From 6bfbfad766301d118de20551a47063952ebd13fa Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 17 Jan 2006 21:44:37 +0000 Subject: [PATCH] add pause/resume service controls --- .../net/hyperic/sigar/cmd/Win32Service.java | 8 +++++++ .../src/net/hyperic/sigar/win32/Service.java | 24 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Win32Service.java b/bindings/java/src/net/hyperic/sigar/cmd/Win32Service.java index cbd898b0..d92b5217 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Win32Service.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Win32Service.java @@ -15,6 +15,8 @@ public class Win32Service extends SigarCommandBase { "state", "start", "stop", + "pause", + "resume", "restart", }); @@ -67,6 +69,12 @@ public class Win32Service extends SigarCommandBase { else if (cmd.equals("stop")) { service.stop(); } + else if (cmd.equals("pause")) { + service.pause(); + } + else if (cmd.equals("resume")) { + service.resume(); + } else if (cmd.equals("delete")) { service.delete(); } diff --git a/bindings/java/src/net/hyperic/sigar/win32/Service.java b/bindings/java/src/net/hyperic/sigar/win32/Service.java index 5f681362..487f0133 100644 --- a/bindings/java/src/net/hyperic/sigar/win32/Service.java +++ b/bindings/java/src/net/hyperic/sigar/win32/Service.java @@ -262,6 +262,30 @@ public class Service extends Win32 { } } + public void pause() throws Win32Exception + { + control(CONTROL_PAUSE); + } + + public void pause(long timeout) throws Win32Exception + { + long status; + + pause(); + + Waiter waiter = + new Waiter(this, timeout, SERVICE_PAUSED, SERVICE_PAUSE_PENDING); + + if (!waiter.sleep()) { + throw new Win32Exception("Failed to pause service"); + } + } + + public void resume() throws Win32Exception + { + control(CONTROL_RESUME); + } + public ServiceConfig getConfig() throws Win32Exception { ServiceConfig config = new ServiceConfig(); QueryServiceConfig(this.service, config);