add pause/resume service controls

This commit is contained in:
Doug MacEachern 2006-01-17 21:44:37 +00:00
parent 1be17d8e6d
commit 6bfbfad766
2 changed files with 32 additions and 0 deletions

View File

@ -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();
}

View File

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