add ServiceConfig class and move some constants there

This commit is contained in:
Doug MacEachern 2005-06-25 16:58:59 +00:00
parent 807758db55
commit 1163e0c803
2 changed files with 197 additions and 25 deletions

View File

@ -13,13 +13,6 @@ public class Service extends Win32Bindings implements java.io.Serializable
public static final int SERVICE_PAUSE_PENDING = 0x00000006;
public static final int SERVICE_PAUSED = 0x00000007;
// Start Type
public static final int SERVICE_BOOT_START = 0x00000000;
public static final int SERVICE_SYSTEM_START = 0x00000001;
public static final int SERVICE_AUTO_START = 0x00000002;
public static final int SERVICE_DEMAND_START = 0x00000003;
public static final int SERVICE_DISABLED = 0x00000004;
// Service Controls
private static final int SERVICE_CONTROL_STOP = 0x00000001;
private static final int SERVICE_CONTROL_PAUSE = 0x00000002;
@ -79,21 +72,6 @@ public class Service extends Win32Bindings implements java.io.Serializable
SERVICE_INTERROGATE |
SERVICE_USER_DEFINED_CONTROL);
// Service Types (Bit Mask)
private static final int SERVICE_KERNEL_DRIVER = 0x00000001;
private static final int SERVICE_FILE_SYSTEM_DRIVER = 0x00000002;
private static final int SERVICE_ADAPTER = 0x00000004;
private static final int SERVICE_RECOGNIZER_DRIVER = 0x00000008;
private static final int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
private static final int SERVICE_WIN32_SHARE_PROCESS = 0x00000020;
private static final int SERVICE_INTERACTIVE_PROCESS = 0x00000100;
// Error control type
private static final int SERVICE_ERROR_IGNORE = 0x00000000;
private static final int SERVICE_ERROR_NORMAL = 0x00000001;
private static final int SERVICE_ERROR_SEVERE = 0x00000002;
private static final int SERVICE_ERROR_CRITICAL = 0x00000003;
///////////////////////////////////////////////////////
// Object Variables
private long m_hMgr;
@ -144,9 +122,10 @@ public class Service extends Win32Bindings implements java.io.Serializable
String path)
throws Win32Exception
{
return Service.create(serviceName, displayName,
description, SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
return Service.create(serviceName, displayName, description,
ServiceConfig.TYPE_WIN32_OWN_PROCESS,
ServiceConfig.START_AUTO,
ServiceConfig.ERROR_NORMAL,
path, null, null, "");
}

View File

@ -0,0 +1,193 @@
package net.hyperic.sigar.win32;
public class ServiceConfig {
// Start type
/**
* A device driver started by the system loader. This value is valid only for driver services.
*/
public static final int START_BOOT = 0x00000000;
/**
* A device driver started by the IoInitSystem function. This value is valid only for driver services.
*/
public static final int START_SYSTEM = 0x00000001;
/**
* A service started automatically by the service control manager during system startup.
*/
public static final int START_AUTO = 0x00000002;
/**
* A service started by the service control manager when a process calls the StartService function.
*/
public static final int START_MANUAL = 0x00000003;
/**
* A service that cannot be started.
* Attempts to start the service result in the error code ERROR_SERVICE_DISABLED.
*/
public static final int START_DISABLED = 0x00000004;
/**
* Driver service.
*/
public static final int TYPE_KERNEL_DRIVER = 0x00000001;
/**
* File system driver service.
*/
public static final int TYPE_FILE_SYSTEM_DRIVER = 0x00000002;
public static final int TYPE_ADAPTER = 0x00000004;
public static final int TYPE_RECOGNIZER_DRIVER = 0x00000008;
/**
* Service that runs in its own process.
*/
public static final int TYPE_WIN32_OWN_PROCESS = 0x00000010;
/**
* Service that shares a process with other services.
*/
public static final int TYPE_WIN32_SHARE_PROCESS = 0x00000020;
/**
* The service can interact with the desktop.
*/
public static final int TYPE_INTERACTIVE_PROCESS = 0x00000100;
// Error control type
/**
* The startup (boot) program logs the error but continues the startup operation.
*/
public static final int ERROR_IGNORE = 0x00000000;
/**
* The startup program logs the error and displays a message box pop-up but continues the startup operation.
*/
public static final int ERROR_NORMAL = 0x00000001;
/**
* The startup program logs the error.
* If the last-known good configuration is being started, the startup operation continues.
* Otherwise, the system is restarted with the last-known-good configuration.
*/
public static final int ERROR_SEVERE = 0x00000002;
/**
* The startup program logs the error, if possible.
* If the last-known good configuration is being started, the startup operation fails.
* Otherwise, the system is restarted with the last-known good configuration.
*/
public static final int ERROR_CRITICAL = 0x00000003;
int type;
int startType;
int errorControl;
String binaryPathName;
String loadOrderGroup;
int tagId;
String dependencies;
String serviceStartName;
String displayName;
/**
* @return Returns the binaryPathName.
*/
public String getBinaryPathName() {
return binaryPathName;
}
/**
* @param binaryPathName The binaryPathName to set.
*/
public void setBinaryPathName(String binaryPathName) {
this.binaryPathName = binaryPathName;
}
/**
* @return Returns the dependencies.
*/
public String getDependencies() {
return dependencies;
}
/**
* @param dependencies The dependencies to set.
*/
public void setDependencies(String dependencies) {
this.dependencies = dependencies;
}
/**
* @return Returns the displayName.
*/
public String getDisplayName() {
return displayName;
}
/**
* @param displayName The displayName to set.
*/
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
/**
* @return Returns the errorControl, one of ERROR_* constants.
*/
public int getErrorControl() {
return errorControl;
}
/**
* @param errorControl The errorControl to set, one of ERROR_* constants.
*/
public void setErrorControl(int errorControl) {
this.errorControl = errorControl;
}
/**
* @return Returns the loadOrderGroup.
*/
public String getLoadOrderGroup() {
return loadOrderGroup;
}
/**
* @param loadOrderGroup The loadOrderGroup to set.
*/
public void setLoadOrderGroup(String loadOrderGroup) {
this.loadOrderGroup = loadOrderGroup;
}
/**
* @return Returns the serviceStartName.
*/
public String getServiceStartName() {
return serviceStartName;
}
/**
* @param serviceStartName The serviceStartName to set.
*/
public void setServiceStartName(String serviceStartName) {
this.serviceStartName = serviceStartName;
}
/**
* @return Returns the startType, one of START_* constants.
*/
public int getStartType() {
return startType;
}
/**
* @param startType The startType to set, one of START_* constants.
*/
public void setStartType(int startType) {
this.startType = startType;
}
/**
* @return Returns the tagId.
*/
public int getTagId() {
return tagId;
}
/**
* @param tagId The tagId to set.
*/
public void setTagId(int tagId) {
this.tagId = tagId;
}
/**
* @return Returns the type, one of TYPE_* constants.
*/
public int getType() {
return type;
}
/**
* @param type The type to set, one of TYPE_* constants.
*/
public void setType(int type) {
this.type = type;
}
}