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);